-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from nort/multi-env
support multiple environments
- Loading branch information
Showing
28 changed files
with
1,149 additions
and
191 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
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
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
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
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
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
28 changes: 28 additions & 0 deletions
28
src/main/java/pl/nort/config/source/context/DefaultEnvironment.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,28 @@ | ||
/* | ||
* Copyright 2015 Norbert Potocki (norbert.potocki@nort.pl) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package pl.nort.config.source.context; | ||
|
||
/** | ||
* Environment named "" (empty string). | ||
*/ | ||
public class DefaultEnvironment extends ImmutableEnvironment { | ||
/** | ||
* Constructs environment named "" (empty string). | ||
*/ | ||
public DefaultEnvironment() { | ||
super(""); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/pl/nort/config/source/context/Environment.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,30 @@ | ||
/* | ||
* Copyright 2015 Norbert Potocki (norbert.potocki@nort.pl) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package pl.nort.config.source.context; | ||
|
||
/** | ||
* Configuration environment. | ||
*/ | ||
public interface Environment { | ||
|
||
/** | ||
* Name of the environment. | ||
* | ||
* @return environment name | ||
*/ | ||
String getName(); | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/pl/nort/config/source/context/ImmutableEnvironment.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,40 @@ | ||
/* | ||
* Copyright 2015 Norbert Potocki (norbert.potocki@nort.pl) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package pl.nort.config.source.context; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
/** | ||
* {@link Environment} that never changes. | ||
*/ | ||
public class ImmutableEnvironment implements Environment { | ||
|
||
private final String envName; | ||
|
||
/** | ||
* Construct environment named {@code envName}. This name never changes. | ||
* | ||
* @param envName environment name to use | ||
*/ | ||
public ImmutableEnvironment(String envName) { | ||
this.envName = checkNotNull(envName); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return envName; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/pl/nort/config/source/context/MissingEnvironmentException.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,34 @@ | ||
/* | ||
* Copyright 2015 Norbert Potocki (norbert.potocki@nort.pl) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package pl.nort.config.source.context; | ||
|
||
/** | ||
* Indicates missing configuration environment | ||
*/ | ||
public class MissingEnvironmentException extends RuntimeException { | ||
|
||
private static final String MISSING_ENV_MSG = "Missing environment: "; | ||
|
||
/** | ||
* Environment named {@code envName} is missing. | ||
* | ||
* @param envName environment name | ||
* @param cause root cause | ||
*/ | ||
public MissingEnvironmentException(String envName, Throwable cause) { | ||
super(MISSING_ENV_MSG + envName, cause); | ||
} | ||
} |
Oops, something went wrong.