cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r582873 - in /incubator/cxf/branches/2.0.x-fixes: ./ rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
Date Mon, 08 Oct 2007 16:42:41 GMT
Author: dkulp
Date: Mon Oct  8 09:42:40 2007
New Revision: 582873

URL: http://svn.apache.org/viewvc?rev=582873&view=rev
Log:
Merged revisions 577477 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r577477 | ningjiang | 2007-09-19 19:59:24 -0400 (Wed, 19 Sep 2007) | 1 line
  
  CXF-1034 shutdown the JettyEngine when bus shutdown is called
........

Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Oct  8 09:42:40 2007
@@ -1 +1 @@
-/incubator/cxf/trunk:1-573657,573659-573660,573662-574161,574163-574834,574836-575221,575223-575253,575255-576654,576656-576672,576674-576710,576712-576775,576777-576788,576790-576791,576793-576831,576833-577091
+/incubator/cxf/trunk:1-573657,573659-573660,573662-574161,574163-574834,574836-575221,575223-575253,575255-576654,576656-576672,576674-576710,576712-576775,576777-576788,576790-576791,576793-576831,576833-577091,577477

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java?rev=582873&r1=582872&r2=582873&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
Mon Oct  8 09:42:40 2007
@@ -30,6 +30,8 @@
 import javax.annotation.Resource;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.buslifecycle.BusLifeCycleListener;
+import org.apache.cxf.buslifecycle.BusLifeCycleManager;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.configuration.jsse.TLSServerParameters;
 
@@ -42,31 +44,19 @@
  * caches the JettyHTTPServerEngines so that they may be 
  * retrieved if already previously configured.
  */
-public class JettyHTTPServerEngineFactory {
+public class JettyHTTPServerEngineFactory implements BusLifeCycleListener {
     private static final Logger LOG =
         LogUtils.getL7dLogger(JettyHTTPServerEngineFactory.class);    
     
     /**
      * This map holds references for allocated ports.
      */
-    // All system tests do not shut down bus correctly,
-    // or the bus does not shutdown all endpoints correctly,
-    // so that these server endings are actuall shared amongst busses
-    // within the same JVM.
-    
-    // We will keep it static until we can resolve the problems 
-    // in the System tests.
-    // TODO: Fix the System Tests so that they shutdown the 
-    // buses that they are using and that the buses actually
-    // shutdown the destinations and their server engines
-    // properly. This will require a bit of lifecyle and reference
-    // counting on Destinations to server engines, if they are 
-    // going to be shared, but they should by no means be 
-    // shared accross buses, right?
+    // Still use the static map to hold the port information
+    // in the same JVM
     private static Map<Integer, JettyHTTPServerEngine> portMap =
         new HashMap<Integer, JettyHTTPServerEngine>();
    
-    
+    private BusLifeCycleManager lifeCycleManager;
     /**
      * This map holds the threading parameters that are to be applied
      * to new Engines when bound to the reference id.
@@ -89,7 +79,8 @@
     
     public JettyHTTPServerEngineFactory() {
         // Empty
-    }
+    }    
+    
     
     /**
      * This call is used to set the bus. It should only be called once.
@@ -104,7 +95,13 @@
     
     @PostConstruct
     public void registerWithBus() {
-        bus.setExtension(this, JettyHTTPServerEngineFactory.class);
+        if (bus != null) {
+            bus.setExtension(this, JettyHTTPServerEngineFactory.class);
+        }
+        lifeCycleManager = bus.getExtension(BusLifeCycleManager.class);
+        if (null != lifeCycleManager) {
+            lifeCycleManager.registerLifeCycleListener(this);
+        }        
     }
     
     
@@ -200,6 +197,29 @@
     @PostConstruct
     public void finalizeConfig() {
         registerWithBus();
+    }
+
+    public void initComplete() {
+        // do nothing here
+        
+    }
+
+    public void postShutdown() {
+        // clean up the collections       
+        portMap.clear();
+        threadingParametersMap.clear();
+        tlsParametersMap.clear();
+    }
+
+    public void preShutdown() {
+        // shut down the jetty server in the portMap
+        // To avoid the CurrentModificationException, 
+        // do not use portMap.vaules directly
+       
+        JettyHTTPServerEngine[] engines = portMap.values().toArray(new JettyHTTPServerEngine[0]);
+        for (JettyHTTPServerEngine engine : engines) {
+            engine.shutdown();
+        }
     }
     
 }



Mime
View raw message