Package org.apache.tuscany.sca.assembly

Examples of org.apache.tuscany.sca.assembly.Component


        CompositeActivator compositeActivator = runtime.getCompositeActivator();
        compositeActivator.start(component);
    }

    public void stopComponent(String componentName) throws ActivationException {
        Component component = getComponent(componentName);
        if (component == null) {
            throw new IllegalArgumentException("no component: " + componentName);
        }
        CompositeActivator compositeActivator = runtime.getCompositeActivator();
        compositeActivator.stop(component);
View Full Code Here


            serviceName = null;
        }

        // Lookup the component in the domain
       
        Component component = null;
       
        for (Composite composite: nodeComposite.getIncludes()) {
            for (Component componentLoop: composite.getComponents()) {
                if (componentLoop.getName().equals(componentName)) {
                    component = componentLoop;
                    break;
                }
            }
        }       
        if (component == null) {
            // The component is not local in the partition, try to create a remote service ref
            return createServiceReference(businessInterface, name);
        }
        RuntimeComponentContext componentContext = null;

        // If the component is a composite, then we need to find the
        // non-composite component that provides the requested service
        if (component.getImplementation() instanceof Composite) {
            for (ComponentService componentService : component.getServices()) {
                if (serviceName == null || serviceName.equals(componentService.getName())) {
                    CompositeService compositeService = (CompositeService)componentService.getService();
                    if (compositeService != null) {
                        if (serviceName != null) {
                            serviceName = "$promoted$." + component.getName() + "." + serviceName;
                        }
                        componentContext =
                            ((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext();
                        return componentContext.createSelfReference(businessInterface, compositeService
                            .getPromotedService());
View Full Code Here

            componentName = name;
            serviceName = null;
        }

        // Lookup the component in the domain
        Component component = componentManager.getComponent(componentName);
        if (component == null) {
            // The component is not local in the partition, try to create a remote service ref
            return createServiceReference(businessInterface, name);
        }
        RuntimeComponentContext componentContext = null;

        // If the component is a composite, then we need to find the
        // non-composite component that provides the requested service
        if (component.getImplementation() instanceof Composite) {
            for (ComponentService componentService : component.getServices()) {
                if (serviceName == null || serviceName.equals(componentService.getName())) {
                    CompositeService compositeService = (CompositeService)componentService.getService();
                    if (compositeService != null) {
                        if (serviceName != null) {
                            serviceName = "$promoted$." + component.getName() + "." + serviceName;
                        }
                        componentContext =
                            ((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext();
                        return componentContext.createSelfReference(businessInterface, compositeService
                            .getPromotedService());
View Full Code Here

    }

    private void checkScenario1Results(boolean nonWiring) {
        Composite domainComposite = customBuilder.getDomainComposite();

        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        if (!nonWiring) {
            // Should create component service $promoted$.Service1 on innermost component
            //  ComponentD, with <binding.ws> and uri="/Service1"
            // No other services on ComponentD should have <binding.ws>
            WebServiceBinding wsBinding = null;
            for (ComponentService service : componentD.getServices()) {
                WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
                if ("$promoted$.Service1".equals(service.getName())) {
                    wsBinding = wsb;
                } else {
                    assert wsb == null;
                }
            }
            assert "/Service1".equals(wsBinding.getURI());

            // Should create WSDL document for ComponentD/$promoted$.Service1 with endpoint uri="/Service1"
            Definition def = wsBinding.getWSDLDocument();
            javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
            Port port = svc.getPort("Service3Port");
            assert "/Service1".equals(TestUtils.getPortAddress(port));
        } else {
            // Should not create component service $promoted$.Service1 on innermost component ComponentD
            // No component services on ComponentD should have <binding.ws>
            for (ComponentService service : componentD.getServices()) {
                assert !"$promoted$.Service1".equals(service.getName());
                assert service.getBinding(WebServiceBinding.class) == null;
            }
        }

        // No services on ComponentB should have <binding.ws>
        Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
        for (ComponentService service : componentB.getServices()) {
            assert service.getBinding(WebServiceBinding.class) == null;
        }

        // No services on CompositeC should have <binding.ws>
        Composite compositeC = TestUtils.getComposite(domainComposite, new QName("http://scenario1", "CompositeC"));
View Full Code Here

    private void checkScenario2and3Results(String namespace, boolean nonWiring) {
        Composite domainComposite = customBuilder.getDomainComposite();

        // Should create WSDL document for ComponentB/Service2 with endpoint uri="/ComponentB/Service2"
        // No other services on ComponentB should have <binding.ws>
        Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
        WebServiceBinding wsBinding = null;
        for (ComponentService service : componentB.getServices()) {
            WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
            if ("Service2".equals(service.getName())) {
                wsBinding = wsb;
            } else {
                assert wsb == null;
            }
        }
        Definition def = wsBinding.getWSDLDocument();
        javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
        Port port = svc.getPort("Service3Port");
        assert "/ComponentB/Service2".equals(TestUtils.getPortAddress(port));

        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        if (!nonWiring) {
            // Should create component service $promoted$.ComponentB.Service2 on innermost component
            //  ComponentD, with <binding.ws> and uri="/ComponentB/Service2"
            wsBinding = null;
            for (ComponentService service : componentD.getServices()) {
                if ("$promoted$.ComponentB.Service2".equals(service.getName())) {
                    wsBinding = service.getBinding(WebServiceBinding.class);
                }
            }
            assert "/ComponentB/Service2".equals(wsBinding.getURI());

            // Should create WSDL document for ComponentD/$promoted$.ComponentB.Service2 with endpoint uri="/ComponentB/Service2"
            def = wsBinding.getWSDLDocument();
            svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
            port = svc.getPort("Service3Port");
            assert "/ComponentB/Service2".equals(TestUtils.getPortAddress(port));
        } else {
            // Should not create component service $promoted$.ComponentB.Service2 on innermost component ComponentD
            for (ComponentService service : componentD.getServices()) {
                assert !"$promoted$.ComponentB.Service2".equals(service.getName());
            }
        }

        // Should add <binding.ws> to outer composite service CompositeA/Service1
        wsBinding = null;
        for (Service service : domainComposite.getServices()) {
            if ("Service1".equals(service.getName())) {
                wsBinding = service.getBinding(WebServiceBinding.class);
            }
        }
        assert wsBinding != null;
        if (nonWiring) {
            // Should not add a WSDL document to domain composite service Service1
            assert wsBinding.getWSDLDocument() == null;
        }

        if (!nonWiring) {
            // Should create component service $promoted$.Service1 on innermost component
            //  ComponentD, with <binding.ws> and uri="/Service1"
            wsBinding = null;
            for (ComponentService service : componentD.getServices()) {
                if ("$promoted$.Service1".equals(service.getName())) {
                    wsBinding = service.getBinding(WebServiceBinding.class);
                }
            }
            assert "/Service1".equals(wsBinding.getURI());

            // Should create WSDL document for ComponentD/$promoted$.Service1 with endpoint uri="/Service1"
            def = wsBinding.getWSDLDocument();
            svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
            port = svc.getPort("Service3Port");
            assert "/Service1".equals(TestUtils.getPortAddress(port));
        } else {
            // Should not create component service $promoted$.Service1 on innermost component ComponentD
            for (ComponentService service : componentD.getServices()) {
                assert !"$promoted$.Service1".equals(service.getName());
            }
        }

        // No services on ComponentD should have <binding.ws>, except for $promoted$.Service1
        // and $promoted$.ComponentB.Service2 
        for (ComponentService service : componentD.getServices()) {
            if (!"$promoted$.Service1".equals(service.getName()) &&
                !"$promoted$.ComponentB.Service2".equals(service.getName())) {
                assert service.getBinding(WebServiceBinding.class) == null;
            }
        }
View Full Code Here

    private void checkScenario4Results(boolean nonWiring) {
        Composite domainComposite = customBuilder.getDomainComposite();

        // Should create WSDL document for ComponentD/Service3 with endpoint uri="/ComponentD/Service3"
        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        WebServiceBinding wsBinding = null;
        for (ComponentService service : componentD.getServices()) {
            if ("Service3".equals(service.getName())) {
                wsBinding = service.getBinding(WebServiceBinding.class);
            }
        }
        Definition def = wsBinding.getWSDLDocument();
        javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
        Port port = svc.getPort("Service3Port");
        assert "/ComponentB/ComponentD/Service3".equals(TestUtils.getPortAddress(port));

        // Should add <binding.ws> to inner composite service CompositeC/Service2
        // No other services on CompositeC should have <binding.ws>
        Composite compositeC = TestUtils.getComposite(domainComposite, new QName("http://scenario4", "CompositeC"));
        wsBinding = null;
        for (Service service : compositeC.getServices()) {
            WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
            if ("Service2".equals(service.getName())) {
                wsBinding = wsb;
            } else {
                assert wsb == null;
            }
        }
        assert "/ComponentB/Service2".equals(wsBinding.getURI());

        // Should add <binding.ws> to outer component service ComponentB/Service2
        // Should create WSDL document for ComponentB/Service2 with endpoint uri="/ComponentB/Service2"
        // No other services on ComponentB should have <binding.ws>
        Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
        wsBinding = null;
        for (ComponentService service : componentB.getServices()) {
            WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
            if ("Service2".equals(service.getName())) {
                wsBinding = wsb;
            } else {
                assert wsb == null;
View Full Code Here

    private void checkScenario5Results(boolean nonWiring) {
        Composite domainComposite = customBuilder.getDomainComposite();

        // Should not add <binding.ws> to any outer component references
        Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
        for (ComponentReference reference : componentB.getReferences()) {
            assert reference.getBinding(WebServiceBinding.class) == null;
        }

        Definition def;
        javax.wsdl.Service svc;
        Port port;
        WebServiceBinding wsBinding;
        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        if (!nonWiring) {
            // Should add <binding.ws> to inner component reference ComponentD/reference3 with uri="http://foo.com/bar"
            // Should set <interface.wsdl> on inner component reference ComponentD/reference3
            wsBinding = null;
            for (ComponentReference reference : componentD.getReferences()) {
                if ("reference3".equals(reference.getName())) {
                    wsBinding = reference.getBinding(WebServiceBinding.class);
                    assert reference.getInterfaceContract(wsBinding) instanceof WSDLInterfaceContract;
                }
            }
            assert "http://foo.com/bar".equals(wsBinding.getURI());

            // Should create WSDL document for ComponentD/reference3 with endpoint uri="http://foo.com/bar"
            def = wsBinding.getWSDLDocument();
            svc = def.getService(new QName("http://scenarios/ComponentD/reference3", "Service3aService"));
            port = svc.getPort("Service3aPort");
            assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
        } else {
            // Should not add <binding.ws> to any inner component references
            for (ComponentReference reference : componentD.getReferences()) {
                assert reference.getBinding(WebServiceBinding.class) == null;
            }
        }

        // Should not add <binding.ws> or <interface.wsdl> to inner composite reference CompositeC/reference2
View Full Code Here

        // Should remove target= on ComponentB/reference2 (for Scenario 6) or
        //  CompositeC/reference2 (for Scenario 7), and add uri="http://foo.com/bar"
        //  to the <binding.ws> element on ComponentB/reference2
        // For nonWiring, ComponentB/reference2 should have target=
        //  and no uri= should be added
        Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
        WebServiceBinding wsBinding = null;
        for (ComponentReference reference : componentB.getReferences()) {
            if ("reference2".equals(reference.getName())) {
                if (!nonWiring) {
                    assert reference.getTargets().size() == 0;
                } else {
                    assert reference.getTargets().size() == 1;
                }
                wsBinding = reference.getBinding(WebServiceBinding.class);
            }
        }
        if (!nonWiring) {
            assert "http://foo.com/bar".equals(wsBinding.getURI());
        } else {
            assert wsBinding.getURI() == null;
        }

        Definition def;
        javax.wsdl.Service svc;
        Port port;
        if (!nonWiring) {
            // Should create WSDL document for ComponentB/reference2 with endpoint uri="http://foo.com/bar"
            def = wsBinding.getWSDLDocument();
            svc = def.getService(new QName("http://scenarios/ComponentB/reference2", "Service3aService"));
            port = svc.getPort("Service3aPort");
            assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
        }

        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        if (!nonWiring) {
            // Should add <binding.ws> to inner component reference ComponentD/reference3 with uri="http://foo.com/bar"
            // Should set <interface.wsdl> on inner component reference ComponentD/reference3
            wsBinding = null;
            for (ComponentReference reference : componentD.getReferences()) {
                if ("reference3".equals(reference.getName())) {
                    wsBinding = reference.getBinding(WebServiceBinding.class);
                    assert reference.getBindings().size() == 1;
                    assert reference.getInterfaceContract(wsBinding) instanceof WSDLInterfaceContract;
                }
            }
            assert "http://foo.com/bar".equals(wsBinding.getURI());

            // Should create WSDL document for ComponentD/reference3 with endpoint uri="http://foo.com/bar"
            def = wsBinding.getWSDLDocument();
            svc = def.getService(new QName("http://scenarios/ComponentB/reference2", "Service3aService"));
            port = svc.getPort("Service3aPort");
            assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
        } else {
            // Should not add <binding.ws> to any inner component references
            for (ComponentReference reference : componentD.getReferences()) {
                assert reference.getBinding(WebServiceBinding.class) == null;
            }
        }

        // No references on CompositeC should have <binding.ws> or <interface.wsdl>, except for
View Full Code Here

    private void checkScenario8Results(boolean nonWiring) {
        Composite domainComposite = customBuilder.getDomainComposite();

        // Should replace target= on ComponentD/reference3 by uri="http://foo.com/bar" on <binding.ws>
        // For nonWiring, the original target= is preserved and there is no uri=
        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        WebServiceBinding wsBinding = null;
        for (ComponentReference reference : componentD.getReferences()) {
            if ("reference3".equals(reference.getName())) {
                if (!nonWiring) {
                    assert reference.getTargets().size() == 0;
                } else {
                    assert reference.getTargets().size() == 1;
                }
                wsBinding = reference.getBinding(WebServiceBinding.class);
            }
        }
        if (!nonWiring) {
            assert "http://foo.com/bar".equals(wsBinding.getURI());
        } else {
            assert wsBinding.getURI() == null;
        }

        Definition def;
        javax.wsdl.Service svc;
        Port port;
        if (!nonWiring) {
            // Should create WSDL document for ComponentD/reference3 with endpoint uri="http://foo.com/bar"
            def = wsBinding.getWSDLDocument();
            svc = def.getService(new QName("http://scenarios/ComponentD/reference3", "Service3aService"));
            port = svc.getPort("Service3aPort");
            assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
        }

        // Should add <binding.ws> and <interface.wsdl> to inner composite reference CompositeC/reference2
        Composite compositeC = TestUtils.getComposite(domainComposite, new QName("http://scenario8", "CompositeC"));
        wsBinding = null;
        for (Reference reference : compositeC.getReferences()) {
            if ("reference2".equals(reference.getName())) {
                wsBinding = reference.getBinding(WebServiceBinding.class);
                assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
            }
        }
        assert wsBinding.getURI() == null;

        // Should add <binding.ws> and <interface.wsdl> to outer component reference ComponentB/reference2
        Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
        wsBinding = null;
        for (ComponentReference reference : componentB.getReferences()) {
            if ("reference2".equals(reference.getName())) {
                wsBinding = reference.getBinding(WebServiceBinding.class);
                assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
            }
        }
View Full Code Here

    }   

    private void checkScenario9Results() {
        Composite domainComposite = customBuilder.getDomainComposite();

        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        ComponentReference componentRef = null;
        for (ComponentReference reference : componentD.getReferences()) {
            if ("reference3a".equals(reference.getName())) {
                componentRef = reference;
                assertTrue(reference.getBindings().size() == 2);
                assertTrue(reference.getBindings().get(0) instanceof SCABinding);
                assertTrue(reference.getBindings().get(1) instanceof WebServiceBinding);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.assembly.Component

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.