Commit 07a2d312174faa12d832b739fe1ebd36bba203d8

Authored by Cleverson Sacramento
1 parent e386cfd7
Exists in master

Suporte a herança em classes anotadas com @Configuration

impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoader.java
... ... @@ -63,10 +63,8 @@ import br.gov.frameworkdemoiselle.annotation.Name;
63 63 import br.gov.frameworkdemoiselle.configuration.ConfigType;
64 64 import br.gov.frameworkdemoiselle.configuration.Configuration;
65 65 import br.gov.frameworkdemoiselle.configuration.ConfigurationException;
66   -import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap;
67 66 import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer;
68 67 import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;
69   -import br.gov.frameworkdemoiselle.util.Beans;
70 68 import br.gov.frameworkdemoiselle.util.Reflections;
71 69 import br.gov.frameworkdemoiselle.util.ResourceBundle;
72 70 import br.gov.frameworkdemoiselle.util.Strings;
... ... @@ -85,8 +83,6 @@ public class ConfigurationLoader implements Serializable {
85 83  
86 84 private Logger logger;
87 85  
88   - private CoreBootstrap bootstrap;
89   -
90 86 /**
91 87 * Loads a config class filling it with the corresponding values.
92 88 *
... ... @@ -97,14 +93,9 @@ public class ConfigurationLoader implements Serializable {
97 93 public void load(Object object) throws ConfigurationException {
98 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 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 99 loadField(field, object, config);
109 100 }
110 101 }
... ... @@ -414,14 +405,6 @@ public class ConfigurationLoader implements Serializable {
414 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 408 private class Key {
426 409  
427 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 43 import java.lang.reflect.ParameterizedType;
44 44 import java.lang.reflect.Type;
45 45 import java.util.ArrayList;
  46 +import java.util.Arrays;
46 47 import java.util.List;
47 48  
48 49 public final class Reflections {
... ... @@ -131,6 +132,17 @@ public final class Reflections {
131 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 146 public static <T> T instantiate(Class<T> clasz) {
135 147 T object = null;
136 148 try {
... ...