org.apache.camel.Processor - java examples

Here are the examples of the java api org.apache.camel.Processor taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

148 Examples 7

19 View Complete Implementation : SwitchYardEndpoint.java
Copyright Apache License 2.0
Author : jboss-switchyard
/**
 * Creates a event driven consumer as opposed to a polling consumer.
 * @param processor processor used by consumer
 * @return event-driven consumer
 * @throws Exception error creating consumer
 */
@Override
public Consumer createConsumer(final Processor processor) throws Exception {
    _consumer = new SwitchYardConsumer(this, processor);
    return _consumer;
}

19 View Complete Implementation : AuditDefinition.java
Copyright Apache License 2.0
Author : krasserm
/**
 * @author Martin Krreplaceder
 */
public clreplaced AuditDefinition extends DelegateDefinition {

    private Processor auditProcessor;

    private String auditProcessorBeanName;

    public AuditDefinition() {
        auditProcessor = new Noop();
    }

    /**
     * @param auditProcessor the auditProcessor to set
     */
    public void setAuditProcessor(Processor auditProcessor) {
        this.auditProcessor = auditProcessor;
    }

    /**
     * @param auditProcessorBeanName the auditProcessorBeanName to set
     */
    public void setAuditProcessorBeanName(String auditProcessorBeanName) {
        this.auditProcessorBeanName = auditProcessorBeanName;
    }

    @Override
    protected Processor doCreateDelegate(RouteContext routeContext) throws Exception {
        if (auditProcessorBeanName != null) {
            auditProcessor = routeContext.lookup(auditProcessorBeanName, Processor.clreplaced);
        }
        return auditProcessor;
    }

    private static clreplaced Noop implements Processor {

        @Override
        public void process(Exchange exchange) throws Exception {
        }
    }
}

19 View Complete Implementation : HiWorldEndpoint.java
Copyright Apache License 2.0
Author : camelinaction
public Consumer createConsumer(Processor processor) throws Exception {
    // make sure inBody is not set for consumers
    if (inBody != null) {
        throw new IllegalArgumentException("Option inBody is not supported for consumer endpoint");
    }
    final HiWorldConsumer consumer = new HiWorldConsumer(this, processor);
    // also set consumer.* properties
    configureConsumer(consumer);
    return consumer;
}

19 View Complete Implementation : JsonEndpoint.java
Copyright Apache License 2.0
Author : funktionio
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    return new JsonConsumer(this, processor);
}

19 View Complete Implementation : CamundaBpmPollExternalTasksEndpointImpl.java
Copyright Apache License 2.0
Author : camunda
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    final BatchConsumer consumer;
    if (getScheduledExecutorService() != null) {
        consumer = new BatchConsumer(this, processor, getScheduledExecutorService(), retries, retryTimeout, retryTimeouts, lockDuration, topic, completeTask, variablesToFetch, deserializeVariables, workerId);
    } else {
        consumer = new BatchConsumer(this, processor, retries, retryTimeout, retryTimeouts, lockDuration, topic, completeTask, variablesToFetch, deserializeVariables, workerId);
    }
    configureConsumer(consumer);
    consumer.setMaxMessagesPerPoll(maxTasksPerPoll);
    return consumer;
}

19 View Complete Implementation : ErpEndpoint.java
Copyright Apache License 2.0
Author : camelinaction
public Consumer createConsumer(Processor processor) throws Exception {
    throw new UnsupportedOperationException("ErpComponent does not support consumer");
}

19 View Complete Implementation : KieEndpoint.java
Copyright Apache License 2.0
Author : kiegroup
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    throw new UnsupportedOperationException("Consumer not supported for " + getClreplaced().getSimpleName() + " endpoint");
}

19 View Complete Implementation : PropagateEndpoint.java
Copyright Apache License 2.0
Author : apache
@Override
public Consumer createConsumer(final Processor processor) throws Exception {
    throw new UnsupportedOperationException("Consumer not supported");
}

