Commit 3242ca5fc97d09766efb124e9b88fcd96db248e4
1 parent
f0bc674e
Exists in
master
Modificação na interface ConfigurationValueExtractor para receber um
Configuration como parâmetro ao invés de DataConfiguration.
Showing
7 changed files
with
17 additions
and
15 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/configuration/ConfigurationValueExtractor.java
| ... | ... | @@ -38,11 +38,11 @@ package br.gov.frameworkdemoiselle.configuration; |
| 38 | 38 | |
| 39 | 39 | import java.lang.reflect.Field; |
| 40 | 40 | |
| 41 | -import org.apache.commons.configuration.DataConfiguration; | |
| 41 | +import org.apache.commons.configuration.Configuration; | |
| 42 | 42 | |
| 43 | 43 | public interface ConfigurationValueExtractor { |
| 44 | 44 | |
| 45 | - Object getValue(String prefix, String key, Field field, DataConfiguration configuration, Object defaultValue); | |
| 45 | + Object getValue(String prefix, String key, Field field, Configuration configuration, Object defaultValue); | |
| 46 | 46 | |
| 47 | 47 | boolean isSupported(Field field); |
| 48 | 48 | } | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationArrayValueExtractor.java
| ... | ... | @@ -40,6 +40,7 @@ import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelecto |
| 40 | 40 | |
| 41 | 41 | import java.lang.reflect.Field; |
| 42 | 42 | |
| 43 | +import org.apache.commons.configuration.Configuration; | |
| 43 | 44 | import org.apache.commons.configuration.DataConfiguration; |
| 44 | 45 | |
| 45 | 46 | import br.gov.frameworkdemoiselle.annotation.Priority; |
| ... | ... | @@ -49,8 +50,9 @@ import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; |
| 49 | 50 | public class ConfigurationArrayValueExtractor implements ConfigurationValueExtractor { |
| 50 | 51 | |
| 51 | 52 | @Override |
| 52 | - public Object getValue(String prefix, String key, Field field, DataConfiguration configuration, Object defaultValue) { | |
| 53 | - return configuration.getArray(field.getType().getComponentType(), prefix + key, defaultValue); | |
| 53 | + public Object getValue(String prefix, String key, Field field, Configuration configuration, Object defaultValue) { | |
| 54 | + return new DataConfiguration(configuration).getArray(field.getType().getComponentType(), prefix + key, | |
| 55 | + defaultValue); | |
| 54 | 56 | } |
| 55 | 57 | |
| 56 | 58 | @Override | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationClassValueExtractor.java
| ... | ... | @@ -40,7 +40,7 @@ import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelecto |
| 40 | 40 | |
| 41 | 41 | import java.lang.reflect.Field; |
| 42 | 42 | |
| 43 | -import org.apache.commons.configuration.DataConfiguration; | |
| 43 | +import org.apache.commons.configuration.Configuration; | |
| 44 | 44 | |
| 45 | 45 | import br.gov.frameworkdemoiselle.annotation.Priority; |
| 46 | 46 | import br.gov.frameworkdemoiselle.configuration.ConfigurationException; |
| ... | ... | @@ -51,7 +51,7 @@ import br.gov.frameworkdemoiselle.util.Reflections; |
| 51 | 51 | public class ConfigurationClassValueExtractor implements ConfigurationValueExtractor { |
| 52 | 52 | |
| 53 | 53 | @Override |
| 54 | - public Object getValue(String prefix, String key, Field field, DataConfiguration configuration, Object defaultValue) { | |
| 54 | + public Object getValue(String prefix, String key, Field field, Configuration configuration, Object defaultValue) { | |
| 55 | 55 | Object value = defaultValue; |
| 56 | 56 | String canonicalName = configuration.getString(prefix + key); |
| 57 | 57 | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoader.java
| ... | ... | @@ -49,7 +49,6 @@ import javax.inject.Inject; |
| 49 | 49 | import javax.validation.constraints.NotNull; |
| 50 | 50 | |
| 51 | 51 | import org.apache.commons.configuration.AbstractConfiguration; |
| 52 | -import org.apache.commons.configuration.DataConfiguration; | |
| 53 | 52 | import org.apache.commons.configuration.FileConfiguration; |
| 54 | 53 | import org.apache.commons.configuration.PropertiesConfiguration; |
| 55 | 54 | import org.apache.commons.configuration.SystemConfiguration; |
| ... | ... | @@ -84,7 +83,7 @@ public class ConfigurationLoader implements Serializable { |
| 84 | 83 | |
| 85 | 84 | private String prefix; |
| 86 | 85 | |
| 87 | - private DataConfiguration configuration; | |
| 86 | + private org.apache.commons.configuration.Configuration configuration; | |
| 88 | 87 | |
| 89 | 88 | private Set<Field> fields; |
| 90 | 89 | |
| ... | ... | @@ -163,7 +162,7 @@ public class ConfigurationLoader implements Serializable { |
| 163 | 162 | } |
| 164 | 163 | } |
| 165 | 164 | |
| 166 | - this.configuration = (conf == null ? null : new DataConfiguration(conf)); | |
| 165 | + this.configuration = conf; | |
| 167 | 166 | } |
| 168 | 167 | |
| 169 | 168 | private void loadExtractors() { | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationMapValueExtractor.java
| ... | ... | @@ -45,7 +45,7 @@ import java.util.Map; |
| 45 | 45 | import java.util.regex.Matcher; |
| 46 | 46 | import java.util.regex.Pattern; |
| 47 | 47 | |
| 48 | -import org.apache.commons.configuration.DataConfiguration; | |
| 48 | +import org.apache.commons.configuration.Configuration; | |
| 49 | 49 | |
| 50 | 50 | import br.gov.frameworkdemoiselle.annotation.Priority; |
| 51 | 51 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; |
| ... | ... | @@ -54,7 +54,7 @@ import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; |
| 54 | 54 | public class ConfigurationMapValueExtractor implements ConfigurationValueExtractor { |
| 55 | 55 | |
| 56 | 56 | @Override |
| 57 | - public Object getValue(String prefix, String key, Field field, DataConfiguration configuration, Object defaultValue) { | |
| 57 | + public Object getValue(String prefix, String key, Field field, Configuration configuration, Object defaultValue) { | |
| 58 | 58 | @SuppressWarnings("unchecked") |
| 59 | 59 | Map<String, Object> value = (Map<String, Object>) defaultValue; |
| 60 | 60 | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationPrimitiveOrWrapperValueExtractor.java
| ... | ... | @@ -42,6 +42,7 @@ import java.lang.reflect.Field; |
| 42 | 42 | import java.util.HashSet; |
| 43 | 43 | import java.util.Set; |
| 44 | 44 | |
| 45 | +import org.apache.commons.configuration.Configuration; | |
| 45 | 46 | import org.apache.commons.configuration.ConversionException; |
| 46 | 47 | import org.apache.commons.configuration.DataConfiguration; |
| 47 | 48 | import org.apache.commons.lang.ClassUtils; |
| ... | ... | @@ -68,11 +69,11 @@ public class ConfigurationPrimitiveOrWrapperValueExtractor implements Configurat |
| 68 | 69 | |
| 69 | 70 | @Override |
| 70 | 71 | @SuppressWarnings("unchecked") |
| 71 | - public Object getValue(String prefix, String key, Field field, DataConfiguration configuration, Object defaultValue) { | |
| 72 | + public Object getValue(String prefix, String key, Field field, Configuration configuration, Object defaultValue) { | |
| 72 | 73 | Object value; |
| 73 | 74 | |
| 74 | 75 | try { |
| 75 | - value = configuration.get(ClassUtils.primitiveToWrapper(field.getType()), prefix + key, defaultValue); | |
| 76 | + value = new DataConfiguration(configuration).get(ClassUtils.primitiveToWrapper(field.getType()), prefix + key, defaultValue); | |
| 76 | 77 | |
| 77 | 78 | } catch (ConversionException cause) { |
| 78 | 79 | value = defaultValue; | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationStringValueExtractor.java
| ... | ... | @@ -40,7 +40,7 @@ import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelecto |
| 40 | 40 | |
| 41 | 41 | import java.lang.reflect.Field; |
| 42 | 42 | |
| 43 | -import org.apache.commons.configuration.DataConfiguration; | |
| 43 | +import org.apache.commons.configuration.Configuration; | |
| 44 | 44 | |
| 45 | 45 | import br.gov.frameworkdemoiselle.annotation.Priority; |
| 46 | 46 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; |
| ... | ... | @@ -49,7 +49,7 @@ import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; |
| 49 | 49 | public class ConfigurationStringValueExtractor implements ConfigurationValueExtractor { |
| 50 | 50 | |
| 51 | 51 | @Override |
| 52 | - public Object getValue(String prefix, String key, Field field, DataConfiguration configuration, Object defaultValue) { | |
| 52 | + public Object getValue(String prefix, String key, Field field, Configuration configuration, Object defaultValue) { | |
| 53 | 53 | return configuration.getString(prefix + key, (String) defaultValue); |
| 54 | 54 | } |
| 55 | 55 | ... | ... |