cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1181841 - in /cxf/trunk/rt/transports/http-jetty/src: main/java/org/apache/cxf/transport/http_jetty/ main/java/org/apache/cxf/transport/http_jetty/spring/ test/java/org/apache/cxf/transport/http_jetty/
Date Tue, 11 Oct 2011 15:30:01 GMT
Author: dkulp
Date: Tue Oct 11 15:30:01 2011
New Revision: 1181841

URL: http://svn.apache.org/viewvc?rev=1181841&view=rev
Log:
Start some work to decouple the JettyHTTPServerEngine from the Bus level
factories to allow them to be configured outside a specific Bus (like
maybe from OSGi)

Modified:
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
    cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java?rev=1181841&r1=1181840&r2=1181841&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
Tue Oct 11 15:30:01 2011
@@ -27,10 +27,8 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
 import javax.servlet.ServletContext;
 
-import org.apache.cxf.Bus;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.SystemPropertyAction;
@@ -71,13 +69,6 @@ public class JettyHTTPServerEngine
         LogUtils.getL7dLogger(JettyHTTPServerEngine.class);
    
     /**
-     * This is the Jetty HTTP Server Engine Factory. This factory caches some 
-     * engines based on port numbers.
-     */
-    protected JettyHTTPServerEngineFactory factory;
-    
-    
-    /**
      * This is the network port for which this engine is allocated.
      */
     private int port;
@@ -103,7 +94,7 @@ public class JettyHTTPServerEngine
     private List<Handler> handlers;
     private JettyConnectorFactory connectorFactory;
     private ContextHandlerCollection contexts;
-    
+    private Container.Listener mBeanContainer;
     private SessionManager sessionManager;
     
     /**
@@ -128,22 +119,18 @@ public class JettyHTTPServerEngine
      * This constructor is called by the JettyHTTPServerEngineFactory.
      */
     public JettyHTTPServerEngine(
-        JettyHTTPServerEngineFactory fac, 
+        Container.Listener mBeanContainer,
         String host,
         int port) {
-        this.factory = fac;
         this.host    = host;
         this.port    = port;
+        this.mBeanContainer = mBeanContainer;
     }
     
     public JettyHTTPServerEngine() {
         
     }
      
-    public void setJettyHTTPServerEngineFactory(JettyHTTPServerEngineFactory fac) {
-        factory = fac;
-    }
-    
     public void setPort(int p) {
         port = p;
     }
@@ -161,16 +148,6 @@ public class JettyHTTPServerEngine
     }
     
     /**
-     * The bus.
-     */
-    @Resource(name = "cxf")
-    public void setBus(Bus bus) {
-        if (null != bus && null == factory) {
-            factory = bus.getExtension(JettyHTTPServerEngineFactory.class);
-        }        
-    }
-    
-    /**
      * Returns the protocol "http" or "https" for which this engine
      * was configured.
      */
