cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r986308 - in /cxf/trunk/rt/core/src: main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java
Date Tue, 17 Aug 2010 13:52:27 GMT
Author: ningjiang
Date: Tue Aug 17 13:52:27 2010
New Revision: 986308

URL: http://svn.apache.org/viewvc?rev=986308&view=rev
Log:
CXF-2948 Let the configure context can be used for extended instance

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
    cxf/trunk/rt/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java?rev=986308&r1=986307&r2=986308&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
Tue Aug 17 13:52:27 2010
@@ -164,18 +164,22 @@ public class ConfigurerImpl extends Bean
     
     private void configureWithWildCard(String bn, Object beanInstance) {
         if (!wildCardBeanDefinitions.isEmpty()) {
-            String className = beanInstance.getClass().getName();
-            List<MatcherHolder> matchers = wildCardBeanDefinitions.get(className);
-            if (matchers != null) {
-                for (MatcherHolder m : matchers) {
-                    synchronized (m.matcher) {
-                        m.matcher.reset(bn);
-                        if (m.matcher.matches()) {
-                            configureBean(m.wildCardId, beanInstance, false);
-                            return;
+            Class<?> clazz = beanInstance.getClass();            
+            while (!Object.class.equals(clazz)) {
+                String className = clazz.getName();
+                List<MatcherHolder> matchers = wildCardBeanDefinitions.get(className);
+                if (matchers != null) {
+                    for (MatcherHolder m : matchers) {
+                        synchronized (m.matcher) {
+                            m.matcher.reset(bn);
+                            if (m.matcher.matches()) {
+                                configureBean(m.wildCardId, beanInstance, false);
+                                return;
+                            }
                         }
                     }
                 }
+                clazz = clazz.getSuperclass();
             }
         }
     }

Modified: cxf/trunk/rt/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java?rev=986308&r1=986307&r2=986308&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java
(original)
+++ cxf/trunk/rt/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java
Tue Aug 17 13:52:27 2010
@@ -198,6 +198,24 @@ public class ConfigurerImplTest extends 
     }
     
     @Test
+    public void testConfigureSimpleMatchingStarBeanIdWithChildInstance() {
+        SimpleBean sb = new ChildBean("simple2");
+        BusApplicationContext ac = 
+            new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml",
+                                      false);
+
+        ConfigurerImpl configurer = new ConfigurerImpl();
+        configurer.setApplicationContext(ac);
+        configurer.configureBean(sb);
+        assertTrue("Unexpected value for attribute booleanAttr", 
+                   !sb.getBooleanAttr());
+        assertEquals("Unexpected value for attribute integerAttr", 
+                     BigInteger.TEN, sb.getIntegerAttr());
+        assertEquals("Unexpected value for attribute stringAttr", 
+                     "StarHallo", sb.getStringAttr());
+    }
+    
+    @Test
     public void testGetBeanName() {
         ConfigurerImpl configurer = new ConfigurerImpl();
         Object beanInstance = new Configurable() {
@@ -236,7 +254,7 @@ public class ConfigurerImplTest extends 
         assertTrue("The conetxts' contains a wrong application context", contexts.contains(context2));
     }
     
-    final class SimpleBean implements Configurable {
+    class SimpleBean implements Configurable {
         
         private String beanName;
         
@@ -398,4 +416,12 @@ public class ConfigurerImplTest extends 
             this.beanName = beanName;
         }    
     }
+    
+    class ChildBean extends SimpleBean {
+
+        public ChildBean(String bn) {
+            super(bn);
+        }
+        
+    }
 }



Mime
View raw message