19 View Complete Implementation : ValidationDefinition.java
Copyright Apache License 2.0
Author : krasserm
/**
 * @author Martin Krreplaceder
 */
public clreplaced ValidationDefinition extends OutputDefinition<ValidationDefinition> {

    private final Processor responseGeneratorProcessor;

    private final String responseGeneratorUri;

    public ValidationDefinition(String responseGeneratorUri) {
        this(null, responseGeneratorUri);
    }

    public ValidationDefinition(Processor responseGeneratorProcessor) {
        this(responseGeneratorProcessor, null);
    }

    private ValidationDefinition(Processor responseGeneratorProcessor, String responseGeneratorUri) {
        this.responseGeneratorProcessor = responseGeneratorProcessor;
        this.responseGeneratorUri = responseGeneratorUri;
    }

    @Override
    public Processor createProcessor(RouteContext routeContext) throws Exception {
        Validation validation = createValidationProcessor(routeContext);
        validation.setProcessor(createChildProcessor(routeContext, false));
        return validation;
    }

    private Validation createValidationProcessor(RouteContext routeContext) throws Exception {
        if (responseGeneratorUri != null) {
            return new Validation(routeContext.resolveEndpoint(responseGeneratorUri).createProducer());
        } else {
            return new Validation(responseGeneratorProcessor);
        }
    }
}

19 View Complete Implementation : CdiEventEndpoint.java
Copyright Apache License 2.0
Author : astefanutti
@Override
public Consumer createConsumer(Processor processor) {
    return new CdiEventConsumer<>(this, processor);
}

19 View Complete Implementation : K8KafkaEndpoint.java
Copyright Apache License 2.0
Author : funktionio
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    KafkaConsumer consumer = new KafkaConsumer(this, processor);
    configureConsumer(consumer);
    return consumer;
}

19 View Complete Implementation : MdwEndpoint.java
Copyright Apache License 2.0
Author : CenturyLinkCloud
public Consumer createConsumer(Processor processor) throws Exception {
    return new MdwConsumer(this, processor);
}

19 View Complete Implementation : DebugSpringTest.java
Copyright Apache License 2.0
Author : CamelCookbook
@Override
protected void debugAfter(Exchange exchange, Processor processor, ProcessorDefinition<?> definition, String id, String label, long timeTaken) {
    // This method is called after each processor step
    // Set your breakpoint here
    log.info("After {} with body {}", definition, exchange.getIn().getBody());
}

19 View Complete Implementation : WsEndpoint.java
Copyright Apache License 2.0
Author : industrial-data-space
@Override
public Consumer createConsumer(Processor processor) {
    return new WsConsumer(this, processor);
}

19 View Complete Implementation : JBatchEndpoint.java
Copyright Apache License 2.0
Author : apache
@Override
public Consumer createConsumer(final Processor processor) throws Exception {
    throw new UnsupportedOperationException();
}

19 View Complete Implementation : KieEmbeddedEndpoint.java
Copyright Apache License 2.0
Author : kiegroup
public Consumer createConsumer(Processor processor) throws Exception {
    return new KieConsumer(this, processor);
}

19 View Complete Implementation : ERPEndpoint.java
Copyright Apache License 2.0
Author : camelinaction
public Consumer createConsumer(Processor processor) throws Exception {
    throw new UnsupportedOperationException("Consumer not supported");
}

19 View Complete Implementation : RouteHelper.java
Copyright Apache License 2.0
Author : krasserm
/**
 * Creates a {@link Validation} process object.
 *
 * @param validator
 *            processor that validates an exchange.
 * @return a validation process object.
 */
public Validation validation(Processor validator) {
    return new Validation(validator);
}

