cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r588107 - in /incubator/cxf/branches/2.0.x-fixes: ./ rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/ rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/ rt/transports/http-jetty/src...
Date Thu, 25 Oct 2007 01:38:46 GMT
Author: dkulp
Date: Wed Oct 24 18:38:45 2007
New Revision: 588107

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

........
  r587893 | ningjiang | 2007-10-24 10:11:09 -0400 (Wed, 24 Oct 2007) | 1 line
  
  CXF-1134 Adding the supporting of set SO_REUSEADD flage, now we can't pass a rm systest
so I do not change the parent\pom.xml
........

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/JettyHTTPServerEngine.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties
    incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/resources/schemas/configuration/http-jetty.xsd
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.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/JettyHTTPServerEngine.java?rev=588107&r1=588106&r2=588107&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
Wed Oct 24 18:38:45 2007
@@ -20,7 +20,9 @@
 package org.apache.cxf.transport.http_jetty;
 
 import java.io.IOException;
+import java.net.ServerSocket;
 import java.net.URL;
+import java.nio.channels.ServerSocketChannel;
 import java.security.GeneralSecurityException;
 import java.util.List;
 import java.util.logging.Level;
@@ -38,6 +40,7 @@
 import org.mortbay.jetty.Connector;
 import org.mortbay.jetty.Handler;
 import org.mortbay.jetty.Server;
+import org.mortbay.jetty.bio.SocketConnector;
 import org.mortbay.jetty.handler.ContextHandler;
 import org.mortbay.jetty.handler.ContextHandlerCollection;
 import org.mortbay.jetty.handler.DefaultHandler;
@@ -87,6 +90,7 @@
     private String protocol = "http";    
     
     private Boolean isSessionSupport = false;
+    private Boolean isReuseAddress = true;
     private int servantCount;
     private Server server;
     private Connector connector;
@@ -239,6 +243,14 @@
         return connector;
     }
     
