use of org.apache.camel.impl.transformer.ProcessorTransformer in project camel by apache.
the class EndpointTransformerDefinition method doCreateTransformer.
@Override
protected Transformer doCreateTransformer(CamelContext context) throws Exception {
Endpoint endpoint = uri != null ? context.getEndpoint(uri) : context.getRegistry().lookupByNameAndType(ref, Endpoint.class);
SendProcessor processor = new SendProcessor(endpoint, ExchangePattern.InOut);
return new ProcessorTransformer(context).setProcessor(processor).setModel(getScheme()).setFrom(getFromType()).setTo(getToType());
}
use of org.apache.camel.impl.transformer.ProcessorTransformer in project camel by apache.
the class TransformerBuilderTest method testEndpointTransformer.
public void testEndpointTransformer() throws Exception {
CamelContext ctx = new DefaultCamelContext();
RouteBuilder builder = new RouteBuilder() {
@Override
public void configure() throws Exception {
transformer().fromType("json:foo").toType("xml:bar").withUri("direct:transformer");
from("direct:transformer").log("test");
}
};
ctx.addRoutes(builder);
ctx.start();
Transformer transformer = ctx.resolveTransformer(new DataType("json:foo"), new DataType("xml:bar"));
assertNotNull(transformer);
assertEquals(ProcessorTransformer.class, transformer.getClass());
ProcessorTransformer pt = (ProcessorTransformer) transformer;
Field f = ProcessorTransformer.class.getDeclaredField("processor");
f.setAccessible(true);
Object processor = f.get(pt);
assertEquals(SendProcessor.class, processor.getClass());
SendProcessor sp = (SendProcessor) processor;
assertEquals("direct://transformer", sp.getEndpoint().getEndpointUri());
}
Aggregations