19 View Complete Implementation : QuarkusPlatformHttpEngine.java
Copyright Apache License 2.0
Author : apache
@Override
public Consumer createConsumer(PlatformHttpEndpoint endpoint, Processor processor) {
    return new QuarkusPlatformHttpConsumer(endpoint, processor, router, handlers, uploadAttacher);
}

19 View Complete Implementation : SplitterDefinition.java
Copyright Apache License 2.0
Author : krasserm
protected Splitter createSplitterInstance(Expression expression, Processor processor) {
    return new Splitter(expression, processor);
}

19 View Complete Implementation : OrderRouterDebuggerTest.java
Copyright Apache License 2.0
Author : camelinaction
@Override
protected void debugAfter(Exchange exchange, Processor processor, ProcessorDefinition<?> definition, String id, String label, long timeTaken) {
    log.info("MyDebugger: after " + definition + " took " + timeTaken + " ms, with body " + exchange.getIn().getBody());
}

19 View Complete Implementation : CamundaBpmEndpointDefaultImpl.java
Copyright Apache License 2.0
Author : camunda
public Consumer createConsumer(Processor processor) throws Exception {
    return null;
}

19 View Complete Implementation : DummyEndpoint.java
Copyright Apache License 2.0
Author : apache
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    DummyConsumer consumer = new DummyConsumer(this, processor);
    configureConsumer(consumer);
    consumer.setFailOnRestart(failOnRestart);
    return consumer;
}

19 View Complete Implementation : CamelHandler.java
Copyright Apache License 2.0
Author : CenturyLinkCloud
public clreplaced CamelHandler {

    private MdwEndpoint endpoint;

    public MdwEndpoint getEndpoint() {
        return endpoint;
    }

    private Processor processor;

    public Processor getProcessor() {
        return processor;
    }

    public CamelHandler(MdwEndpoint endpoint, Processor processor) {
        this.endpoint = endpoint;
        this.processor = processor;
    }

    protected Exchange prepareCamelExchange(Object request, Map<String, Object> headers) {
        // create a Camel exchange
        Exchange exchange = endpoint.createExchange();
        exchange.setPattern(ExchangePattern.InOut);
        Message inMessage = exchange.getIn();
        if (headers != null) {
            // propagate headers
            for (String key : headers.keySet()) inMessage.setHeader(key, headers.get(key));
        }
        // set the body
        inMessage.setBody(request);
        return exchange;
    }
}

19 View Complete Implementation : OfbizEndpoint.java
Copyright MIT License
Author : bibryam
public Consumer createConsumer(Processor processor) throws Exception {
    throw new UnsupportedOperationException("Consumer not supported for Ofbiz endpoint");
}

19 View Complete Implementation : FlowableEndpoint.java
Copyright Apache License 2.0
Author : flowable
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    return new FlowableConsumer(this, processor);
}

19 View Complete Implementation : DataVecEndpoint.java
Copyright Apache License 2.0
Author : deeplearning4j
public Consumer createConsumer(Processor processor) throws Exception {
    return new DataVecConsumer(this, processor);
}

19 View Complete Implementation : WireTapOnPrepareRoute.java
Copyright Apache License 2.0
Author : CamelCookbook
@Override
public void configure() throws Exception {
    Processor markProcessed = new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader("processorAction", "triggered");
        }
    };
    from("direct:start").wireTap("mock:tapped").onPrepare(markProcessed).to("mock:out");
}

19 View Complete Implementation : K8NatsEndpoint.java
Copyright Apache License 2.0
Author : funktionio
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    return new NatsConsumer(this, processor);
}

19 View Complete Implementation : CamelStreamer.java
Copyright Apache License 2.0
Author : apache
/**
 * Sets the {@link Processor} used to generate the response.
 *
 * @param resProc The {@link Processor}.
 */
public void setResponseProcessor(Processor resProc) {
    this.resProc = resProc;
}

