package com.liav.oxp.esb.poc; import org.apache.camel.processor.DelegateProcessor; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.model.ProcessorType; import org.apache.camel.model.RouteType; import org.apache.camel.spi.InterceptStrategy; public class MyFromEndpointInterceptor extends DelegateProcessor implements InterceptStrategy { private ProcessorType node; protected MyFromEndpointInterceptor() { } private MyFromEndpointInterceptor(ProcessorType node, Processor target) { super(target); this.node = node; } public Processor wrapProcessorInInterceptors(ProcessorType processorType, Processor target) throws Exception { return new MyFromEndpointInterceptor(processorType, target); } public void process(Exchange exchange) throws Exception { //Trying to extract the 'FROM' end-point: // compuate and set from endpoint uri if (exchange.getProperty("fromEndpointUri") == null) { ProcessorType parent = node.getParent(); if (parent instanceof RouteType) { RouteType rt = (RouteType)parent; // note assumes that we only have one input (that is very common anyway) String fromEndpointUri = rt.getInputs().get(0).getEndpoint().getEndpointUri(); exchange.setProperty("fromEndpointUri", fromEndpointUri); } } // must invoke the target to continue the routing Processor oXpServicesAuthenticationProcessor = new OXpServicesAuthenticationProcessor(); //getProcessor().process(exchange); oXpServicesAuthenticationProcessor.process(exchange); } }