Commit 07a2d312174faa12d832b739fe1ebd36bba203d8
1 parent
e386cfd7
Exists in
master
Suporte a herança em classes anotadas com @Configuration
Showing
2 changed files
with
13 additions
and
18 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoader.java
| @@ -63,10 +63,8 @@ import br.gov.frameworkdemoiselle.annotation.Name; | @@ -63,10 +63,8 @@ import br.gov.frameworkdemoiselle.annotation.Name; | ||
| 63 | import br.gov.frameworkdemoiselle.configuration.ConfigType; | 63 | import br.gov.frameworkdemoiselle.configuration.ConfigType; |
| 64 | import br.gov.frameworkdemoiselle.configuration.Configuration; | 64 | import br.gov.frameworkdemoiselle.configuration.Configuration; |
| 65 | import br.gov.frameworkdemoiselle.configuration.ConfigurationException; | 65 | import br.gov.frameworkdemoiselle.configuration.ConfigurationException; |
| 66 | -import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap; | ||
| 67 | import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | 66 | import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; |
| 68 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | 67 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; |
| 69 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
| 70 | import br.gov.frameworkdemoiselle.util.Reflections; | 68 | import br.gov.frameworkdemoiselle.util.Reflections; |
| 71 | import br.gov.frameworkdemoiselle.util.ResourceBundle; | 69 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
| 72 | import br.gov.frameworkdemoiselle.util.Strings; | 70 | import br.gov.frameworkdemoiselle.util.Strings; |
| @@ -85,8 +83,6 @@ public class ConfigurationLoader implements Serializable { | @@ -85,8 +83,6 @@ public class ConfigurationLoader implements Serializable { | ||
| 85 | 83 | ||
| 86 | private Logger logger; | 84 | private Logger logger; |
| 87 | 85 | ||
| 88 | - private CoreBootstrap bootstrap; | ||
| 89 | - | ||
| 90 | /** | 86 | /** |
| 91 | * Loads a config class filling it with the corresponding values. | 87 | * Loads a config class filling it with the corresponding values. |
| 92 | * | 88 | * |
| @@ -97,14 +93,9 @@ public class ConfigurationLoader implements Serializable { | @@ -97,14 +93,9 @@ public class ConfigurationLoader implements Serializable { | ||
| 97 | public void load(Object object) throws ConfigurationException { | 93 | public void load(Object object) throws ConfigurationException { |
| 98 | Class<?> config = object.getClass(); | 94 | Class<?> config = object.getClass(); |
| 99 | 95 | ||
| 100 | - if (!getBootstrap().isAnnotatedType(config)) { | ||
| 101 | - config = config.getSuperclass(); | ||
| 102 | - getLogger().debug(getBundle().getString("proxy-detected", config, config.getClass().getSuperclass())); | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | getLogger().debug(getBundle().getString("loading-configuration-class", config.getName())); | 96 | getLogger().debug(getBundle().getString("loading-configuration-class", config.getName())); |
| 106 | 97 | ||
| 107 | - for (Field field : Reflections.getNonStaticDeclaredFields(config)) { | 98 | + for (Field field : Reflections.getNonStaticFields(config)) { |
| 108 | loadField(field, object, config); | 99 | loadField(field, object, config); |
| 109 | } | 100 | } |
| 110 | } | 101 | } |
| @@ -414,14 +405,6 @@ public class ConfigurationLoader implements Serializable { | @@ -414,14 +405,6 @@ public class ConfigurationLoader implements Serializable { | ||
| 414 | return logger; | 405 | return logger; |
| 415 | } | 406 | } |
| 416 | 407 | ||
| 417 | - private CoreBootstrap getBootstrap() { | ||
| 418 | - if (bootstrap == null) { | ||
| 419 | - bootstrap = Beans.getReference(CoreBootstrap.class); | ||
| 420 | - } | ||
| 421 | - | ||
| 422 | - return bootstrap; | ||
| 423 | - } | ||
| 424 | - | ||
| 425 | private class Key { | 408 | private class Key { |
| 426 | 409 | ||
| 427 | private String prefix; | 410 | private String prefix; |
impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Reflections.java
| @@ -43,6 +43,7 @@ import java.lang.reflect.Modifier; | @@ -43,6 +43,7 @@ import java.lang.reflect.Modifier; | ||
| 43 | import java.lang.reflect.ParameterizedType; | 43 | import java.lang.reflect.ParameterizedType; |
| 44 | import java.lang.reflect.Type; | 44 | import java.lang.reflect.Type; |
| 45 | import java.util.ArrayList; | 45 | import java.util.ArrayList; |
| 46 | +import java.util.Arrays; | ||
| 46 | import java.util.List; | 47 | import java.util.List; |
| 47 | 48 | ||
| 48 | public final class Reflections { | 49 | public final class Reflections { |
| @@ -131,6 +132,17 @@ public final class Reflections { | @@ -131,6 +132,17 @@ public final class Reflections { | ||
| 131 | return fields.toArray(new Field[0]); | 132 | return fields.toArray(new Field[0]); |
| 132 | } | 133 | } |
| 133 | 134 | ||
| 135 | + public static List<Field> getNonStaticFields(Class<?> type) { | ||
| 136 | + List<Field> fields = new ArrayList<Field>(); | ||
| 137 | + | ||
| 138 | + if (type != null) { | ||
| 139 | + fields.addAll(Arrays.asList(getNonStaticDeclaredFields(type))); | ||
| 140 | + fields.addAll(getNonStaticFields(type.getSuperclass())); | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + return fields; | ||
| 144 | + } | ||
| 145 | + | ||
| 134 | public static <T> T instantiate(Class<T> clasz) { | 146 | public static <T> T instantiate(Class<T> clasz) { |
| 135 | T object = null; | 147 | T object = null; |
| 136 | try { | 148 | try { |