Source:
void doDeploy(URI uri, Consumer<EndpointServlet> endpointServletConsumer, Consumer<DeploymentInfo> deploymentInfoConsumer, Consumer<DeploymentImpl> deploymentConsumer) { final ServletInfo servletInfo = Servlets.servlet(EndpointServlet.NAME, EndpointServlet.class).addMapping("/*") .setAsyncSupported(true); final DeploymentInfo mainDeploymentInfo = deploymentInfoSupplier.getValue(); DeploymentInfo endPointDeplyomentInfo = adaptDeploymentInfo(mainDeploymentInfo, uri, servletInfo); deploymentInfoConsumer.accept(endPointDeplyomentInfo); CamelLogger.LOGGER.debug("Deploying endpoint {}", endPointDeplyomentInfo.getDeploymentName()); final ClassLoader old = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(endPointDeplyomentInfo.getClassLoader()); try { final DeploymentManager manager = servletContainerServiceSupplier.getValue().getServletContainer() .addDeployment(endPointDeplyomentInfo); manager.deploy(); final Deployment deployment = manager.getDeployment(); try { HttpHandler handler = manager.start(); if (handler != deployment.getHandler()) { throw new IllegalStateException(); } deploymentConsumer.accept((DeploymentImpl) deployment); hostSupplier.getValue().registerDeployment(deployment, deployment.getHandler()); ManagedServlet managedServlet = deployment.getServlets().getManagedServlet(EndpointServlet.NAME); EndpointServlet servletInstance = (EndpointServlet) managedServlet.getServlet().getInstance(); endpointServletConsumer.accept(servletInstance); } catch (ServletException ex) { throw new IllegalStateException(ex); } synchronized (deployments) { deployments.put(uri, manager); } } finally { Thread.currentThread().setContextClassLoader(old); } }

Target:
void doDeploy(URI uri, Consumer<EndpointServlet> endpointServletConsumer, Consumer<DeploymentInfo> deploymentInfoConsumer, Consumer<DeploymentImpl> deploymentConsumer) { final ServletInfo servletInfo = Servlets.servlet(EndpointServlet.NAME, EndpointServlet.class).addMapping("/*") .setAsyncSupported(true); final DeploymentInfo mainDeploymentInfo = deploymentInfoSupplier.getValue(); DeploymentInfo endPointDeplyomentInfo = adaptDeploymentInfo(mainDeploymentInfo, uri, servletInfo); deploymentInfoConsumer.accept(endPointDeplyomentInfo); CamelLogger.LOGGER.debug("Deploying endpoint {}", endPointDeplyomentInfo.getDeploymentName()); final ClassLoader old = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(endPointDeplyomentInfo.getClassLoader()); try { final DeploymentManager manager = servletContainerServiceSupplier.getValue().getServletContainer() .addDeployment(endPointDeplyomentInfo); manager.deploy(); final Deployment deployment = manager.getDeployment(); try { deploymentConsumer.accept((DeploymentImpl) deployment); manager.start(); hostSupplier.getValue().registerDeployment(deployment, deployment.getHandler()); ManagedServlet managedServlet = deployment.getServlets().getManagedServlet(EndpointServlet.NAME); EndpointServlet servletInstance = (EndpointServlet) managedServlet.getServlet().getInstance(); endpointServletConsumer.accept(servletInstance); } catch (ServletException ex) { throw new IllegalStateException(ex); } synchronized (deployments) { deployments.put(uri, manager); } } finally { Thread.currentThread().setContextClassLoader(old); } }