Package org.switchyard

Examples of org.switchyard.ServiceReference


                qualified.getLocalPart());
    }
   
    @Test
    public void testUnqualifyReference() {
        ServiceReference reference = new ServiceReferenceImpl(
                ComponentNames.qualify(COMPONENT_NAME, SERVICE_NAME), null, null, null);
       
        QName unqualified = ComponentNames.unqualify(reference);
       
        Assert.assertEquals(COMPONENT_NAME.getNamespaceURI(), unqualified.getNamespaceURI());
View Full Code Here


                ServiceInterface refIntf = getComponentReferenceInterface(reference);
                ServiceMetadata metadata = ServiceMetadataBuilder.create()
                        .security(getDomain().getServiceSecurity(reference.getSecurity()))
                        .requiredPolicies(requires).registrant(impl)
                        .build();
                ServiceReference svcRef = getDomain().registerServiceReference(refName, refIntf, null, metadata);

                boolean wired = false;
                // wire a reference if the name is different from promoted name
                compositeReferenceLoop: for (CompositeReferenceModel compositeReference : getConfig().getComposite().getReferences()) {
                    for (ComponentReferenceModel componentReference : compositeReference.getComponentReferences()) {
                        if (componentReference != null && componentReference.equals(reference)) {
                            if (!componentReference.getQName().equals(compositeReference.getQName())) {
                                svcRef.wire(compositeReference.getQName());
                                wired = true;
                                break compositeReferenceLoop;
                            }
                        }
                    }
                }
               
                // if we didn't wire to a promoted reference, then default to unqualified service name
                if (!wired) {
                    svcRef.wire(ComponentNames.unqualify(svcRef));
                }
                references.add(svcRef);
            }
           
            // register a service for each one declared in the component
View Full Code Here

            // Create the reference for the composite service
            ServiceMetadata metadata = ServiceMetadataBuilder.create()
                    .throttling(getCompositeServiceThrottling(service))
                    .registrant(new Binding(service.getBindings()))
                    .build();
            ServiceReference reference = getDomain().registerServiceReference(
                    service.getQName(), getCompositeServiceInterface(service), null, metadata);
           
            int bindingCount = 0;
            for (BindingModel binding : service.getBindings()) {
                ++bindingCount;
View Full Code Here

        exchange.send(exchange.createMessage());
    }
   
    @Test
    public void testInOutMessageTrace() throws Exception {
        ServiceReference service = _domain.createInOutService(
                new QName("InOutTrace"), new MockHandler().forwardInToOut());
        Exchange exchange = service.createExchange(new MockHandler());
        exchange.send(exchange.createMessage());
    }
View Full Code Here

        exchange.send(exchange.createMessage());
    }

    @Test
    public void testInFaultMessageTrace() throws Exception {
        ServiceReference service = _domain.createInOutService(
                new QName("InFaultTrace"), new MockHandler().forwardInToOut());
        Exchange exchange = service.createExchange(new MockHandler());
        exchange.send(exchange.createMessage());
    }
View Full Code Here

    @Test
    public void testStreamContent() throws Exception {
        String contentAsString = "abc-InputStream-xyz";
        MockHandler provider = new MockHandler();
        _domain.getTransformerRegistry().addTransformer(new StreamTransformer());
        ServiceReference service = _domain.createInOnlyService(new QName("StreamTest"), provider);
       
        InputStream contentAsStream = new ByteArrayInputStream(contentAsString.getBytes());
        Exchange ex = service.createExchange();
        Message msg = ex.createMessage();
        msg.setContent(contentAsStream);
        ex.send(msg);

        Message rcvdMsg = provider.getMessages().poll().getMessage();
View Full Code Here

    @Test
    public void testReaderContent() throws Exception {
        String contentAsString = "abc-Reader-xyz";
        MockHandler provider = new MockHandler();
        _domain.getTransformerRegistry().addTransformer(new ReaderTransformer());
        ServiceReference service = _domain.createInOnlyService(new QName("ReaderTest"), provider);
       
        StringReader contentAsReader = new StringReader(contentAsString);
        Exchange ex = service.createExchange();
        Message msg = ex.createMessage();
        msg.setContent(contentAsReader);
        ex.send(msg);

        Message rcvdMsg = provider.getMessages().poll().getMessage();
View Full Code Here

    public void testInOutSuccess() throws Exception {
        final QName serviceName = new QName("inOutSuccess");

        // Provide the service
        MockHandler provider = new MockHandler().forwardInToOut();
        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.waitForOKMessage();
View Full Code Here

    public void testInOutFault() throws Exception {
       
        final QName serviceName = new QName("inOutFault");
        // 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 event) {
          inEvents.add(event);
      }
        };

        ServiceReference service = _domain.createInOnlyService(serviceName, provider);
       
        // Consume the service
        Exchange exchange = service.createExchange();
        exchange.send(exchange.createMessage());
       
        // wait a sec, since this is async
        Thread.sleep(200);
        Assert.assertTrue(inEvents.size() == 1);
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.