-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4900d87
Showing
49 changed files
with
3,060 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
target/ | ||
*.iml | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
language: java | ||
|
||
jdk: | ||
- oraclejdk8 | ||
|
||
after_success: | ||
- mvn clean test jacoco:report coveralls:report | ||
|
||
secure: "LGWj4Dr9uNyKkGBnnPB3yE3cyg9yJ9GkIbttGqrKx/2xTpsVrQFgv7oMCSUHjKQs9qUHPKvZ9Bt7o7sIkJrKq5JQIKSuE3/iwoyBrb52q9aD+pl39MKKk1Vn6ghyBttjrT8Z+nV2WU9y7Kpv+P2RSe8JHcr0ktUOQKbMuclMai8=" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
|
||
<img src="http://www.bagdemir.com/img/propane_banner.jpg"/> | ||
|
||
## | ||
|
||
<img src="https://travis-ci.org/bagdemir/propane.svg?branch=master"/> [![Coverage Status](https://coveralls.io/repos/bagdemir/Propane/badge.svg)](https://coveralls.io/r/bagdemir/Propane) <img src="https://img.shields.io/packagist/l/doctrine/orm.svg" /> [![GitHub version](https://badge.fury.io/gh/bagdemir%2Fpropane.svg)](https://badge.fury.io/gh/bagdemir%2Fpropane) | ||
|
||
Propane is a light-weight Java framework for Configuration Management. This | ||
project is inspired by the Netflix's Archaius project with some cool new | ||
features like annotation based configuration entities, custom context | ||
definitions and so on. If Archaius works for you, probably, you would keep it. | ||
If you make some considerations on managing your configurations throughout | ||
your applications from the scratch, Propane might be the right solution for you. | ||
|
||
[Check out Project's home for API docs.] (http://propane.moo.io) | ||
|
||
## Overview | ||
|
||
## | ||
|
||
Propane is a Java framework to manage your configurations for different contexts. | ||
- Annotate your Java classes with configuration management annotations. | ||
- Define your configurations for each context for a particular application. | ||
|
||
and then Propane enables the configuration set in applications for this given context. | ||
|
||
A context may be a region, an environment, or a custom context just defined by you. For instance, if your service is running in the US region and in the dev environment, Propane enables the configurations for Development + US in those applications running in US and dev environment. | ||
|
||
## Usage | ||
|
||
## | ||
|
||
Since the project is under development, you are able to test it by cloning the project on your computer and build it. | ||
|
||
<pre lang="shell"> | ||
git clone [email protected]:bagdemir/propane.git | ||
cd propane | ||
mvn -e clean install | ||
</pre> | ||
|
||
After you install propane in your local Maven repository, you can add it into your project by defining the dependency and test it: | ||
|
||
``` | ||
<dependency> | ||
<groupId>io.moo</groupId> | ||
<artifactId>propane</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</dependency> | ||
``` | ||
|
||
Now, you can create the configuration entities: | ||
|
||
<pre lang="java"> | ||
@Configuration(componentId = "test") | ||
@Source(url = "classpath://configurations/test.properties") | ||
public class TestConfigurationEntityWithClasspathSource { | ||
|
||
@KeyValue(name = "testProp") | ||
private String url; | ||
|
||
@KeyValue(name = "longProp") | ||
private Long timeout; | ||
|
||
@KeyValue(name = "intProp") | ||
private int count; | ||
|
||
private String nonPropField; | ||
|
||
} | ||
</pre> | ||
|
||
You can now register your entity witin the configuration manager: | ||
<pre lang="java"> | ||
final ConfigurationManager configurationManager = new ConfigurationManagerImpl(); | ||
configurationManager.register(TestConfigurationEntityWithClasspathSource.class); | ||
</pre> | ||
|
||
Once the configurations are loaded by the ConfigurationManager, you can access them: | ||
|
||
<pre lang="java"> | ||
final Optional<TestConfigurationEntityWithClasspathSource> configs = configurationManager.load(TestConfigurationEntityWithClasspathSource.class); | ||
final TestConfigurationEntityWithClasspathSource testPropsWithClasspathSource = configs.get(); | ||
testPropsWithClasspathSource.getUrl() | ||
</pre> | ||
|
||
That's all. | ||
|
||
|
||
## Contributing | ||
|
||
## | ||
|
||
1. Fork it ( https://github.com/bagdemir/propane/fork ) | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Add some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create a new Pull Request | ||
|
||
## License | ||
|
||
## | ||
|
||
Copyright (c) 2016 Erhan Bağdemir | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>io.moo</groupId> | ||
<artifactId>propane</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>propane-core</module> | ||
</modules> | ||
|
||
<description>Propane is a light-weight Java framework for Configuration Management.</description> | ||
|
||
<developers> | ||
<developer> | ||
<name>Erhan Bagdemir</name> | ||
<email>[email protected]</email> | ||
</developer> | ||
</developers> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Erhan Bağdemir | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>io.moo</groupId> | ||
<artifactId>propane-core</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<description>Propane is a light-weight Java framework for Configuration Management.</description> | ||
|
||
<developers> | ||
<developer> | ||
<name>Erhan Bagdemir</name> | ||
<email>[email protected]</email> | ||
</developer> | ||
</developers> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eluder.coveralls</groupId> | ||
<artifactId>coveralls-maven-plugin</artifactId> | ||
<version>3.1.0</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.jacoco</groupId> | ||
<artifactId>jacoco-maven-plugin</artifactId> | ||
<version>0.7.2.201409121644</version> | ||
<executions> | ||
<execution> | ||
<id>prepare-agent</id> | ||
<goals> | ||
<goal>prepare-agent</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.2</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-collections</groupId> | ||
<artifactId>commons-collections</artifactId> | ||
<version>3.2.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
<version>18.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-api</artifactId> | ||
<version>2.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-core</artifactId> | ||
<version>2.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest-all</artifactId> | ||
<version>1.3</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-all</artifactId> | ||
<version>1.10.19</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
97 changes: 97 additions & 0 deletions
97
propane-core/src/main/java/io/moo/propane/ConfigurationManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/** | ||
* The MIT License (MIT) | ||
* <p> | ||
* Copyright (c) 2015 moo.io , Erhan Bagdemir | ||
* <p> | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* <p> | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* <p> | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package io.moo.propane; | ||
|
||
import io.moo.propane.data.ContextInfo; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* <p>{@link ConfigurationManager} is the repository for your configuration | ||
* entities which lives in a context like environment, region, etc. According | ||
* to its content, the configuration managers gives only the configurations | ||
* back that they exist within the same configuration.</p> | ||
* <p> | ||
* <p> | ||
* <p>Each configuration manager instance may live in a context for which the | ||
* configuration manager handles the configurations. For instance, if the | ||
* configuration manager instance is configured for the environment <i>STAGE</i>, | ||
* only the configurations for the <i>STAGE</i> environment will be returned | ||
* to the clients of the manager.</p> | ||
* | ||
* @author bagdemir | ||
* @version 1.0 | ||
* @see ContextInfo | ||
* @see io.moo.propane.data.ConfigurationEntity | ||
* @since 1.0 | ||
*/ | ||
public interface ConfigurationManager { | ||
|
||
/** | ||
* Registers a new configuration entity type which is going to be managed | ||
* by this configuration manager. | ||
* | ||
* @param clazz The entity class type. | ||
* @param <T> The type of the entity. | ||
* @return The instance of the entity. | ||
*/ | ||
<T> boolean register(Class<T> clazz); | ||
|
||
/** | ||
* Queries if the entity class type has already been registered within this | ||
* entity manager. | ||
* | ||
* @param clazz The class type to be queried. | ||
* @param <T> The configuration entity type. | ||
* @return Boolean value. | ||
*/ | ||
<T> boolean isRegistered(Class<T> clazz); | ||
|
||
/** | ||
* Loads a registered entity instance. | ||
* | ||
* @param clazz The class type to be queried. | ||
* @param <T> The configuration entity type. | ||
* @return The configuration entity instance. | ||
*/ | ||
<T> Optional<T> load(Class<T> clazz); | ||
|
||
/** | ||
* @param clazz The class type to be queried. | ||
* @param contexts The optional context information. | ||
* @return The configuration entity instance. | ||
*/ | ||
<T> Optional<T> load(Class<T> clazz, Optional<ContextInfo> contexts); | ||
|
||
/** | ||
* Static factory to instantiate a manager. | ||
* | ||
* @param contextInfo Context info of the {@link ConfigurationManager}. | ||
* @return Manager instance. | ||
*/ | ||
static ConfigurationManager newManager(Optional<ContextInfo> contextInfo) { | ||
return new ConfigurationManagerImpl(contextInfo); | ||
} | ||
|
||
} |
Oops, something went wrong.