-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
6 changed files
with
348 additions
and
343 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
135 changes: 135 additions & 0 deletions
135
core/api/src/main/java/cloud/piranha/core/api/PiranhaConfiguration.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,135 @@ | ||
/* | ||
* Copyright (c) 2002-2023 Manorrock.com. All Rights Reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package cloud.piranha.core.api; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* Piranha configuration. | ||
* | ||
* @author Manfred Riem ([email protected]) | ||
*/ | ||
public interface PiranhaConfiguration { | ||
|
||
/** | ||
* Get the value as a boolean. | ||
* | ||
* @param key the key. | ||
* @param defaultValue the default value if the key is not found. | ||
* @return the value. | ||
*/ | ||
boolean getBoolean(String key, boolean defaultValue); | ||
|
||
/** | ||
* Get the value as a class. | ||
* | ||
* @param key the key. | ||
* @return the value. | ||
*/ | ||
Class<?> getClass(String key); | ||
|
||
/** | ||
* Get the value as a File. | ||
* | ||
* @param key the key. | ||
* @return the value. | ||
*/ | ||
File getFile(String key); | ||
|
||
/** | ||
* Get the value as an int. | ||
* | ||
* @param key the key. | ||
* @return the value. | ||
*/ | ||
Integer getInteger(String key); | ||
|
||
/** | ||
* Get the value as a long. | ||
* | ||
* @param key the key. | ||
* @return the value. | ||
*/ | ||
Long getLong(String key); | ||
|
||
/** | ||
* Get the value as a string. | ||
* | ||
* @param key the key. | ||
* @return the value (or null if not set). | ||
*/ | ||
String getString(String key); | ||
|
||
/** | ||
* Set the boolean value. | ||
* | ||
* @param key the key. | ||
* @param value the boolean value. | ||
*/ | ||
void setBoolean(String key, Boolean value); | ||
|
||
/** | ||
* Set the class value. | ||
* | ||
* @param key the key. | ||
* @param value the class value. | ||
*/ | ||
void setClass(String key, Class<?> value); | ||
|
||
/** | ||
* Set the File value. | ||
* | ||
* @param key the key. | ||
* @param value the value. | ||
*/ | ||
void setFile(String key, File value); | ||
|
||
/** | ||
* Set the integer value. | ||
* | ||
* @param key the key. | ||
* @param value the value. | ||
*/ | ||
void setInteger(String key, Integer value); | ||
|
||
/** | ||
* Set the long value. | ||
* | ||
* @param key the key. | ||
* @param value the value. | ||
*/ | ||
void setLong(String key, Long value); | ||
|
||
/** | ||
* Set the string value. | ||
* | ||
* @param key the key. | ||
* @param value the value. | ||
*/ | ||
void setString(String key, String value); | ||
} |
109 changes: 109 additions & 0 deletions
109
core/impl/src/main/java/cloud/piranha/core/impl/DefaultPiranhaConfiguration.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,109 @@ | ||
/* | ||
* Copyright (c) 2002-2023 Manorrock.com. All Rights Reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package cloud.piranha.core.impl; | ||
|
||
import cloud.piranha.core.api.PiranhaConfiguration; | ||
import java.io.File; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* The default Piranha configuration implementation. | ||
* | ||
* @author Manfred Riem ([email protected]) | ||
*/ | ||
public class DefaultPiranhaConfiguration implements PiranhaConfiguration { | ||
|
||
/** | ||
* Stores the configuration. | ||
*/ | ||
private final Map<String, Object> configuration = new HashMap<>(); | ||
|
||
@Override | ||
public boolean getBoolean(String key, boolean defaultValue) { | ||
if (configuration.containsKey(key)) { | ||
return (boolean) configuration.get(key); | ||
} | ||
return defaultValue; | ||
} | ||
|
||
@Override | ||
public Class<?> getClass(String key) { | ||
return (Class<?>) configuration.get(key); | ||
} | ||
|
||
@Override | ||
public File getFile(String key) { | ||
return (File) configuration.get(key); | ||
} | ||
|
||
@Override | ||
public Integer getInteger(String key) { | ||
return (Integer) configuration.get(key); | ||
} | ||
|
||
@Override | ||
public Long getLong(String key) { | ||
return (Long) configuration.get(key); | ||
} | ||
|
||
@Override | ||
public String getString(String key) { | ||
return (String) configuration.get(key); | ||
} | ||
|
||
@Override | ||
public void setBoolean(String key, Boolean value) { | ||
configuration.put(key, value); | ||
} | ||
|
||
@Override | ||
public void setClass(String key, Class<?> value) { | ||
configuration.put(key, value); | ||
} | ||
|
||
@Override | ||
public void setFile(String key, File value) { | ||
configuration.put(key, value); | ||
} | ||
|
||
@Override | ||
public void setInteger(String key, Integer value) { | ||
configuration.put(key, value); | ||
} | ||
|
||
@Override | ||
public void setLong(String key, Long value) { | ||
configuration.put(key, value); | ||
} | ||
|
||
@Override | ||
public void setString(String key, String value) { | ||
configuration.put(key, value); | ||
} | ||
} |
Oops, something went wrong.