+    public boolean isReuseAddress() {
+        return isReuseAddress;
+    }
+    
+    public void setReuseAddress(boolean reuse) {
+        isReuseAddress = reuse;
+    }
+    
     /**
      * Register a servant.
      * 
@@ -274,6 +286,9 @@
             }
             try {
                 server.start();
+                if (isReuseAddress()) {
+                    setReuseAddress(connector);
+                }
                 AbstractConnector aconn = (AbstractConnector) connector;
                 if (aconn.getThreadPool() instanceof BoundedThreadPool
                     && isSetThreadingParameters()) {
@@ -327,6 +342,23 @@
         ++servantCount;
     }
     
+    private void setReuseAddress(Connector conn) throws IOException {
+        if (conn.getConnection() == null) {
+            conn.open();  // it might not be opened.
+        }    
+        ServerSocket socket = null;
+        if (conn instanceof SelectChannelConnector) {
+            ServerSocketChannel channel = (ServerSocketChannel) conn.getConnection();
+            socket = channel.socket();
+        } else if (conn instanceof SocketConnector) {    
+            socket = (ServerSocket)conn.getConnection();
+        } else {
+            LOG.info("UNKNOWN_CONNECTOR_MSG");
+            return;
+        }       
+        socket.setReuseAddress(true);        
+    }
+
     /**
      * Remove a previously registered servant.
      * 

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties
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/Messages.properties?rev=588107&r1=588106&r2=588107&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties
Wed Oct 24 18:38:45 2007
@@ -22,4 +22,5 @@
 ADD_HANDLER_FAILED_MSG = Could not add cxf jetty handler to Jetty server: {0}
 REMOVE_HANDLER_FAILED_MSG = Could not remove cxf jetty handler from Jetty server: {0}
 CAN_NOT_FIND_HANDLER_MSG = Could not find the handler to remove for context url {0}
-FAILED_TO_SHUTDOWN_ENGINE_MSG = Failed to shutdown Jetty server: {0} because it is still
in use
\ No newline at end of file
+FAILED_TO_SHUTDOWN_ENGINE_MSG = Failed to shutdown Jetty server: {0} because it is still
in use
+UNKNOWN_CONNECTOR_MSG = Unknown connector type, can't set the socket reuse address flage.
\ No newline at end of file

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.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/spring/JettyHTTPServerEngineBeanDefinitionParser.java?rev=588107&r1=588106&r2=588107&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
Wed Oct 24 18:38:45 2007
@@ -104,12 +104,10 @@
                         List handlers = 
                             ctx.getDelegate().parseListElement((Element) n, bean.getBeanDefinition());
                         bean.addPropertyValue("handlers", handlers);
-                    } else if ("sessionSupport".equals(name)) {
-                        String text = n.getTextContent();
-                        System.out.println("sessionSupport is " + Boolean.valueOf(text));
+                    } else if ("sessionSupport".equals(name) || "reuseAddress".equals(name))
{
+                        String text = n.getTextContent();                        
                         bean.addPropertyValue(name, Boolean.valueOf(text));
-                    }
-                        
+                    }                         
                 }
             }
         } catch (Exception e) {

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/resources/schemas/configuration/http-jetty.xsd
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/resources/schemas/configuration/http-jetty.xsd?rev=588107&r1=588106&r2=588107&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/resources/schemas/configuration/http-jetty.xsd
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/main/resources/schemas/configuration/http-jetty.xsd
Wed Oct 24 18:38:45 2007
@@ -78,7 +78,8 @@
          </xs:choice>         
          <xs:element name="connector" type="xsd:anyType" minOccurs="0"/>
          <xs:element name="handlers" type="xsd:anyType" minOccurs="0"/>
-         <xs:element name="sessionSupport" type="xsd:boolean" minOccurs="0"/>     
    
+         <xs:element name="sessionSupport" type="xsd:boolean" minOccurs="0"/>
+         <xs:element name="reuseAddress" type="xsd:boolean" minOccurs="0" />      
   
        </xs:sequence>
           <xs:attribute name="port" type="xs:int" use="required"/>
     </xs:complexType>

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java?rev=588107&r1=588106&r2=588107&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
Wed Oct 24 18:38:45 2007
@@ -25,17 +25,15 @@
 
 import java.net.HttpURLConnection;
 import java.net.InetAddress;
-import java.net.ServerSocket;
+
 import java.net.Socket;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.UnknownHostException;
-import java.nio.channels.ServerSocketChannel;
 import java.util.Properties;
 
 
 import org.apache.cxf.Bus;
-import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.endpoint.ServerImpl;
 import org.apache.cxf.endpoint.ServerRegistry;
 import org.apache.cxf.helpers.IOUtils;
@@ -49,9 +47,7 @@
 
 
 import org.junit.Test;
-import org.mortbay.jetty.Connector;
 import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.nio.SelectChannelConnector;
 import org.mortbay.jetty.webapp.WebAppContext;
 import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
@@ -171,8 +167,7 @@
     @Test
     public void testUpDownWithServlets() throws Exception {        
         setUpBus(true);
-        setReuseAddrForServer(8801);
-        setReuseAddrForServer(8808);
+       
         Bus bus = (Bus)applicationContext.getBean("cxf");
         ServerRegistry sr = bus.getExtension(ServerRegistry.class);
         ServerImpl si = (ServerImpl) sr.getServers().get(0);
@@ -197,36 +192,7 @@
         verifyNoServer(8801);
     }
     
-    private void setReuseAddrForServer(int port) throws IOException {
-        Bus bus = (Bus)applicationContext.getBean("cxf");
-        boolean turnedOnReuseAddr = false;
-        ServerRegistry sr = bus.getExtension(ServerRegistry.class);
-        for (Server server : sr.getServers()) {
-            ServerImpl si = (ServerImpl) server;
-            JettyHTTPDestination jhd = (JettyHTTPDestination) si.getDestination();
-            JettyHTTPServerEngine e = (JettyHTTPServerEngine) jhd.getEngine();
-            Connector connector = e.getConnector();
-            if (connector.getPort() == port) {
-                if (connector.getConnection() == null) {
-                    connector.open();  // it might not be opened.
-                }    
-                ServerSocket socket = null;
-                if (connector instanceof SelectChannelConnector) {
-                    ServerSocketChannel channel = (ServerSocketChannel) connector.getConnection();
-                    socket = channel.socket();
-                } else {    
-                    socket = (ServerSocket)connector.getConnection();
-                }    
-                assertNotNull("connector must have socket", socket);
-                socket.setReuseAddress(true);
-                turnedOnReuseAddr = socket.getReuseAddress();
-            }
-        }
-        assertTrue("Did not set the socket's ReuseAddress to be true", turnedOnReuseAddr);

-        // insure that we actually found the server for the port and did the deed.
         
-    }
-    
     private void verifyNoServer(int port) {
         try {
             Socket socket = new Socket(InetAddress.getLocalHost(), port);
@@ -248,8 +214,7 @@
     public void testServerUpDownUp() throws Exception {
         
         setUpBus(true);
-        setReuseAddrForServer(8801);
-        setReuseAddrForServer(8808);
+        
         getTestHtml();
         invokeService();    
         invokeService8801();
@@ -261,8 +226,7 @@
         Thread.sleep(4000);
         
         setUpBus(true);
-        setReuseAddrForServer(8801);
-        setReuseAddrForServer(8808);
+       
         invokeService();            
         invokeService8801();
         getTestHtml();



Mime
View raw message