@Override public Consumer doCreateConsumer(Processor processor) throws Exception { return super.createConsumer(processor); }
/** * Strategy to create the servlet endpoint. */ protected ServletEndpoint createServletEndpoint(String endpointUri, ServletComponent component, URI httpUri) throws Exception { return new ServletEndpoint(endpointUri, component, httpUri); }
@Override public Consumer createConsumer(Processor processor) throws Exception { ServletConsumer answer = new ServletConsumer(this, processor); configureConsumer(answer); return answer; }
@Override public HttpBinding getHttpBinding() { // make sure we include servlet variant of the http binding if (this.binding == null) { // is attachment binding enabled? if (isAttachmentMultipartBinding()) { this.binding = new AttachmentHttpBinding(); } else { this.binding = new DefaultHttpBinding(); } this.binding.setFileNameExtWhitelist(getFileNameExtWhitelist()); this.binding.setTransferException(isTransferException()); if (getComponent() != null) { this.binding.setAllowJavaSerializedObject(getComponent().isAllowJavaSerializedObject()); } this.binding.setHeaderFilterStrategy(getHeaderFilterStrategy()); this.binding.setEagerCheckContentAvailable(isEagerCheckContentAvailable()); this.binding.setMapHttpMessageBody(isMapHttpMessageBody()); this.binding.setMapHttpMessageHeaders(isMapHttpMessageHeaders()); this.binding.setMapHttpMessageFormUrlEncodedBody(isMapHttpMessageFormUrlEncodedBody()); } return this.binding; }
binding.setHeaderFilterStrategy(endpoint.getHeaderFilterStrategy()); binding.setTransferException(endpoint.isTransferException()); binding.setEagerCheckContentAvailable(endpoint.isEagerCheckContentAvailable()); endpoint.setHttpBinding(binding); Consumer consumer = endpoint.createConsumer(processor); if (config.getConsumerProperties() != null && !config.getConsumerProperties().isEmpty()) { setProperties(camelContext, consumer, config.getConsumerProperties());
@Override public void connect(HttpConsumer consumer) { ServletEndpoint endpoint = getServletEndpoint(consumer); if (endpoint.getServletName() != null && endpoint.getServletName().equals(getServletName())) { super.connect(consumer); } }
/** * Proxies the {@link org.apache.camel.http.common.HttpBinding} returned by {@link super#getBinding()} * with a dynamic proxy. The proxy's invocation handler further delegates to * {@link InboundBinding#readRequest(org.apache.camel.Endpoint, Exchange, Object)} * . * * @return proxied {@link org.apache.camel.http.common.HttpBinding}. */ @Override public HttpBinding getBinding() { return (HttpBinding)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {HttpBinding.class}, new HttpBindingInvocationHandler<GHttpEndpoint, HttpServletRequest, HttpServletResponse>( this, super.getBinding(), getInboundBinding())); }
@Override public Producer doCreateProducer() throws Exception { return super.createProducer(); }
@Override protected void populateRequestParameters(HttpServletRequest request, HttpMessage message) throws Exception { super.populateRequestParameters(request, message); String path = request.getPathInfo(); if (path == null) { return; } // in the endpoint the user may have defined rest {} placeholders // so we need to map those placeholders with data from the incoming request context path ServletEndpoint endpoint = (ServletEndpoint) message.getExchange().getFromEndpoint(); String consumerPath = endpoint.getPath(); if (useRestMatching(consumerPath)) { // split using single char / is optimized in the jdk String[] paths = path.split("/"); String[] consumerPaths = consumerPath.split("/"); for (int i = 0; i < consumerPaths.length; i++) { if (paths.length < i) { break; } String p1 = consumerPaths[i]; if (p1.startsWith("{") && p1.endsWith("}")) { String key = p1.substring(1, p1.length() - 1); String value = paths[i]; if (value != null) { message.setHeader(key, value); } } } } }
@Override public void connect(HttpConsumer consumer) { log.debug("Getting ServletEndpoint for consumer: {}", consumer); ServletEndpoint endpoint = getServletEndpoint(consumer); if (endpoint.getServletName() != null) { String endpointName = getEndpointNameFromPath(consumer.getPath()); log.debug("Adding consumer for endpointName: {}", endpointName); consumers.put(endpointName, consumer); } }
/** * Proxies the {@link HttpBinding} returned by {@link super#getBinding()} * with a dynamic proxy. The proxy's invocation handler further delegates to * {@link InboundBinding#readRequest(org.apache.camel.Endpoint, Exchange, Object)} . * * @return proxied {@link HttpBinding}. */ @Override public HttpBinding getBinding() { return (HttpBinding)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {HttpBinding.class}, new HttpBindingInvocationHandler<GTaskEndpoint, HttpServletRequest, HttpServletResponse>( this, super.getBinding(), getInboundBinding())); }
@Override public void connect(HttpConsumer consumer) throws Exception { ServletConsumer sc = (ServletConsumer) consumer; String name = sc.getEndpoint().getServletName(); HttpRegistry registry = httpRegistry; if (registry == null) { registry = DefaultHttpRegistry.getHttpRegistry(name); } registry.register(consumer); }
@Override public void disconnect(HttpConsumer consumer) throws Exception { ServletConsumer sc = (ServletConsumer) consumer; String name = sc.getEndpoint().getServletName(); HttpRegistry registry = httpRegistry; if (registry == null) { registry = DefaultHttpRegistry.getHttpRegistry(name); } registry.unregister(consumer); }