camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rom...@apache.org
Subject svn commit: r718246 - in /activemq/camel/branches/camel-1.x: ./ components/camel-jetty/src/main/java/org/apache/camel/component/jetty/ components/camel-jetty/src/test/java/org/apache/camel/component/jetty/
Date Mon, 17 Nov 2008 14:01:55 GMT
Author: romkal
Date: Mon Nov 17 06:01:55 2008
New Revision: 718246

URL: http://svn.apache.org/viewvc?rev=718246&view=rev
Log:
Merged revisions 718242 via svnmerge from 
https://svn.apache.org/repos/asf/activemq/camel/trunk

........
  r718242 | romkal | 2008-11-17 14:18:58 +0100 (Mon, 17 Nov 2008) | 1 line
  
  CAMEL-1091 : camel jetty looks at host specified in URL now
........

Added:
    activemq/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/InterfacesTest.java
      - copied unchanged from r718242, activemq/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/InterfacesTest.java
Modified:
    activemq/camel/branches/camel-1.x/   (props changed)
    activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
    activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java

Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov 17 06:01:55 2008
@@ -1 +1 @@
-/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989
+/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242

Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java?rev=718246&r1=718245&r2=718246&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
(original)
+++ activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
Mon Nov 17 06:01:55 2008
@@ -26,7 +26,6 @@
 import org.apache.camel.component.http.CamelServlet;
 import org.apache.camel.component.http.HttpConsumer;
 import org.apache.camel.component.http.HttpExchange;
-
 import org.mortbay.util.ajax.Continuation;
 import org.mortbay.util.ajax.ContinuationSupport;
 
@@ -35,6 +34,8 @@
  */
 public class CamelContinuationServlet extends CamelServlet {
 
+    private static final long serialVersionUID = 1L;
+
     @Override
     protected void service(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
         try {

Modified: activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java?rev=718246&r1=718245&r2=718246&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
(original)
+++ activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
Mon Nov 17 06:01:55 2008
@@ -26,10 +26,12 @@
 import org.apache.camel.component.http.HttpConsumer;
 import org.apache.camel.component.http.HttpEndpoint;
 import org.apache.camel.component.http.HttpExchange;
-
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.mortbay.jetty.Connector;
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.client.HttpClient;
+import org.mortbay.jetty.handler.ContextHandlerCollection;
 import org.mortbay.jetty.nio.SelectChannelConnector;
 import org.mortbay.jetty.security.SslSocketConnector;
 import org.mortbay.jetty.servlet.Context;
@@ -48,10 +50,12 @@
 
     class ConnectorRef {
         Connector connector;
+        CamelServlet servlet;
         int refCount;
 
-        public ConnectorRef(Connector connector) {
+        public ConnectorRef(Connector connector, CamelServlet servlet) {
             this.connector = connector;
+            this.servlet = servlet;
             increment();
         }
 
@@ -63,10 +67,11 @@
             return --refCount;
         }
     }
-
-    private CamelServlet camelServlet;
+    
+    private static final Log LOGGER = LogFactory.getLog(JettyHttpComponent.class);
+    
     private Server server;
-    private final HashMap<String, ConnectorRef> connectors = new HashMap<String,
ConnectorRef>();
+    private HashMap<String, ConnectorRef> connectors = new HashMap<String, ConnectorRef>();
     private HttpClient httpClient;
     private String sslKeyPassword;
     private String sslPassword;
@@ -91,7 +96,7 @@
 
         // Make sure that there is a connector for the requested endpoint.
         JettyHttpEndpoint endpoint = (JettyHttpEndpoint)consumer.getEndpoint();
-        String connectorKey = endpoint.getProtocol() + ":" + endpoint.getPort();
+        String connectorKey = endpoint.getProtocol() + ":" + endpoint.getHttpUri().getHost()
+ ":" + endpoint.getPort();
 
         synchronized (connectors) {
             ConnectorRef connectorRef = connectors.get(connectorKey);
@@ -103,26 +108,27 @@
                     connector = new SelectChannelConnector();
                 }
                 connector.setPort(endpoint.getPort());
-                getServer().addConnector(connector);
-                // check the session support
-                if (endpoint.isSessionSupport()) {
-                    enableSessionSupport();
+                connector.setHost(endpoint.getHttpUri().getHost());
+                if ("localhost".equalsIgnoreCase(endpoint.getHttpUri().getHost())) {
+                    LOGGER.warn("You use localhost interface! It means that no external connections
will be available. Don't you want to use 0.0.0.0 instead (all network interfaces)?");
                 }
+                getServer().addConnector(connector);
+
+                connectorRef = new ConnectorRef(connector, createServletForConnector(connector));
                 connector.start();
-                connectorRef = new ConnectorRef(connector);
+                
                 connectors.put(connectorKey, connectorRef);
+                
             } else {
                 // ref track the connector
                 connectorRef.increment();
-                // check the session support
-                if (endpoint.isSessionSupport()) {
-                    enableSessionSupport();
-                }
             }
-
+            // check the session support
+            if (endpoint.isSessionSupport()) {
+                enableSessionSupport();
+            }
+            connectorRef.servlet.connect(consumer);
         }
-
-        camelServlet.connect(consumer);
     }
 
     private void enableSessionSupport() throws Exception {
@@ -145,8 +151,6 @@
      */
     @Override
     public void disconnect(HttpConsumer consumer) throws Exception {
-        camelServlet.disconnect(consumer);
-
         // If the connector is not needed anymore then stop it
         HttpEndpoint endpoint = consumer.getEndpoint();
         String connectorKey = endpoint.getProtocol() + ":" + endpoint.getPort();
@@ -154,6 +158,7 @@
         synchronized (connectors) {
             ConnectorRef connectorRef = connectors.get(connectorKey);
             if (connectorRef != null) {
+                connectorRef.servlet.disconnect(consumer);
                 if (connectorRef.decrement() == 0) {
                     getServer().removeConnector(connectorRef.connector);
                     connectorRef.connector.stop();
@@ -219,22 +224,32 @@
         sslSocketConnector = connector;
     }
 
-    // Implementation methods
-    // -------------------------------------------------------------------------
-
-    protected Server createServer() throws Exception {
-        camelServlet = new CamelContinuationServlet();
-
-        Server server = new Server();
-        Context context = new Context(Context.NO_SECURITY | Context.NO_SESSIONS);
+    protected CamelServlet createServletForConnector(Connector connector) throws Exception
{
+        CamelServlet camelServlet = new CamelContinuationServlet();
+        
+        Context context = new Context(server, "/", Context.NO_SECURITY | Context.NO_SESSIONS);
+        context.setConnectorNames(new String[] {connector.getName()});
 
-        context.setContextPath("/");
         ServletHolder holder = new ServletHolder();
         holder.setServlet(camelServlet);
         context.addServlet(holder, "/*");
-        server.setHandler(context);
+        connector.start();
+        context.start();
+        
+
+        return camelServlet;
+    }
+    
+    // Implementation methods
+    // -------------------------------------------------------------------------
 
+    protected Server createServer() throws Exception {
+        Server server = new Server();
+        ContextHandlerCollection collection = new ContextHandlerCollection();
+        collection.setServer(server);
+        server.addHandler(collection);
         server.start();
+
         return server;
     }
 



Mime
View raw message