camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [1/4] git commit: CAMEL-7520 Support to setup the handler even the Jetty server is created
Date Wed, 18 Jun 2014 07:00:06 GMT
Repository: camel
Updated Branches:
  refs/heads/master ef4d0a7ec -> 601c14356


CAMEL-7520 Support to setup the handler even the Jetty server is created


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8c7dcebd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8c7dcebd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8c7dcebd

Branch: refs/heads/master
Commit: 8c7dcebd8bb477654226ee3d8132ecf36aa8058a
Parents: b6a8799
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Wed Jun 18 14:36:46 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Wed Jun 18 14:56:15 2014 +0800

----------------------------------------------------------------------
 .../component/jetty/JettyHttpComponent.java     | 38 +++++++++++++-------
 1 file changed, 25 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8c7dcebd/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
index f9d4ebf..6d15b68 100644
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
+++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
@@ -312,6 +312,13 @@ public class JettyHttpComponent extends HttpComponent {
                 CONNECTORS.put(connectorKey, connectorRef);
                 
             } else {
+                
+                if (endpoint.getHandlers() != null && !endpoint.getHandlers().isEmpty())
{
+                    // As the server is started, we need to stop the server for a while to
add the new handler
+                    connectorRef.server.stop();
+                    addJettyHandlers(connectorRef.server, endpoint.getHandlers());
+                    connectorRef.server.start();
+                }
                 // ref track the connector
                 connectorRef.increment();
             }
@@ -925,19 +932,7 @@ public class JettyHttpComponent extends HttpComponent {
         ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.NO_SECURITY
| ServletContextHandler.NO_SESSIONS);
         context.setConnectorNames(new String[] {connector.getName()});
 
-        if (handlers != null && !handlers.isEmpty()) {
-            for (Handler handler : handlers) {
-                if (handler instanceof HandlerWrapper) {
-                    ((HandlerWrapper) handler).setHandler(server.getHandler());
-                    server.setHandler(handler);
-                } else {
-                    HandlerCollection handlerCollection = new HandlerCollection();
-                    handlerCollection.addHandler(server.getHandler());
-                    handlerCollection.addHandler(handler);
-                    server.setHandler(handlerCollection);
-                }
-            }
-        }
+        addJettyHandlers(server, handlers);
 
         CamelServlet camelServlet;
         boolean jetty = endpoint.getUseContinuation() != null ? endpoint.getUseContinuation()
: isUseContinuation();
@@ -968,6 +963,23 @@ public class JettyHttpComponent extends HttpComponent {
         return camelServlet;
     }
     
+    protected void addJettyHandlers(Server server, List<Handler> handlers) {
+        if (handlers != null && !handlers.isEmpty()) {
+            for (Handler handler : handlers) {
+                if (handler instanceof HandlerWrapper) {
+                    ((HandlerWrapper) handler).setHandler(server.getHandler());
+                    server.setHandler(handler);
+                } else {
+                    HandlerCollection handlerCollection = new HandlerCollection();
+                    handlerCollection.addHandler(server.getHandler());
+                    handlerCollection.addHandler(handler);
+                    server.setHandler(handlerCollection);
+                }
+            }
+        }
+        
+    }
+    
     protected Server createServer() throws Exception {
         Server server = new Server();
         ContextHandlerCollection collection = new ContextHandlerCollection();


Mime
View raw message