cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r547746 - in /incubator/cxf/trunk/rt/transports/http-jetty/src: main/java/org/apache/cxf/transport/http_jetty/ test/java/org/apache/cxf/transport/http_jetty/spring/
Date Fri, 15 Jun 2007 17:16:45 GMT
Author: eglynn
Date: Fri Jun 15 10:16:43 2007
New Revision: 547746

URL: http://svn.apache.org/viewvc?view=rev&rev=547746
Log:
Allowing fallback Jetty thread pool thresholds to be configured that would apply in the case
where port-specific values are not provided.

Modified:
    incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
    incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
    incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml

Modified: incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java?view=diff&rev=547746&r1=547745&r2=547746
==============================================================================
--- incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
(original)
+++ incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
Fri Jun 15 10:16:43 2007
@@ -42,7 +42,8 @@
 public class JettyHTTPServerEngineFactory {
     private static final Logger LOG =
         LogUtils.getL7dLogger(JettyHTTPServerEngineFactory.class);
-
+    
+    private static final int FALLBACK_THREADING_PARAMS_KEY = 0;
 
     /**
      * This map holds references for allocated ports.
@@ -203,10 +204,7 @@
 
         ref.setProgrammaticTlsServerParameters(tlsParams);
         
-        ThreadingParameters tparams = threadingParametersMap.get(port);
-        if (tparams != null) {
-            ref.setThreadingParameters(tparams);
-        }
+        applyThreadingParameters(ref, port);
         
         ref.finalizeConfig();
         portMap.put(port, ref);
@@ -241,13 +239,31 @@
                     + port + " is not configured for TLS");
         }
         
-        ThreadingParameters threadingParams = threadingParametersMap.get(port);
-        if (threadingParams != null) {
-            ref.setThreadingParameters(threadingParams);
-        }
+        applyThreadingParameters(ref, port);
+        
         ref.finalizeConfig();
         portMap.put(port, ref);
         return ref;
+    }
+
+    /**
+     * Apply the thread paramaters to the newly created engine,
+     * falling back to non-port specific values if necessary.
+     * 
+     * @param engine the new created engine
+     * @param port the listen port
+     */
+    protected void applyThreadingParameters(JettyHTTPServerEngine engine, int port) {
+        ThreadingParameters params = threadingParametersMap.get(port);
+        if (params != null) {
+            engine.setThreadingParameters(params);
+        } else {
+            ThreadingParameters fallback =
+                threadingParametersMap.get(FALLBACK_THREADING_PARAMS_KEY);
+            if (fallback != null) {
+                engine.setThreadingParameters(fallback);
+            }
+        }
     }
     
     /**

Modified: incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java?view=diff&rev=547746&r1=547745&r2=547746
==============================================================================
--- incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
(original)
+++ incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
Fri Jun 15 10:16:43 2007
@@ -32,6 +32,7 @@
 import org.apache.cxf.transport.ConduitInitiator;
 import org.apache.cxf.transport.ConduitInitiatorManager;
 import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.DestinationFactory;
 import org.apache.cxf.transport.DestinationFactoryManager;
 import org.apache.cxf.transport.http.HTTPConduit;
 import org.apache.cxf.transport.http_jetty.JettyHTTPDestination;
@@ -92,24 +93,21 @@
         
         ConfigurerImpl cfg = new ConfigurerImpl(ctx);
         
-        ServiceInfo serviceInfo = new ServiceInfo();
-        serviceInfo.setName(new QName("bla", "Service"));        
-        EndpointInfo info = new EndpointInfo(serviceInfo, "");
-        info.setName(new QName("urn:test:ns", "Foo"));
-        info.setAddress("http://localhost:9000");
+        EndpointInfo info = getEndpointInfo("bla", "Foo", "http://localhost:9000");
         
         Bus bus = (Bus) ctx.getBean("cxf");
         bus.setExtension(cfg, Configurer.class);
         
         DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
-        Destination d = 
-            dfm.getDestinationFactory("http://schemas.xmlsoap.org/soap/http").getDestination(info);
+        DestinationFactory factory = dfm.getDestinationFactory("http://schemas.xmlsoap.org/soap/http");
+        Destination d = factory.getDestination(info);
         assertTrue(d instanceof JettyHTTPDestination);
         JettyHTTPDestination jd = (JettyHTTPDestination) d;        
         assertEquals("foobar", jd.getServer().getContentEncoding());   
         
         JettyHTTPServerEngine engine = (JettyHTTPServerEngine)jd.getEngine();
         assertEquals(111, engine.getThreadingParameters().getMinThreads());
+        assertEquals(120, engine.getThreadingParameters().getMaxThreads());
         
         ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
         ConduitInitiator ci = cim.getConduitInitiator("http://schemas.xmlsoap.org/soap/http");
@@ -119,6 +117,32 @@
         info.setName(new QName("urn:test:ns", "Bar"));
         conduit = (HTTPConduit) ci.getConduit(info);
         assertEquals(79, conduit.getClient().getConnectionTimeout());
-        
+
+        JettyHTTPDestination jd2 = 
+            (JettyHTTPDestination)factory.getDestination(
+                getEndpointInfo("foo", "bar", "http://localhost:9001"));
+        
+        engine = (JettyHTTPServerEngine)jd2.getEngine();
+        assertEquals(99, engine.getThreadingParameters().getMinThreads());
+        assertEquals(777, engine.getThreadingParameters().getMaxThreads());
+        
+        JettyHTTPDestination jd3 = 
+            (JettyHTTPDestination)factory.getDestination(
+                getEndpointInfo("sna", "foo", "http://localhost:9100"));
+        
+        engine = (JettyHTTPServerEngine)jd3.getEngine();
+        assertEquals(99, engine.getThreadingParameters().getMinThreads());
+        assertEquals(777, engine.getThreadingParameters().getMaxThreads());
+    }
+    
+    private EndpointInfo getEndpointInfo(String serviceNS, 
+                                         String endpointLocal, 
+                                         String address) {
+        ServiceInfo serviceInfo2 = new ServiceInfo();
+        serviceInfo2.setName(new QName(serviceNS, "Service"));        
+        EndpointInfo info2 = new EndpointInfo(serviceInfo2, "");
+        info2.setName(new QName("urn:test:ns", endpointLocal));
+        info2.setAddress(address);
+        return info2;
     }
 }

Modified: incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml?view=diff&rev=547746&r1=547745&r2=547746
==============================================================================
--- incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml
(original)
+++ incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml
Fri Jun 15 10:16:43 2007
@@ -55,5 +55,9 @@
 	      <hj:threadingParametersRef id="sampleThreading1"/>
 	   </hj:engine>
 	   
+	   <hj:engine port="0">
+	      <hj:threadingParameters minThreads="99" maxThreads="777"/>
+	   </hj:engine>
+	   
 	</hj:engine-factory>
 </beans>



Mime
View raw message