cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1177164 - 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/ main/java/org/apache/cxf/transport/https_jetty/ main/resources/schemas/configuration...
Date Thu, 29 Sep 2011 04:52:09 GMT
Author: ningjiang
Date: Thu Sep 29 04:52:08 2011
New Revision: 1177164

URL: http://svn.apache.org/viewvc?rev=1177164&view=rev
Log:
Added maxIdleTime attribute support on the jetty engine spring configure

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/spring/JettyHTTPServerEngineBeanDefinitionParser.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
    cxf/trunk/rt/transports/http-jetty/src/main/resources/schemas/configuration/http-jetty.xsd
    cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
    cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
    cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml

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=1177164&r1=1177163&r2=1177164&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
Thu Sep 29 04:52:08 2011
@@ -96,6 +96,7 @@ public class JettyHTTPServerEngine
     private Boolean isSessionSupport = false;
     private Boolean isReuseAddress = true;
     private Boolean continuationsEnabled = true;
+    private int maxIdleTime = 200000;
     private int servantCount;
     private Server server;
     private Connector connector;
@@ -284,6 +285,14 @@ public class JettyHTTPServerEngine
         isReuseAddress = reuse;
     }
     
+    public int getMaxIdleTime() {
+        return maxIdleTime;
+    }
+    
+    public void setMaxIdleTime(int maxIdel) {
+        maxIdleTime = maxIdel;
+    }
+    
     /**
      * Register a servant.
      * 
@@ -643,6 +652,9 @@ public class JettyHTTPServerEngine
                     result.setHost(hosto);
                 }
                 result.setPort(porto);
+                if (getMaxIdleTime() > 0) {
+                    result.setMaxIdleTime(getMaxIdleTime());
+                }
                 return result;
             }
         };
@@ -654,7 +666,7 @@ public class JettyHTTPServerEngine
     protected JettyConnectorFactory getHTTPSConnectorFactory(
             TLSServerParameters tlsParams
     ) {
-        return new JettySslConnectorFactory(tlsParams);
+        return new JettySslConnectorFactory(tlsParams, getMaxIdleTime());
     }
     
     /**

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=1177164&r1=1177163&r2=1177164&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
Thu Sep 29 04:52:08 2011
@@ -70,6 +70,11 @@ public class JettyHTTPServerEngineBeanDe
         if (continuationsStr != null && continuationsStr.length() > 0) {
             bean.addPropertyValue("continuationsEnabled", continuationsStr);
         }
+        
+        String maxIdleTimeStr = element.getAttribute("maxIdleTime");
+        if (maxIdleTimeStr != null && !"".equals(maxIdleTimeStr.trim())) {
+            bean.addPropertyValue("maxIdleTime", maxIdleTimeStr);
+        }
         ValueHolder busValue = ctx.getContainingBeanDefinition()
             .getConstructorArgumentValues().getArgumentValue(0, Bus.class);
         bean.addPropertyValue("bus", busValue.getValue());

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java?rev=1177164&r1=1177163&r2=1177164&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
Thu Sep 29 04:52:08 2011
@@ -30,10 +30,16 @@ import org.eclipse.jetty.server.Abstract
 public final class JettySslConnectorFactory implements JettyConnectorFactory {
     
     TLSServerParameters tlsServerParameters;
+    int maxIdleTime;
     
     public JettySslConnectorFactory(TLSServerParameters params) {
         tlsServerParameters = params;
     }
+    
+    public JettySslConnectorFactory(TLSServerParameters params, int maxIdle) {
+        this(params);
+        this.maxIdleTime = maxIdle;
+    }
     /**
      * Create a Listener.
      * 
@@ -58,6 +64,9 @@ public final class JettySslConnectorFact
             secureConnector.setHost(host);
         }
         secureConnector.setPort(port);
+        if (maxIdleTime > 0) {
+            secureConnector.setMaxIdleTime(maxIdleTime);
+        }
         decorateCXFJettySslSocketConnector(secureConnector);
         return secureConnector;
     }

Modified: cxf/trunk/rt/transports/http-jetty/src/main/resources/schemas/configuration/http-jetty.xsd
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/resources/schemas/configuration/http-jetty.xsd?rev=1177164&r1=1177163&r2=1177164&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/resources/schemas/configuration/http-jetty.xsd
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/resources/schemas/configuration/http-jetty.xsd
Thu Sep 29 04:52:08 2011
@@ -144,9 +144,14 @@
        <xs:attribute name="continuationsEnabled" type="ptp:ParameterizedBoolean">
            <xs:annotation>
                 <xs:documentation>Specifies if Jetty Continuations will be explicitly
supported
-                by Jetty destinations. Continuations will be checked if this attribute is
set to true or                            omitted, ignored otherwise</xs:documentation>
+                by Jetty destinations. Continuations will be checked if this attribute is
set to true or omitted, ignored otherwise.</xs:documentation>
              </xs:annotation>
        </xs:attribute>
+       <xs:attribute name="maxIdleTime" type="ptp:ParameterizedInt">
+           <xs:annotation>  
+                <xs:documentation>Set the maximum Idle time for a connection, the timer
will be reset if there is any read and write option on the under layer stream.</xs:documentation>

+           </xs:annotation>
+       </xs:attribute>
     </xs:complexType>
     
     <xs:complexType name="JettyHTTPServerEngineFactoryConfigType">

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=1177164&r1=1177163&r2=1177164&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
Thu Sep 29 04:52:08 2011
@@ -103,18 +103,22 @@ public class JettyHTTPServerEngineTest e
                 "http".equals(engine.getProtocol()));
 
         engine = new JettyHTTPServerEngine();
+        engine.setJettyHTTPServerEngineFactory(factory);
         engine.setPort(9235);
+        engine.setMaxIdleTime(30000);
         engine.setTlsServerParameters(new TLSServerParameters());
         engine.finalizeConfig();
 
         List<JettyHTTPServerEngine> list = new ArrayList<JettyHTTPServerEngine>();
         list.add(engine);
         factory.setEnginesList(list);
-
         engine = factory.createJettyHTTPServerEngine(9235, "https");
-
+        JettyHTTPTestHandler handler1 = new JettyHTTPTestHandler("string1", true);
+        // need to create a servant to create the connector
+        engine.addServant(new URL("https://localhost:9235/test"), handler1);
         assertTrue("Protocol must be https",
                 "https".equals(engine.getProtocol()));
+        assertEquals("Get the wrong maxIdleTime.", 30000, engine.getConnector().getMaxIdleTime());
 
         factory.setTLSServerParametersForPort(9234, new TLSServerParameters());
         engine = factory.createJettyHTTPServerEngine(9234, "https");
@@ -172,9 +176,12 @@ public class JettyHTTPServerEngineTest e
         String urlStr2 = "http://localhost:9234/hello233/test";
         JettyHTTPServerEngine engine =
             factory.createJettyHTTPServerEngine(9234, "http");
+        engine.setMaxIdleTime(30000);
         JettyHTTPTestHandler handler1 = new JettyHTTPTestHandler("string1", true);
         JettyHTTPTestHandler handler2 = new JettyHTTPTestHandler("string2", true);
         engine.addServant(new URL(urlStr), handler1);
+        assertEquals("Get the wrong maxIdleTime.", 30000, engine.getConnector().getMaxIdleTime());
+        
         String response = null;
         response = getResponse(urlStr);
         assertEquals("The jetty http handler did not take effect", response, "string1");

Modified: cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java?rev=1177164&r1=1177163&r2=1177164&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
Thu Sep 29 04:52:08 2011
@@ -126,6 +126,7 @@ public class ApplicationContextTest exte
                 getEndpointInfo("foo", "bar", "http://localhost:9001"));
         
         engine = (JettyHTTPServerEngine)jd2.getEngine();
+        assertEquals(40000, engine.getMaxIdleTime());
         assertEquals(99, engine.getThreadingParameters().getMinThreads());
         assertEquals(777, engine.getThreadingParameters().getMaxThreads());
         assertTrue("The engine should support session manager", engine.isSessionSupport());

Modified: cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml?rev=1177164&r1=1177163&r2=1177164&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml
Thu Sep 29 04:52:08 2011
@@ -57,7 +57,7 @@
 	      <hj:threadingParameters minThreads="111" maxThreads="120"/>
 	   </hj:identifiedThreadingParameters>
        
-	   <hj:engine port="9000">
+	   <hj:engine port="9000" maxIdleTime="30000">
 	      <hj:threadingParametersRef id="sampleThreading1"/>	      
 	   </hj:engine>
 	   
@@ -65,7 +65,7 @@
 	      <hj:threadingParameters minThreads="21" maxThreads="389"/>
 	   </hj:engine>
 	   
-	   <hj:engine port="9001">
+	   <hj:engine port="9001" maxIdleTime="40000">
 	       <hj:threadingParameters minThreads="99" maxThreads="777"/>	      
 	     <hj:connector>
            <beans:bean class="org.eclipse.jetty.server.bio.SocketConnector">



Mime
View raw message