Package org.switchyard

Examples of org.switchyard.ExchangeHandler


        exchangeContract.getInvokerInvocationMetaData().setInputType(JavaService.toMessageType(payload.getClass()));

        if (operation.getExchangePattern() == ExchangePattern.IN_OUT) {
            final BlockingQueue<Exchange> responseQueue = new ArrayBlockingQueue<Exchange>(1);

            AtomicReference<ExchangeHandler> responseExchangeHandler = new AtomicReference<ExchangeHandler>(new ExchangeHandler() {
                public void handleMessage(Exchange exchange) throws HandlerException {
                    responseQueue.offer(exchange);
                }

                public void handleFault(Exchange exchange) {
View Full Code Here


     * Make sure that happy path is not impacted by updated logic to screen
     * off "Camel*" exchange properties.
     */
    @Test
    public void testOnExceptionHappyPath() {
        testKit.registerInOutService("Service1", new ExchangeHandler() {
            public void handleFault(Exchange exchange) { }
            public void handleMessage(Exchange exchange) throws HandlerException {
                // check to make sure that when Service1 is called, the correct properties were passed
                Assert.assertEquals("Camel-abc", exchange.getContext().getPropertyValue("Camel-abc"));
                Assert.assertNull(exchange.getContext().getProperty("Camel-123"));
View Full Code Here

    @Override
    public void process(Exchange ex) throws Exception {
        org.switchyard.Exchange syEx = new CamelExchange(ex);

        if (syEx.getState() == ExchangeState.FAULT) {
            ExchangeHandler handler = syEx.getReplyHandler();
            if (handler != null) {
                handler.handleFault(syEx);
            }
        } else {
            // Only call back with reply messages if the MEP is In-Out
            if (ExchangePattern.IN_OUT.equals(syEx.getPattern())) {
                syEx.getReplyHandler().handleMessage(syEx);
View Full Code Here

    @Test
    public void testInOnlySuccess() throws Exception {
        final QName serviceName = new QName("inOnlySuccess");
       
        // Provide the service
        ExchangeHandler provider = new BaseHandler() {
      public void handleMessage(Exchange event) {
          inEvents.add(event);
      }
        };
View Full Code Here

        _camelContext.getWritebleRegistry().put("types", types);
       
        QName inType = new QName("urn:foo", "in");
        QName outType = new QName("urn:bar", "out");

        ExchangeHandler handler = new BaseHandler() {
            @Override
            public void handleMessage(Exchange exchange)
                    throws HandlerException {
                exchange.send(exchange.getMessage().copy());
            }
View Full Code Here

        return false;
    }

    @Override
    public synchronized ExchangeHandler remove(String handlerName) {
        ExchangeHandler handler = null;

        for (HandlerRef ref : _chain) {
            if (ref.getName().equals(handlerName)) {
                handler = ref.getHandler();
                _chain.remove(ref);
View Full Code Here

        final String inMsgContent = "in message";
        final String outMsgContent = "out message";
       
        // create a handler to test that the in and out content match
        // expected result from getMessage()
        ExchangeHandler provider = new BaseHandler() {
            public void handleMessage(Exchange exchange) {
                Assert.assertEquals(
                    exchange.getMessage().getContent(),
                        inMsgContent);
               
                Message outMsg = exchange.createMessage();
                outMsg.setContent(outMsgContent);
                try {
                  exchange.send(outMsg);
                }
                catch (Exception ex) {
                    Assert.fail(ex.toString());
                }
            }
        };

        ExchangeHandler consumer = new BaseHandler() {
            public void handleMessage(Exchange exchange) {
                Assert.assertEquals(
                    exchange.getMessage().getContent(),
                        outMsgContent);
            }
View Full Code Here

    }
   
    @Test
    public void faultChainContinuesOnFault() throws Exception {
        // This goes first and throws an exception - bad handler!
        ExchangeHandler badHandler = new BaseHandler() {
            @Override
            public void handleFault(Exchange exchange) {
                throw new RuntimeException("oops!");
            }
        };
View Full Code Here

        return _operationName == null ? reference.createExchange() : reference.createExchange(_operationName);
    }

    private ExchangeHandlerProxy createHandlerProxy(ExchangeHandler handler) {
        ProxyInvocationHandler proxyInvocationHandler = new ProxyInvocationHandler(handler);
        ExchangeHandler exchangeHandlerProxy = (ExchangeHandler) Proxy.newProxyInstance(ExchangeHandler.class.getClassLoader(),
                                                                                        new Class[]{ExchangeHandler.class},
                                                                                        proxyInvocationHandler);

        return new ExchangeHandlerProxy(proxyInvocationHandler, exchangeHandlerProxy);
    }
View Full Code Here

        switch (exchange.getPhase()) {
        case IN:
            _requestChain.handle(exchange);
            break;
        case OUT:
            ExchangeHandler replyHandler = ((ExchangeImpl)exchange).getReplyHandler();
            if (replyHandler != null) {
                _replyChain.replace(HandlerChain.CONSUMER_HANDLER, replyHandler);
            }
            _replyChain.handle(exchange);
            break;
View Full Code Here

TOP

Related Classes of org.switchyard.ExchangeHandler

Copyright © 2018 www.massapicom. 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.