public HttpProxyServiceImpl(CamelContext camelContext) { this.camelContext = camelContext; // Add servlet to the Camel Context ServletComponent servlet = new ServletComponent(); servlet.setCamelContext(camelContext); servlet.setServletName(SERVLET_NAME); if (camelContext != null) { this.camelContext.addComponent(SERVLET_COMPONENT, servlet); } }
@Override public void connect(HttpConsumer consumer) throws Exception { super.connect(consumer); } }
@Override public Consumer createConsumer(CamelContext camelContext, Processor processor, String verb, String basePath, String uriTemplate, String consumes, String produces, RestConfiguration configuration, Map<String, Object> parameters) throws Exception { return doCreateConsumer(camelContext, processor, verb, basePath, uriTemplate, consumes, produces, configuration, parameters, false); }
Boolean throwExceptionOnFailure = getAndRemoveParameter(parameters, "throwExceptionOnFailure", Boolean.class); Boolean transferException = getAndRemoveParameter(parameters, "transferException", Boolean.class); Boolean bridgeEndpoint = getAndRemoveParameter(parameters, "bridgeEndpoint", Boolean.class); HttpBinding binding = resolveAndRemoveReferenceParameter(parameters, "httpBinding", HttpBinding.class); Boolean matchOnUriPrefix = getAndRemoveParameter(parameters, "matchOnUriPrefix", Boolean.class); String servletName = getAndRemoveParameter(parameters, "servletName", String.class, getServletName()); String httpMethodRestrict = getAndRemoveParameter(parameters, "httpMethodRestrict", String.class); HeaderFilterStrategy headerFilterStrategy = resolveAndRemoveReferenceParameter(parameters, "headerFilterStrategy", HeaderFilterStrategy.class); Boolean async = getAndRemoveParameter(parameters, "async", Boolean.class); Boolean attachmentMultipartBinding = getAndRemoveParameter(parameters, "attachmentMultipartBinding", Boolean.class); Boolean disableStreamCache = getAndRemoveParameter(parameters, "disableStreamCache", Boolean.class); if (lenientContextPath()) { ServletEndpoint endpoint = createServletEndpoint(uri, this, httpUri); endpoint.setServletName(servletName); endpoint.setFileNameExtWhitelist(fileNameExtWhitelist); endpoint.setHeaderFilterStrategy(headerFilterStrategy); } else { setEndpointHeaderFilterStrategy(endpoint); binding = getHttpBinding(); endpoint.setAttachmentMultipartBinding(attachmentMultipartBinding); } else { endpoint.setAttachmentMultipartBinding(isAttachmentMultipartBinding()); setProperties(endpoint, parameters);
@Validate public void start() throws ServletException, NamespaceException { CamelHttpTransportServlet srvlet = new CamelHttpTransportServlet(); httpSevlet.registerServlet("/sally", srvlet, null, null); httpSevlet.registerResources("/sally/static", "/static", null); servletComponent = new ServletComponent(); servletComponent.setServletName(srvlet.getServletName()); log.info("SallyURL "+SallyURL+ " "); }
@ConditionalOnMissingBean(ServletComponent.class) public ServletComponent configureServletComponent() throws Exception { ServletComponent component = new ServletComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null,
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { Iti68Endpoint endpoint = (Iti68Endpoint)super.createEndpoint(uri, remaining, parameters); // Ensure that the audit/auditContext parameter is evaluated endpoint.setConfig(new AuditableEndpointConfiguration(this, parameters)); return endpoint; }
@Validate public void start() throws ServletException, NamespaceException { CamelHttpTransportServlet srvlet = new CamelHttpTransportServlet(); httpSevlet.registerServlet("/sally", srvlet, null, null); httpSevlet.registerResources("/sally/jobad", "/app/jobad", null); httpSevlet.registerResources("/sally/client", "/app/client", null); ServletComponent servletComponent = new ServletComponent(); servletComponent.setServletName(srvlet.getServletName()); camelContextProvider.registerGlobalComponent("sallyservlet", servletComponent); }
@Override @SuppressWarnings("unchecked") protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { boolean throwException = getAndRemoveParameter(parameters, "throwExceptionOnFailure", Boolean.class, true); boolean bridgeEndpoint = getAndRemoveParameter(parameters, "bridgeEndpoint", Boolean.class, true); OutboundBinding<GHttpEndpoint, HTTPRequest, HTTPResponse> outboundBinding = resolveAndRemoveReferenceParameter( parameters, "outboundBindingRef", OutboundBinding.class, new GHttpBinding()); InboundBinding<GHttpEndpoint, HttpServletRequest, HttpServletResponse> inboundBinding = resolveAndRemoveReferenceParameter( parameters, "inboundBindingRef", InboundBinding.class, new GHttpBinding()); GHttpEndpoint endpoint = (GHttpEndpoint)super.createEndpoint(uri, remaining, parameters); endpoint.setThrowExceptionOnFailure(throwException); endpoint.setBridgeEndpoint(bridgeEndpoint); endpoint.setOutboundBinding(outboundBinding); endpoint.setInboundBinding(inboundBinding); return endpoint; }
@Override @SuppressWarnings("unchecked") protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { String workerRoot = getAndRemoveParameter(parameters, "workerRoot", String.class, "worker"); String inboundBindingRef = (String) parameters.get("inboundBindingRef"); String outboundBindingRef = (String) parameters.get("outboundBindingRef"); OutboundBinding<GTaskEndpoint, TaskOptions, Void> outboundBinding = resolveAndRemoveReferenceParameter( parameters, "outboundBindingRef", OutboundBinding.class, new GTaskBinding()); InboundBinding<GTaskEndpoint, HttpServletRequest, HttpServletResponse> inboundBinding = resolveAndRemoveReferenceParameter( parameters, "inboundBindingRef", InboundBinding.class, new GTaskBinding()); GTaskEndpointInfo info = new GTaskEndpointInfo(uri, remaining); GTaskEndpoint endpoint = (GTaskEndpoint)super.createEndpoint( info.getCanonicalUri(), info.getCanonicalUriPath(), parameters); endpoint.setServletName(getServletName()); endpoint.setWorkerRoot(workerRoot); endpoint.setOutboundBinding(outboundBinding); endpoint.setInboundBinding(inboundBinding); endpoint.setQueueName(remaining); endpoint.setQueue(QueueFactory.getQueue(remaining)); endpoint.setInboundBindingRef(inboundBindingRef); endpoint.setOutboundBindingRef(outboundBindingRef); return endpoint; }
@Override public Consumer createApiConsumer(CamelContext camelContext, Processor processor, String contextPath, RestConfiguration configuration, Map<String, Object> parameters) throws Exception { // reuse the createConsumer method we already have. The api need to use GET and match on uri prefix return doCreateConsumer(camelContext, processor, "GET", contextPath, null, null, null, configuration, parameters, true); }