Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A8F211170A for ; Wed, 18 Jun 2014 07:00:06 +0000 (UTC) Received: (qmail 8137 invoked by uid 500); 18 Jun 2014 07:00:06 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 8062 invoked by uid 500); 18 Jun 2014 07:00:06 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 8053 invoked by uid 99); 18 Jun 2014 07:00:06 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Jun 2014 07:00:06 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 2FA4283B411; Wed, 18 Jun 2014 07:00:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ningjiang@apache.org To: commits@camel.apache.org Date: Wed, 18 Jun 2014 07:00:06 -0000 Message-Id: <5777172f15e943c1b5959b943efe1997@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/4] git commit: CAMEL-7520 Support to setup the handler even the Jetty server is created 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 Authored: Wed Jun 18 14:36:46 2014 +0800 Committer: Willem Jiang 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 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();