19 View Complete Implementation : OtherTest.java
Copyright Apache License 2.0
Author : garethahealy
@Test
public void camelContextIsNotNull() throws Exception {
    final Map<String, Objects> headers = new HashMap<String, Objects>();
    final Object body = "hello";
    Processor processor = new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            Message in = exchange.getIn();
            in.setBody(body);
            if (headers != null) {
                in.getHeaders().putAll(headers);
            }
        }
    };
    Exchange sent = template.send(processor);
    replacedert.replacedertNotNull(sent.getIn().getBody(String.clreplaced));
    replacedert.replacedertEquals("test", sent.getIn().getBody(String.clreplaced));
}

19 View Complete Implementation : DebugSpringTest.java
Copyright Apache License 2.0
Author : CamelCookbook
@Override
protected void debugBefore(Exchange exchange, Processor processor, ProcessorDefinition<?> definition, String id, String label) {
    // This method is called before each processor step
    // Set your breakpoint here
    log.info("Before {} with body {}", definition, exchange.getIn().getBody());
}

19 View Complete Implementation : WebsocketEndpoint.java
Copyright Apache License 2.0
Author : industrial-data-space
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    ObjectHelper.notNull(component, "component");
    WebsocketConsumer consumer = new WebsocketConsumer(this, processor);
    configureConsumer(consumer);
    return consumer;
}

19 View Complete Implementation : KnativeHttpSupport.java
Copyright Apache License 2.0
Author : apache
/**
 * Removes cloud event headers at the end of the processing.
 */
public static Processor withoutCloudEventHeaders(Processor delegate, CloudEvent ce) {
    return new DelegateAsyncProcessor(delegate) {

        @Override
        public boolean process(Exchange exchange, AsyncCallback callback) {
            return processor.process(exchange, doneSync -> {
                // remove CloudEvent headers
                for (CloudEvent.Attribute attr : ce.attributes()) {
                    exchange.getMessage().removeHeader(attr.http());
                }
                callback.done(doneSync);
            });
        }
    };
}

19 View Complete Implementation : UndertowKeycloakEndpoint.java
Copyright Apache License 2.0
Author : keycloak
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    return new UndertowKeycloakConsumer(this, processor, getDeploymentContext(), getSkipPatternAsPattern(), computeAllowedRoles(), this.confidentialPort);
}

19 View Complete Implementation : MyEndpoint.java
Copyright Apache License 2.0
Author : camelinaction
public Consumer createConsumer(Processor processor) throws Exception {
    return new MyConsumer(this, processor);
}

19 View Complete Implementation : KiePolicy.java
Copyright Apache License 2.0
Author : kiegroup
public Processor wrap(RouteContext routeContext, Processor processor) {
    RouteDefinition routeDef = routeContext.getRoute();
    ToDefinition toKie = getKieNode(routeDef);
    Processor returnedProcessor;
    if (toKie != null) {
        returnedProcessor = new KieProcess(toKie.getUri(), processor);
    } else {
        returnedProcessor = processor;
    }
    return returnedProcessor;
}

19 View Complete Implementation : CbSailEndpoint.java
Copyright Apache License 2.0
Author : apache
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    throw new RuntimeCamelException((new StringBuilder()).append("Cannot consume from a CbSailEndpoint: ").append(getEndpointUri()).toString());
}

19 View Complete Implementation : RouteBuilder.java
Copyright Apache License 2.0
Author : krasserm
public Validation validation(Processor validator) {
    return routeHelper.validation(validator);
}

19 View Complete Implementation : MyCustomLoadBalancer.java
Copyright Apache License 2.0
Author : camelinaction
public void process(Exchange exchange) throws Exception {
    Processor target = chooseProcessor(exchange);
    target.process(exchange);
}

19 View Complete Implementation : AuditDefinition.java
Copyright Apache License 2.0
Author : krasserm
/**
 * @param auditProcessor the auditProcessor to set
 */
public void setAuditProcessor(Processor auditProcessor) {
    this.auditProcessor = auditProcessor;
}

