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,11 +38,11 @@ package br.gov.frameworkdemoiselle.configuration; | ||
| 38 | 38 | ||
| 39 | import java.lang.reflect.Field; | 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 | public interface ConfigurationValueExtractor { | 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 | boolean isSupported(Field field); | 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,6 +40,7 @@ import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelecto | ||
| 40 | 40 | ||
| 41 | import java.lang.reflect.Field; | 41 | import java.lang.reflect.Field; |
| 42 | 42 | ||
| 43 | +import org.apache.commons.configuration.Configuration; | ||
| 43 | import org.apache.commons.configuration.DataConfiguration; | 44 | import org.apache.commons.configuration.DataConfiguration; |
| 44 | 45 | ||
| 45 | import br.gov.frameworkdemoiselle.annotation.Priority; | 46 | import br.gov.frameworkdemoiselle.annotation.Priority; |
| @@ -49,8 +50,9 @@ import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; | @@ -49,8 +50,9 @@ import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; | ||
| 49 | public class ConfigurationArrayValueExtractor implements ConfigurationValueExtractor { | 50 | public class ConfigurationArrayValueExtractor implements ConfigurationValueExtractor { |
| 50 | 51 | ||
| 51 | @Override | 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 | @Override | 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,7 +40,7 @@ import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelecto | ||
| 40 | 40 | ||
| 41 | import java.lang.reflect.Field; | 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 | import br.gov.frameworkdemoiselle.annotation.Priority; | 45 | import br.gov.frameworkdemoiselle.annotation.Priority; |
| 46 | import br.gov.frameworkdemoiselle.configuration.ConfigurationException; | 46 | import br.gov.frameworkdemoiselle.configuration.ConfigurationException; |
| @@ -51,7 +51,7 @@ import br.gov.frameworkdemoiselle.util.Reflections; | @@ -51,7 +51,7 @@ import br.gov.frameworkdemoiselle.util.Reflections; | ||
| 51 | public class ConfigurationClassValueExtractor implements ConfigurationValueExtractor { | 51 | public class ConfigurationClassValueExtractor implements ConfigurationValueExtractor { |
| 52 | 52 | ||
| 53 | @Override | 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 | Object value = defaultValue; | 55 | Object value = defaultValue; |
| 56 | String canonicalName = configuration.getString(prefix + key); | 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,7 +49,6 @@ import javax.inject.Inject; | ||
| 49 | import javax.validation.constraints.NotNull; | 49 | import javax.validation.constraints.NotNull; |
| 50 | 50 | ||
| 51 | import org.apache.commons.configuration.AbstractConfiguration; | 51 | import org.apache.commons.configuration.AbstractConfiguration; |
| 52 | -import org.apache.commons.configuration.DataConfiguration; | ||
| 53 | import org.apache.commons.configuration.FileConfiguration; | 52 | import org.apache.commons.configuration.FileConfiguration; |
| 54 | import org.apache.commons.configuration.PropertiesConfiguration; | 53 | import org.apache.commons.configuration.PropertiesConfiguration; |
| 55 | import org.apache.commons.configuration.SystemConfiguration; | 54 | import org.apache.commons.configuration.SystemConfiguration; |
| @@ -84,7 +83,7 @@ public class ConfigurationLoader implements Serializable { | @@ -84,7 +83,7 @@ public class ConfigurationLoader implements Serializable { | ||
| 84 | 83 | ||
| 85 | private String prefix; | 84 | private String prefix; |
| 86 | 85 | ||
| 87 | - private DataConfiguration configuration; | 86 | + private org.apache.commons.configuration.Configuration configuration; |
| 88 | 87 | ||
| 89 | private Set<Field> fields; | 88 | private Set<Field> fields; |
| 90 | 89 | ||
| @@ -163,7 +162,7 @@ public class ConfigurationLoader implements Serializable { | @@ -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 | private void loadExtractors() { | 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,7 +45,7 @@ import java.util.Map; | ||
| 45 | import java.util.regex.Matcher; | 45 | import java.util.regex.Matcher; |
| 46 | import java.util.regex.Pattern; | 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 | import br.gov.frameworkdemoiselle.annotation.Priority; | 50 | import br.gov.frameworkdemoiselle.annotation.Priority; |
| 51 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; | 51 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; |
| @@ -54,7 +54,7 @@ import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; | @@ -54,7 +54,7 @@ import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; | ||
| 54 | public class ConfigurationMapValueExtractor implements ConfigurationValueExtractor { | 54 | public class ConfigurationMapValueExtractor implements ConfigurationValueExtractor { |
| 55 | 55 | ||
| 56 | @Override | 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 | @SuppressWarnings("unchecked") | 58 | @SuppressWarnings("unchecked") |
| 59 | Map<String, Object> value = (Map<String, Object>) defaultValue; | 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,6 +42,7 @@ import java.lang.reflect.Field; | ||
| 42 | import java.util.HashSet; | 42 | import java.util.HashSet; |
| 43 | import java.util.Set; | 43 | import java.util.Set; |
| 44 | 44 | ||
| 45 | +import org.apache.commons.configuration.Configuration; | ||
| 45 | import org.apache.commons.configuration.ConversionException; | 46 | import org.apache.commons.configuration.ConversionException; |
| 46 | import org.apache.commons.configuration.DataConfiguration; | 47 | import org.apache.commons.configuration.DataConfiguration; |
| 47 | import org.apache.commons.lang.ClassUtils; | 48 | import org.apache.commons.lang.ClassUtils; |
| @@ -68,11 +69,11 @@ public class ConfigurationPrimitiveOrWrapperValueExtractor implements Configurat | @@ -68,11 +69,11 @@ public class ConfigurationPrimitiveOrWrapperValueExtractor implements Configurat | ||
| 68 | 69 | ||
| 69 | @Override | 70 | @Override |
| 70 | @SuppressWarnings("unchecked") | 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 | Object value; | 73 | Object value; |
| 73 | 74 | ||
| 74 | try { | 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 | } catch (ConversionException cause) { | 78 | } catch (ConversionException cause) { |
| 78 | value = defaultValue; | 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,7 +40,7 @@ import static br.gov.frameworkdemoiselle.internal.implementation.StrategySelecto | ||
| 40 | 40 | ||
| 41 | import java.lang.reflect.Field; | 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 | import br.gov.frameworkdemoiselle.annotation.Priority; | 45 | import br.gov.frameworkdemoiselle.annotation.Priority; |
| 46 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; | 46 | import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; |
| @@ -49,7 +49,7 @@ import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; | @@ -49,7 +49,7 @@ import br.gov.frameworkdemoiselle.configuration.ConfigurationValueExtractor; | ||
| 49 | public class ConfigurationStringValueExtractor implements ConfigurationValueExtractor { | 49 | public class ConfigurationStringValueExtractor implements ConfigurationValueExtractor { |
| 50 | 50 | ||
| 51 | @Override | 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 | return configuration.getString(prefix + key, (String) defaultValue); | 53 | return configuration.getString(prefix + key, (String) defaultValue); |
| 54 | } | 54 | } |
| 55 | 55 |