cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r810927 - 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 Thu, 03 Sep 2009 13:11:06 GMT
Author: ningjiang
Date: Thu Sep  3 13:11:05 2009
New Revision: 810927

URL: http://svn.apache.org/viewvc?rev=810927&view=rev
Log:
CXF-2421 fixed the UnsupportOperationException issue in ConfigureImpl

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=810927&r1=810926&r2=810927&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
Thu Sep  3 13:11:05 2009
@@ -225,16 +225,19 @@
     public final void addApplicationContext(ApplicationContext ac) {
         if (!appContexts.contains(ac)) {
             appContexts.add(ac);
-            
+            List<ApplicationContext> inactiveApplicationContexts = new ArrayList<ApplicationContext>();
             Iterator<ApplicationContext> it = appContexts.iterator();
             while (it.hasNext()) {
                 ApplicationContext c = it.next();
                 if (c instanceof ConfigurableApplicationContext
                     && !((ConfigurableApplicationContext)c).isActive()) {
-                    it.remove();
+                    inactiveApplicationContexts.add(c);
                 }
             }
-            
+            // Remove the inactive application context here can avoid the UnsupportedOperationException
+            for (ApplicationContext context : inactiveApplicationContexts) {
+                appContexts.remove(context);
+            }
             initWildcardDefinitionMap();
         }
     }
@@ -247,4 +250,8 @@
     public Class<?> getRegistrationType() {
         return Configurer.class;
     }
+    
+    protected Set<ApplicationContext> getAppContexts() {
+        return appContexts;
+    }
 }

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=810927&r1=810926&r2=810927&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
Thu Sep  3 13:11:05 2009
@@ -21,6 +21,7 @@
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.util.Set;
 
 import javax.xml.bind.DatatypeConverter;
 import javax.xml.bind.DatatypeConverterInterface;
@@ -31,6 +32,11 @@
 import org.apache.cxf.configuration.Configurable;
 import org.junit.Assert;
 import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+
 
 
 
@@ -213,6 +219,23 @@
         assertNull(configurer.getBeanName(beanInstance));
     }
     
+    @Test
+    public void testAddApplicationContext() {
+        ConfigurableApplicationContext context1 =
+            new ClassPathXmlApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml");
+        ConfigurerImpl configurer = new ConfigurerImpl();
+        configurer.setApplicationContext(context1);
+        // Just to simulate the OSGi's uninstall command
+        context1.close();
+        
+        ConfigurableApplicationContext context2 =
+            new ClassPathXmlApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml");
+        configurer.addApplicationContext(context2);
+        Set<ApplicationContext> contexts = configurer.getAppContexts();
+        assertEquals("The Context's size is wrong", 1, contexts.size());
+        assertTrue("The conetxts' contains a wrong application context", contexts.contains(context2));
+    }
+    
     final class SimpleBean implements Configurable {
         
         private String beanName;



Mime
View raw message