cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r467854 - in /incubator/cxf/trunk/rt/core/src: main/java/org/apache/cxf/bus/spring/SpringBusImpl.java test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
Date Thu, 26 Oct 2006 03:50:00 GMT
Author: ningjiang
Date: Wed Oct 25 20:49:59 2006
New Revision: 467854

URL: http://svn.apache.org/viewvc?view=rev&rev=467854
Log:
CXF-152 call the lifecycleManager.preShutdown() and postShutdown() in springBus.shutdown()

Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusImpl.java
    incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusImpl.java?view=diff&rev=467854&r1=467853&r2=467854
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusImpl.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusImpl.java
Wed Oct 25 20:49:59 2006
@@ -24,18 +24,23 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.BusState;
+import org.apache.cxf.buslifecycle.BusLifeCycleManager;
 import org.apache.cxf.interceptor.AbstractBasicInterceptorProvider;
 
 public class SpringBusImpl extends AbstractBasicInterceptorProvider implements Bus {
     
     private Map<Class, Object> extensions;
-    
+    private BusLifeCycleManager lifeCycleManager;
     private String id;
     private BusState state;      
     
     public SpringBusImpl() {
         extensions = new HashMap<Class, Object>();
         state = BusState.INITIAL;
+        lifeCycleManager = this.getExtension(BusLifeCycleManager.class);
+        if (null != lifeCycleManager) {
+            lifeCycleManager.initComplete();
+        }
     }
     
     public void setExtensions(Map<Class, Object> e) {
@@ -82,7 +87,17 @@
     }
 
     public void shutdown(boolean wait) {
-        // TODO
+        lifeCycleManager = this.getExtension(BusLifeCycleManager.class);
+        if (null != lifeCycleManager) {
+            lifeCycleManager.preShutdown();
+        }
+        synchronized (this) {
+            state = BusState.SHUTDOWN;
+            notifyAll();
+        }
+        if (null != lifeCycleManager) {
+            lifeCycleManager.postShutdown();
+        }
     }
     
     protected BusState getState() {

Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java?view=diff&rev=467854&r1=467853&r2=467854
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
(original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
Wed Oct 25 20:49:59 2006
@@ -26,6 +26,7 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
 import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.buslifecycle.BusLifeCycleListener;
 import org.apache.cxf.buslifecycle.BusLifeCycleManager;
 import org.apache.cxf.configuration.Configurer;
 import org.apache.cxf.endpoint.ServerRegistry;
@@ -38,6 +39,7 @@
 import org.apache.cxf.transport.DestinationFactoryManager;
 import org.apache.cxf.workqueue.WorkQueueManager;
 import org.apache.cxf.wsdl.WSDLManager;
+import org.easymock.EasyMock;
 
 public class SpringBusFactoryTest extends TestCase {
 
@@ -87,6 +89,22 @@
         interceptors = bus.getOutInterceptors();
         assertEquals("Unexpected number of interceptors", 1, interceptors.size());
         assertEquals("Unexpected interceptor", "out", interceptors.get(0).toString());
+        
+    }
+    
+    public void testForLifeCycle() {
+        BusLifeCycleListener bl = EasyMock.createMock(BusLifeCycleListener.class);
+        Bus bus = new SpringBusFactory().createBus();
+        BusLifeCycleManager lifeCycleManager = bus.getExtension(BusLifeCycleManager.class);
+        lifeCycleManager.registerLifeCycleListener(bl);
+        
+        bl.preShutdown();
+        EasyMock.expectLastCall();
+        bl.postShutdown();
+        EasyMock.expectLastCall();
+        EasyMock.replay(bl);
+        bus.shutdown(true);
+        EasyMock.verify(bl);
         
     }
     



Mime
View raw message