Package org.apache.camel

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


        Exchange exchange = createExchangeWithBody(new DefaultCamelContext(), "body");
        Message out = new DefaultMessage();
        out.setBody(new Object());
        Processor processor = new UnmarshalProcessor(new MyDataFormat(out));

        processor.process(exchange);
        assertSame("UnmarshalProcessor did not make use of the returned OUT message", out, exchange.getOut());
        assertSame("UnmarshalProcessor did change the body bound to the OUT message", out.getBody(), exchange.getOut().getBody());
    }

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


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

        processor.process(exchange);
        assertSame("UnmarshalProcessor did not make use of the returned object being returned while unmarshalling", unmarshalled, exchange.getOut().getBody());
    }

    private static class MyDataFormat implements DataFormat {
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 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

        if (processor != null) {
            try {
                // must process the incoming exchange and NOT the copy as the idea
                // is the end user can manipulate the exchange
                processor.process(exchange);
            } catch (Exception e) {
                // set exceptions on exchange so we can throw exceptions to simulate errors
                exchange.setException(e);
            }
        }
View Full Code Here

                if (processor instanceof AsyncProcessor) {
                    AsyncProcessor async = (AsyncProcessor) processor;
                    return async.process(exchange, callback);
                } else {
                    try {
                        processor.process(exchange);
                    } catch (Exception e) {
                        exchange.setException(e);
                    }
                    callback.done(true);
                    return true;
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 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

    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

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

        processor.process(exchange);

        Exception e = exchange.getException();
        assertNotNull(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.