@@ -200,8 +177,8 @@ public class JettyHTTPServerEngine
      */
     public void shutdown() {
         if (shouldDestroyPort()) {
-            if (factory != null && servantCount == 0) {
-                factory.destroyForPort(port);
+            if (servantCount == 0) {
+                JettyHTTPServerEngineFactory.destroyForPort(port);
             } else {
                 LOG.log(Level.WARNING, "FAILED_TO_SHUTDOWN_ENGINE_MSG", port);
             }
@@ -306,7 +283,6 @@ public class JettyHTTPServerEngine
             // create a new jetty server instance if there is no server there           

             server = new Server();
             
-            Container.Listener mBeanContainer = factory.getMBeanContainer();
             if (mBeanContainer != null) {
                 server.getContainer().addEventListener(mBeanContainer);
             }

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java?rev=1181841&r1=1181840&r2=1181841&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
Tue Oct 11 15:30:01 2011
@@ -111,7 +111,7 @@ public class JettyHTTPServerEngineFactor
         
         JettyHTTPServerEngine ref = portMap.get(port);
         if (ref == null) {
-            ref = new JettyHTTPServerEngine(factory, host, port);
+            ref = new JettyHTTPServerEngine(factory.getMBeanContainer(), host, port);
             if (tlsParams != null) {
                 ref.setTlsServerParameters(tlsParams);
             }
@@ -282,7 +282,7 @@ public class JettyHTTPServerEngineFactor
     /**
      * This method removes the Server Engine from the port map and stops it.
      */
-    public synchronized void destroyForPort(int port) {
+    public static synchronized void destroyForPort(int port) {
         JettyHTTPServerEngine ref = portMap.remove(port);
         if (ref != null) {
             LOG.fine("Stopping Jetty HTTP Server Engine on port " + port + ".");

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java?rev=1181841&r1=1181840&r2=1181841&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
Tue Oct 11 15:30:01 2011
@@ -170,24 +170,32 @@ public class JettyHTTPServerEngineBeanDe
         String threadingRef;
         String tlsRef;
         Bus bus;
+        JettyHTTPServerEngineFactory factory;
         
         public SpringJettyHTTPServerEngine(
             JettyHTTPServerEngineFactory fac,
             Bus b,
             String host,
             int port) {
-            super(fac, host, port);
+            super(fac.getMBeanContainer(), host, port);
             bus = b;
+            factory = fac;
         }
         
         public SpringJettyHTTPServerEngine() {
             super();
         }
         
+        public void setBus(Bus b) {
+            bus = b;
+            if (null != bus && null == factory) {
+                factory = bus.getExtension(JettyHTTPServerEngineFactory.class);
+            } 
+        }
         
         public void setApplicationContext(ApplicationContext ctx) throws BeansException {
             if (bus == null) {
-                setBus(BusWiringBeanFactoryPostProcessor.addDefaultBus(ctx));
+                bus = BusWiringBeanFactoryPostProcessor.addDefaultBus(ctx);
             }
         }
         
@@ -203,9 +211,7 @@ public class JettyHTTPServerEngineBeanDe
             throws GeneralSecurityException,
                    IOException {
             if (tlsRef != null || threadingRef != null) {
-                if (bus != null) {
-                    setBus(bus);
-                }
+
                 if (threadingRef != null) {
                     setThreadingParameters(factory.getThreadingParametersMap().get(threadingRef));
                 }

Modified: cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java?rev=1181841&r1=1181840&r2=1181841&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
Tue Oct 11 15:30:01 2011
@@ -91,7 +91,7 @@ public class JettyHTTPServerEngineTest e
             "Engine references for the same port should point to the same instance",
             engine == factory.retrieveJettyHTTPServerEngine(9234));
 
-        factory.destroyForPort(1234);
+        JettyHTTPServerEngineFactory.destroyForPort(1234);
     }
 
     @Test
@@ -103,7 +103,6 @@ public class JettyHTTPServerEngineTest e
                 "http".equals(engine.getProtocol()));
 
         engine = new JettyHTTPServerEngine();
-        engine.setJettyHTTPServerEngineFactory(factory);
         engine.setPort(9235);
         engine.setMaxIdleTime(30000);
         engine.setTlsServerParameters(new TLSServerParameters());
@@ -130,9 +129,9 @@ public class JettyHTTPServerEngineTest e
         assertTrue("Protocol must be https",
                    "https".equals(engine.getProtocol()));
 
-        factory.destroyForPort(9234);
-        factory.destroyForPort(9235);
-        factory.destroyForPort(9236);
+        JettyHTTPServerEngineFactory.destroyForPort(9234);
+        JettyHTTPServerEngineFactory.destroyForPort(9235);
+        JettyHTTPServerEngineFactory.destroyForPort(9236);
     }
 
 
@@ -200,7 +199,7 @@ public class JettyHTTPServerEngineTest e
         response = getResponse(urlStr2);
         assertEquals("The jetty http handler did not take effect", response, "string2");
         // set the get request
-        factory.destroyForPort(9234);
+        JettyHTTPServerEngineFactory.destroyForPort(9234);
 
     }
     
@@ -247,8 +246,8 @@ public class JettyHTTPServerEngineTest e
             queryNames(new ObjectName("org.eclipse.jetty.server:type=server,*"), null));
         assertEquals("Could not find 0 Jetty Server: " + s, 0, s.size());
         
-        factory.destroyForPort(9234);
-        factory.destroyForPort(9235);
+        JettyHTTPServerEngineFactory.destroyForPort(9234);
+        JettyHTTPServerEngineFactory.destroyForPort(9235);
     }
 
     @Test
@@ -259,7 +258,6 @@ public class JettyHTTPServerEngineTest e
 
         JettyHTTPServerEngine engine = new JettyHTTPServerEngine();
         engine.setPort(9235);
-        engine.setJettyHTTPServerEngineFactory(factory);
 
         List<Handler> handlers = new ArrayList<Handler>();
         handlers.add(handler1);
@@ -307,7 +305,7 @@ public class JettyHTTPServerEngineTest e
             fail("Can't get the reponse from the server " + ex);
         }
         assertEquals("the jetty http handler did not take effect", response, "string2");
-        factory.destroyForPort(9234);
+        JettyHTTPServerEngineFactory.destroyForPort(9234);
     }
 
     @Test
@@ -340,7 +338,7 @@ public class JettyHTTPServerEngineTest e
         }
         assertEquals("the jetty http handler did not take effect", response, "test2");
 
-        factory.destroyForPort(9236);
+        JettyHTTPServerEngineFactory.destroyForPort(9236);
     }
 
     private String getResponse(String target) throws Exception {



Mime
View raw message