org.apache.camel.builder.ValueBuilder Java Examples
The following examples show how to use
org.apache.camel.builder.ValueBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MqttCamelRouteBuilder.java From Ardulink-2 with Apache License 2.0 | 6 votes |
private Processor divideByValueOf(ValueBuilder valueBuilder) { return new Processor() { @Override public void process(Exchange exchange) throws Exception { Message in = exchange.getIn(); BigDecimal sum = new BigDecimal( checkNotNull(in.getBody(Number.class), "Body of %s is null", in).toString()); BigDecimal divisor = new BigDecimal(checkNotNull(valueBuilder.evaluate(exchange, Integer.class), "No %s set in exchange %s", valueBuilder, exchange).toString()); in.setBody(sum.divide(divisor, HALF_UP)); } @Override public String toString() { return "Processor divideByValueOf by " + valueBuilder; } }; }
Example #2
Source File: Route.java From container with Apache License 2.0 | 5 votes |
@Override public void configure() throws Exception { final URL wsdlURL = this.getClass().getClassLoader().getResource("wsdl/SoapAPI.wsdl"); // CXF Endpoint final String SOAP_ENDPOINT = "cxf:" + ENDPOINT + "?wsdlURL=" + wsdlURL.toString() + "&serviceName={http://opentosca.org/appinvoker/}AppInvokerSoapWebServiceService&portName=" + PORT.toString() + "&dataFormat=PAYLOAD&loggingFeatureEnabled=true"; final ValueBuilder APP_BUS_ENDPOINT = new ValueBuilder(method(ApplicationBusServiceHandler.class, "getApplicationBusRoutingEndpoint")); final Predicate APP_BUS_ENDPOINT_EXISTS = PredicateBuilder.isNotNull(APP_BUS_ENDPOINT); final ClassLoader cl = org.opentosca.bus.application.api.soaphttp.model.ObjectFactory.class.getClassLoader(); final JAXBContext jc = JAXBContext.newInstance("org.opentosca.bus.application.api.soaphttp.model", cl); final JaxbDataFormat jaxb = new JaxbDataFormat(jc); final Processor requestProcessor = new RequestProcessor(); final Processor responseProcessor = new ResponseProcessor(); from(SOAP_ENDPOINT).unmarshal(jaxb).process(requestProcessor).choice().when(APP_BUS_ENDPOINT_EXISTS) //FIXME this recipientList should be replaced with a directly injected service reference .recipientList(APP_BUS_ENDPOINT).to("direct:handleResponse").endChoice().otherwise() .to("direct:handleException"); // handle exception if Application Bus is not running or wasn't bound from("direct:handleException") .throwException(new ApplicationBusInternalException("It seems like the Application Bus is not running.")) .to("direct:handleResponse"); // handle response from("direct:handleResponse").process(responseProcessor).marshal(jaxb); }
Example #3
Source File: QuteTestBase.java From camel-quarkus with Apache License 2.0 | 4 votes |
protected static ValueBuilder body() { return Builder.body(); }
Example #4
Source File: Route.java From container with Apache License 2.0 | 4 votes |
@Override public void configure() throws Exception { final ValueBuilder APP_BUS_ENDPOINT = new ValueBuilder(this.method(ApplicationBusServiceHandler.class, "getApplicationBusRoutingEndpoint")); final Predicate APP_BUS_ENDPOINT_EXISTS = PredicateBuilder.isNotNull(APP_BUS_ENDPOINT); final InvocationRequestProcessor invocationRequestProcessor = new InvocationRequestProcessor(); final InvocationResponseProcessor invocationResponseProcessor = new InvocationResponseProcessor(); final IsFinishedRequestProcessor isFinishedRequestProcessor = new IsFinishedRequestProcessor(); final IsFinishedResponseProcessor isFinishedResponseProcessor = new IsFinishedResponseProcessor(); final GetResultRequestProcessor getResultRequestProcessor = new GetResultRequestProcessor(); final GetResultResponseProcessor getResultResponseProcessor = new GetResultResponseProcessor(); final ExceptionProcessor exceptionProcessor = new ExceptionProcessor(); // handle exceptions this.onException(Exception.class).handled(true).setBody(property(Exchange.EXCEPTION_CAUGHT)) .process(exceptionProcessor); // INVOKE ROUTES // invoke route (for ServiceInstance) this.from("restlet:" + Route.BASE_ENDPOINT + Route.INVOKE_ENDPOINT_SI + "?restletMethod=post") .to("direct:invoke"); // invoke route (for NodeInstance) this.from("restlet:" + Route.BASE_ENDPOINT + Route.INVOKE_ENDPOINT_NI + "?restletMethod=post") .to("direct:invoke"); // invoke route this.from("direct:invoke").process(invocationRequestProcessor).to(Route.TO_APP_BUS_ENDPOINT).choice() .when(property(Exchange.EXCEPTION_CAUGHT).isNull()).process(invocationResponseProcessor).removeHeaders("*") .otherwise().process(exceptionProcessor); // IS FINISHED ROUTES // isFinished route (for ServiceInstance) this.from("restlet:" + Route.BASE_ENDPOINT + Route.POLL_ENDPOINT_SI + "?restletMethod=get") .to("direct:isFinished"); // isFinished route (for NodeInstance) this.from("restlet:" + Route.BASE_ENDPOINT + Route.POLL_ENDPOINT_NI + "?restletMethod=get") .to("direct:isFinished"); // isFinished route this.from("direct:isFinished").process(isFinishedRequestProcessor).to(Route.TO_APP_BUS_ENDPOINT) .process(isFinishedResponseProcessor).removeHeaders("*"); // GET RESULT ROUTES // getResult route (for ServiceInstance) this.from("restlet:" + Route.BASE_ENDPOINT + Route.GET_RESULT_ENDPOINT_SI + "?restletMethod=get") .to("direct:getResult"); // getResult route (for NodeInstance) this.from("restlet:" + Route.BASE_ENDPOINT + Route.GET_RESULT_ENDPOINT_NI + "?restletMethod=get") .to("direct:getResult"); // getResult route this.from("direct:getResult").process(getResultRequestProcessor).to(Route.TO_APP_BUS_ENDPOINT) .process(getResultResponseProcessor).removeHeaders("*"); // applicationBus route, throws exception if Application Bus is not // running or wasn't binded this.from(Route.TO_APP_BUS_ENDPOINT).choice().when(APP_BUS_ENDPOINT_EXISTS).recipientList(APP_BUS_ENDPOINT) .endChoice().otherwise().to("direct:handleException"); // handle exception if Application Bus is not running or wasn't binded this.from("direct:handleException") .throwException(new ApplicationBusInternalException("The Application Bus is not running.")); }
Example #5
Source File: Route.java From container with Apache License 2.0 | 4 votes |
@Override public void configure() throws Exception { final ValueBuilder APP_BUS_ENDPOINT = new ValueBuilder(method(ApplicationBusServiceHandler.class, "getApplicationBusRoutingEndpoint")); final Predicate APP_BUS_ENDPOINT_EXISTS = PredicateBuilder.isNotNull(APP_BUS_ENDPOINT); final InvocationRequestProcessor invocationRequestProcessor = new InvocationRequestProcessor(); final InvocationResponseProcessor invocationResponseProcessor = new InvocationResponseProcessor(); final IsFinishedRequestProcessor isFinishedRequestProcessor = new IsFinishedRequestProcessor(); final IsFinishedResponseProcessor isFinishedResponseProcessor = new IsFinishedResponseProcessor(); final GetResultRequestProcessor getResultRequestProcessor = new GetResultRequestProcessor(); final GetResultResponseProcessor getResultResponseProcessor = new GetResultResponseProcessor(); final ExceptionProcessor exceptionProcessor = new ExceptionProcessor(); // handle exceptions onException(Exception.class).handled(true).setBody(property(Exchange.EXCEPTION_CAUGHT)) .process(exceptionProcessor); // invoke route from("restlet:" + Route.BASE_ENDPOINT + Route.INVOKE_ENDPOINT + "?restletMethod=post") .process(invocationRequestProcessor).to(Route.TO_APP_BUS_ENDPOINT).choice() .when(property(Exchange.EXCEPTION_CAUGHT).isNull()).process(invocationResponseProcessor).removeHeaders("*") .otherwise().process(exceptionProcessor); // isFinished route from("restlet:" + Route.BASE_ENDPOINT + Route.POLL_ENDPOINT + "?restletMethod=get") .process(isFinishedRequestProcessor).to(Route.TO_APP_BUS_ENDPOINT).process(isFinishedResponseProcessor) .removeHeaders("*"); // getResult route from("restlet:" + Route.BASE_ENDPOINT + Route.GET_RESULT_ENDPOINT + "?restletMethod=get") .process(getResultRequestProcessor).to(Route.TO_APP_BUS_ENDPOINT).process(getResultResponseProcessor) .removeHeaders("*"); // applicationBus route, throws exception if Application Bus is not // running or wasn't binded from(Route.TO_APP_BUS_ENDPOINT).choice().when(APP_BUS_ENDPOINT_EXISTS).recipientList(APP_BUS_ENDPOINT) .endChoice().otherwise().to("direct:handleException"); // handle exception if Application Bus is not running or wasn't binded from("direct:handleException") .throwException(new ApplicationBusInternalException("The Application Bus is not running.")); }