camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [1/2] git commit: CAMEL-7520 Support to setup the handler even the Jetty server is created
Date Wed, 18 Jun 2014 07:02:07 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.12.x 3c4f98a04 -> 23bb1758a
  refs/heads/camel-2.13.x 4f7b3c8c4 -> 254c03a9a


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/254c03a9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/254c03a9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/254c03a9

Branch: refs/heads/camel-2.13.x
Commit: 254c03a9ab0bfbf059e5a8b7de41b1f072cee2cc
Parents: 4f7b3c8
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 15:01:18 2014 +0800

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


http://git-wip-us.apache.org/repos/asf/camel/blob/254c03a9/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 670a4a5..5fe2ae4 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
@@ -310,6 +310,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();
             }
@@ -923,19 +930,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();
@@ -966,6 +961,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