19 View Complete Implementation : TransformRequestConsumer.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
/**
 * Listener for transform request events.
 *
 * @author aepure
 */
@Component
public clreplaced TransformRequestConsumer extends SpringRouteBuilder {

    private static Log logger = LogFactory.getLog(TransformRequestConsumer.clreplaced);

    @Value("${acs.repo.transform.request.endpoint}")
    public String sourceQueue;

    @Autowired
    @Qualifier("transformRequestProcessor")
    private Processor processor;

    // Not restricted for now, should be restricted after performance tests.
    private ExecutorService executorService = Executors.newCachedThreadPool();

    public void setSourceQueue(String sourceQueue) {
        this.sourceQueue = sourceQueue;
    }

    public void setExecutorService(ExecutorService executorService) {
        this.executorService = executorService;
    }

    public void setProcessor(Processor processor) {
        this.processor = processor;
    }

    @Override
    public void configure() {
        if (logger.isDebugEnabled()) {
            logger.debug("Transform Request events route config: ");
            logger.debug("SourceQueue is " + sourceQueue);
        }
        from(sourceQueue).threads().executorService(executorService).process(processor).end();
    }
}

19 View Complete Implementation : DelegateDefinition.java
Copyright Apache License 2.0
Author : krasserm
@Override
public Processor createProcessor(RouteContext routeContext) throws Exception {
    Processor delegate = doCreateDelegate(routeContext);
    Processor next = createChildProcessor(routeContext, false);
    List<Processor> processors = new ArrayList<Processor>();
    processors.add(delegate);
    if (next != null) {
        processors.add(next);
    }
    return Pipeline.newInstance(routeContext.getCamelContext(), processors);
}

19 View Complete Implementation : OrderRouterDebuggerTest.java
Copyright Apache License 2.0
Author : camelinaction
@Override
protected void debugBefore(Exchange exchange, Processor processor, ProcessorDefinition<?> definition, String id, String shortName) {
    log.info("MyDebugger: before " + definition + " with body " + exchange.getIn().getBody());
}

19 View Complete Implementation : ArdulinkEndpoint.java
Copyright Apache License 2.0
Author : Ardulink
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    return new ArdulinkConsumer(this, processor, link);
}

19 View Complete Implementation : TransformRequestConsumer.java
Copyright GNU Lesser General Public License v3.0
Author : Alfresco
public void setProcessor(Processor processor) {
    this.processor = processor;
}

19 View Complete Implementation : MyRoutesWithNestedClass.java
Copyright Apache License 2.0
Author : apache
@Override
public void configure() throws Exception {
    Processor toUpper = new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            String body = exchange.getIn().getBody(String.clreplaced);
            body = body.toUpperCase();
            exchange.getOut().setBody(body);
        }
    };
    from("timer:tick").setBody().constant("test").process(toUpper).to("log:info");
}

19 View Complete Implementation : HystrixMultiConfigurationTest.java
Copyright Apache License 2.0
Author : apache
// **********************************************
// Helper
// **********************************************
private HystrixProcessor findHystrixProcessor(Navigate<Processor> navigate) throws Exception {
    for (Processor processor : navigate.next()) {
        if (processor instanceof HystrixProcessor) {
            return (HystrixProcessor) processor;
        }
        if (processor instanceof Navigate) {
            return findHystrixProcessor((Navigate<Processor>) processor);
        }
    }
    throw new IllegalStateException("Unable to find an HystrixProcessor instance");
}

19 View Complete Implementation : HibersapEndpoint.java
Copyright Apache License 2.0
Author : bjoben
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    throw new UnsupportedOperationException("Not supported yet.");
}

19 View Complete Implementation : KuraCloudEndpoint.java
Copyright Eclipse Public License 1.0
Author : eclipse
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    return new KuraCloudConsumer(this, processor, this.cloudClientHandle.getClient());
}