tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [01/11] incubator-tamaya-extensions git commit: TAMAYA-197: Fixed bug not injecting properties in superclasses.
Date Sun, 26 Feb 2017 23:05:14 GMT
Repository: incubator-tamaya-extensions
Updated Branches:
  refs/heads/master 946584592 -> abb34d651


TAMAYA-197: Fixed bug not injecting properties in superclasses.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/abb34d65
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/abb34d65
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/abb34d65

Branch: refs/heads/master
Commit: abb34d65181d9be614cbba258dd0ee174a7f3b7d
Parents: d763fa0
Author: anatole <anatole@apache.org>
Authored: Mon Feb 27 00:00:30 2017 +0100
Committer: anatole <anatole@apache.org>
Committed: Mon Feb 27 00:05:00 2017 +0100

----------------------------------------------------------------------
 .../inject/internal/ConfiguredTypeImpl.java     |  9 ++++++
 .../annottext/InheritedAnnotatedConfigBean.java | 29 ++++++++++++++++++++
 .../tamaya/inject/TamayaInjectionTest.java      | 24 ++++++++++++++++
 .../tamaya/inject/TestPropertySource.java       |  1 +
 modules/pom.xml                                 |  2 ++
 5 files changed, 65 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/abb34d65/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/ConfiguredTypeImpl.java
----------------------------------------------------------------------
diff --git a/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/ConfiguredTypeImpl.java
b/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/ConfiguredTypeImpl.java
index b40f6c9..c438348 100644
--- a/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/ConfiguredTypeImpl.java
+++ b/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/ConfiguredTypeImpl.java
@@ -81,6 +81,9 @@ public class ConfiguredTypeImpl implements ConfiguredType{
     }
 
     private void initFields(Class type, boolean autoConfigure) {
+        if (type.getSuperclass() != null) {
+            initFields(type.getSuperclass(), autoConfigure);
+        }
         for (Field f : type.getDeclaredFields()) {
             if (f.isAnnotationPresent(NoConfig.class)) {
                 LOG.finest("Ignored @NoConfig annotated field " + f.getClass().getName()
+ "#" +
@@ -112,6 +115,9 @@ public class ConfiguredTypeImpl implements ConfiguredType{
     }
 
     private void initMethods(Class type, boolean autoConfigure) {
+        if (type.getSuperclass() != null) {
+            initMethods(type.getSuperclass(), autoConfigure);
+        }
         // TODO revisit this logic here...
         for (Method m : type.getDeclaredMethods()) {
             if (m.isAnnotationPresent(NoConfig.class)) {
@@ -191,6 +197,9 @@ public class ConfiguredTypeImpl implements ConfiguredType{
                 return true;
             }
         }
+        if (type.getSuperclass() != null) {
+            return isConfigured(type.getSuperclass());
+        }
         return false;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/abb34d65/modules/injection/standalone/src/test/java/annottext/InheritedAnnotatedConfigBean.java
----------------------------------------------------------------------
diff --git a/modules/injection/standalone/src/test/java/annottext/InheritedAnnotatedConfigBean.java
b/modules/injection/standalone/src/test/java/annottext/InheritedAnnotatedConfigBean.java
new file mode 100644
index 0000000..9952b18
--- /dev/null
+++ b/modules/injection/standalone/src/test/java/annottext/InheritedAnnotatedConfigBean.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package annottext;
+
+import org.apache.tamaya.inject.api.Config;
+
+public class InheritedAnnotatedConfigBean extends AnnotatedConfigBean {
+
+    @Config("someMoreValue")
+    public String someMoreValue;
+    
+    public String notConfigured;
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/abb34d65/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java
----------------------------------------------------------------------
diff --git a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java
b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java
index d5a26c1..b95d491 100644
--- a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java
+++ b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java
@@ -20,6 +20,7 @@ package org.apache.tamaya.inject;
 
 import annottext.AnnotatedConfigBean;
 import annottext.AnnotatedConfigTemplate;
+import annottext.InheritedAnnotatedConfigBean;
 import annottext.NonAnnotatedConfigBean;
 import org.junit.Test;
 
@@ -68,6 +69,29 @@ public class TamayaInjectionTest {
         assertEquals(testInstance.getHostName(), testInstance.getDynamicValue().get());
         assertEquals(testInstance.javaVersion, System.getProperty("java.version"));
     }
+    
+    @Test
+    public void testInjectionInheritedClass(){
+        assertNotNull(ConfigurationInjection.getConfigurationInjector());
+        InheritedAnnotatedConfigBean testInstance = new InheritedAnnotatedConfigBean();
+        assertEquals(testInstance.getHostName(), null);
+        assertEquals(testInstance.getAnotherValue(), null);
+        assertEquals(testInstance.myParameter, null);
+        assertEquals(testInstance.simpleValue, null);
+        assertEquals(testInstance.someMoreValue, null);
+        assertEquals(testInstance.notConfigured, null);
+        ConfigurationInjection.getConfigurationInjector().configure(testInstance);
+        assertEquals(testInstance.getHostName(), "tamaya01.incubator.apache.org");
+        assertEquals(testInstance.getAnotherValue(), "HALLO!");
+        assertEquals(testInstance.myParameter, "ET");
+        assertEquals(testInstance.simpleValue, "aSimpleValue");
+        assertNotNull(testInstance.getDynamicValue());
+        assertTrue(testInstance.getDynamicValue().isPresent());
+        assertEquals(testInstance.getDynamicValue().get(), "tamaya01.incubator.apache.org");
+        assertEquals(testInstance.getHostName(), testInstance.getDynamicValue().get());
+        assertEquals(testInstance.javaVersion, System.getProperty("java.version"));
+        assertEquals(testInstance.someMoreValue, "s'more");
+    }    
 
     @Test
     public void testConfigTemplate(){

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/abb34d65/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java
b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java
index 321f7f4..4af2f33 100644
--- a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java
+++ b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java
@@ -39,6 +39,7 @@ public class TestPropertySource implements PropertySource {
         properties.put("NonAnnotatedConfigBean.classFieldKey", "Class-Field-Value");
         properties.put("NonAnnotatedConfigBean.fieldKey", "Field-Value");
         properties.put("annottext.NonAnnotatedConfigBean.fullKey", "Fullkey-Value");
+        properties.put("someMoreValue", "s'more");
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/abb34d65/modules/pom.xml
----------------------------------------------------------------------
diff --git a/modules/pom.xml b/modules/pom.xml
index c8be869..621ef44 100644
--- a/modules/pom.xml
+++ b/modules/pom.xml
@@ -32,6 +32,7 @@ under the License.
     <packaging>pom</packaging>
 
     <modules>
+        <module>features</module>
         <module>functions</module>
         <module>spi-support</module>
         <module>optional</module>
@@ -43,6 +44,7 @@ under the License.
         <module>resolver</module>
         <module>resources</module>
         <module>spring</module>
+        <module>jndi</module>
     </modules>
 
 </project>


Mime
View raw message