Package org.switchyard

Examples of org.switchyard.ServiceReference


        _domain.addEventObserver(counter, ExchangeInitiatedEvent.class);
        _domain.addEventObserver(counter, ExchangeCompletionEvent.class);
       
        // send 10 in-only messages and check the counters
        for (int i = 0; i < 10; i++) {
            ServiceReference inOnlyService = _domain.createInOnlyService(new QName("ExchangeEvent-0" + i));
            Exchange inOnly = inOnlyService.createExchange();
            inOnly.send(inOnly.createMessage());
        }
       
        Assert.assertEquals(10, counter.initiatedCount);
        Assert.assertEquals(10, counter.completedCount);
       
        // initialize counters
        counter.initiatedCount = 0;
        counter.completedCount = 0;
       
        // send 10 in-out and check the count
        for (int i = 0; i < 10; i++) {
            ServiceReference inOutService = _domain.createInOutService(
                    new QName("ExchangeEvent-1" + i), new MockHandler().forwardInToOut());
            Exchange inOut = inOutService.createExchange(new MockHandler());
            inOut.send(inOut.createMessage());
        }
       
        Assert.assertEquals(10, counter.initiatedCount);
        Assert.assertEquals(10, counter.completedCount);
View Full Code Here


                    exchange.getMessage().getContent(),
                        outMsgContent);
            }
        };

        ServiceReference service = _domain.createInOutService(serviceName, provider);
        Exchange exchange = service.createExchange(consumer);
        Message inMsg = exchange.createMessage();
        inMsg.setContent(inMsgContent);
        exchange.send(inMsg);
    }
View Full Code Here

    public void testExceptionOnSendOnFaultExchange() throws Exception {

        final QName serviceName = new QName("testExceptionOnSendOnFaultExchange");
        // Provide the service
        MockHandler provider = new MockHandler().forwardInToFault();
        ServiceReference service = _domain.createInOutService(serviceName, provider);

        // Consume the service
        MockHandler consumer = new MockHandler();
        Exchange exchange = service.createExchange(consumer);
        exchange.send(exchange.createMessage());

        // wait, since this is async
        provider.waitForOKMessage();
        consumer.waitForFaultMessage();
View Full Code Here

            public void handleMessage(Exchange exchange) throws HandlerException {
                throw new HandlerException("explode");
            }
        };

        ServiceReference service = _domain.createInOutService(serviceName, provider);

        try {
            // Don't provide a consumer...
            service.createExchange();
            Assert.fail("Should not be able to create an InOut without specifying a reply handler");
        } catch (RuntimeException e) {
            // exception expected
        }
    }
View Full Code Here

            public void handleMessage(Exchange exchange) throws HandlerException {
                throw new HandlerException("explode");
            }
        };

        ServiceReference service = _domain.createInOnlyService(serviceName, provider);

        // Don't provide a consumer...
        Exchange exchange = service.createExchange();

        exchange.send(exchange.createMessage());
    }
View Full Code Here

            @Override
            public void handleMessage(Exchange exchange) throws HandlerException {
                throw new HandlerException("Fault With No Handler!");
            }
        };
        ServiceReference service = _domain.createInOnlyService(serviceName, provider);

        // Consume the service
        Exchange exchange = service.createExchange();
        exchange.send(exchange.createMessage());

        // Make sure the exchange is in fault status
        Assert.assertEquals(ExchangeState.FAULT, exchange.getState());
    }
View Full Code Here

                JavaTypes.toMessageType(String.class),   // input
                JavaTypes.toMessageType(String.class),   // output
                JavaTypes.toMessageType(String.class))// fault
        _domain.registerService(serviceName, new InOutService(providerContract), provider);
        _domain.getTransformerRegistry().addTransformer(new ExceptionToStringTransformer());
        ServiceReference service = _domain.registerServiceReference(serviceName, new InOutService(consumerContract));

        // Consume the service
        Exchange exchange = service.createExchange(new MockHandler());
        exchange.send(exchange.createMessage());

        // Make sure the exchange is in fault status
        Assert.assertEquals(String.class, exchange.getMessage().getContent().getClass());
        Assert.assertEquals(exchange.getMessage().getContent(), "testFaultTransformSequence");
View Full Code Here

       
        _chain.addFirst("first", badHandler);
        _chain.addLast("second", goodHandler);

        MockDomain domain = new MockDomain();
        ServiceReference reference = domain.createInOnlyService(new QName("bar"));
        Dispatcher dispatch = domain.getBus().createDispatcher(reference);
        Exchange ex = new ExchangeImpl(domain, dispatch).consumer(reference, new InOnlyOperation("foo"));
        _chain.handleFault(ex);
        Assert.assertNotNull(goodHandler.waitForFaultMessage());
    }
View Full Code Here

    }

    private Exchange createExchange(ExchangePattern pattern, ExchangeHandler handler) {
       
        ServiceOperation operation = _serviceOperation;
        ServiceReference reference;
       
        if (operation == null) {
            if (ExchangePattern.IN_ONLY.equals(pattern)) {
                operation = new InOnlyOperation(_operationName, _inputType);
            } else {
                operation = new InOutOperation(_operationName, _inputType, _expectedOutputType, _expectedFaultType);
            }
        }
       
        reference = _domain.registerServiceReference(_serviceName, new BaseService(operation), handler);
        return _operationName == null ? reference.createExchange() : reference.createExchange(_operationName);
    }
View Full Code Here

            source = Source.PROVIDER;
            serviceDomain = service.getDomain();
            serviceSecurity = service.getServiceMetadata().getSecurity();
        }
        if (serviceSecurity == null) {
            ServiceReference serviceReference = exchange.getConsumer();
            if (serviceReference != null) {
                source = Source.CONSUMER;
                serviceDomain = serviceReference.getDomain();
                serviceSecurity = serviceReference.getServiceMetadata().getSecurity();
            }
        }
        return new SecurityMetadata(source, serviceDomain, serviceSecurity);
    }
View Full Code Here

TOP

Related Classes of org.switchyard.ServiceReference

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.