Package org.apache.camel

Examples of org.apache.camel.Processor.process()


        Processor processor = chooseProcessor(list, exchange);
        if (processor == null) {
            throw new IllegalStateException("No processors could be chosen to process " + exchange);
        }
        else {
            processor.process(exchange);
        }
    }

    protected abstract Processor chooseProcessor(List<Processor> processors, Exchange exchange);
}
View Full Code Here


    }

    protected void processEntity(Exchange exchange, T entity) throws Exception {
        if (entity instanceof Processor) {
            Processor processor = (Processor) entity;
            processor.process(exchange);
        }
        else {
            // TODO add other extension points - eg. passing in Activity
            throw new IllegalArgumentException("No processor defined for this route");
        }
View Full Code Here

            ActivityState secondState = activityState;
            Date overdue = secondState.getTimeOverdue();
            if (now.compareTo(overdue) >= 0) {
                Exchange exchange = createExchange();
                exchange.getIn().setBody(activityState);
                processor.process(exchange);
            }
            else {
                log.warn("Process has not actually expired; the time is: " + now + " but the overdue time is: " + overdue);
            }
        }
View Full Code Here

    protected boolean customProcessorForException(Exchange exchange, Throwable exception) throws Exception {
        OnExceptionDefinition policy = getExceptionPolicy(exchange, exception);
        if (policy != null) {
            Processor processor = policy.getErrorHandler();
            if (processor != null) {
                processor.process(exchange);
                return true;
            }
        }
        return false;
    }
View Full Code Here

        exchange.getIn().setBody("Hello World");

        CamelConverter cc = new CamelConverter();
        Processor pro = cc.toProcessor(exp);

        pro.process(exchange);

        assertEquals("bar", exchange.getOut().getBody());
    }

    public void testToProcessorPredicate() throws Exception {
View Full Code Here

        exchange.getIn().setBody("Hello World");

        CamelConverter cc = new CamelConverter();
        Processor pro = cc.toProcessor(pred);

        pro.process(exchange);

        assertEquals(true, exchange.getOut().getBody());
    }
}
View Full Code Here

        // should not be invoked if an explicit method has been set
        Processor processor = getProcessor();
        if (explicitMethodName == null && processor != null) {
            LOG.trace("Using a custom adapter as bean invocation: {}", processor);
            try {
                processor.process(exchange);
            } catch (Throwable e) {
                exchange.setException(e);
            }
            callback.done(true);
            return true;
View Full Code Here

    protected boolean customProcessorForException(Exchange exchange, Throwable exception) throws Exception {
        OnExceptionDefinition policy = getExceptionPolicy(exchange, exception);
        if (policy != null) {
            Processor processor = policy.getErrorHandler();
            if (processor != null) {
                processor.process(exchange);
                return true;
            }
        }
        return false;
    }
View Full Code Here

    public void testDataFormatReturnsSameExchange() throws Exception {
        Exchange exchange = createExchangeWithBody(new DefaultCamelContext(), "body");
        Processor processor = new UnmarshalProcessor(new MyDataFormat(exchange));

        processor.process(exchange);

        assertEquals("UnmarshalProcessor did not copy OUT from IN message", "body", exchange.getOut().getBody());
    }

    public void testDataFormatReturnsAnotherExchange() throws Exception {
View Full Code Here

        Exchange exchange = createExchangeWithBody(context, "body");
        Exchange exchange2 = createExchangeWithBody(context, "body2");
        Processor processor = new UnmarshalProcessor(new MyDataFormat(exchange2));

        try {
            processor.process(exchange);
            fail("Should have thrown exception");
        } catch (RuntimeCamelException e) {
            assertEquals("The returned exchange " + exchange2 + " is not the same as " + exchange + " provided to the DataFormat", e.getMessage());
        }
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.