Package org.apache.tuscany.sca.assembly

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


        clone.components = new ArrayList<Component>();
        for (Component component : getComponents()) {
            Component clonedComponent = (Component)component.clone();
            for (Service service : clone.getServices()) {
                CompositeService compositeService = (CompositeService)service;
                // Force the promoted component/service to be rebuilt against the clone
                if (compositeService.getPromotedComponent() != null) {
                    compositeService.getPromotedComponent().setUnresolved(true);
                }
                if (compositeService.getPromotedService() != null) {
                    compositeService.getPromotedService().setUnresolved(true);
                }
            }
            for (Reference reference : clone.getReferences()) {
                CompositeReference compositeReference = (CompositeReference)reference;
                for (ComponentReference ref : compositeReference.getPromotedReferences()) {
View Full Code Here


        Wire w = factory.createWire();
        w.setSource(c1.getReferences().get(0));
        w.setTarget(c2.getServices().get(0));
        c.getWires().add(w);

        CompositeService cs = factory.createCompositeService();
        cs.setName("AccountService");
        cs.setPromotedService(c1.getServices().get(0));
        cs.setInterfaceContract(new TestInterfaceContract(factory));
        c.getServices().add(cs);
        cs.getBindings().add(new TestBinding(factory));

        CompositeReference cr = factory.createCompositeReference();
        cr.setName("StockQuoteService");
        cr.getPromotedReferences().add(c2.getReferences().get(1));
        cr.setInterfaceContract(new TestInterfaceContract(factory));
View Full Code Here

   
    private Composite createTopLevelCompositeServiceBinding(){
        Composite composite1 = assemblyFactory.createComposite();
        composite1.setName(new QName("http://foo", "C1"));
       
        CompositeService s1 = assemblyFactory.createCompositeService();
        s1.setName("s1");
        composite1.getServices().add(s1);
       
        Binding b1 = new TestBindingImpl();
        s1.getBindings().add(b1);
       
        CompositeService s2 = assemblyFactory.createCompositeService();
        s2.setName("s2");
        composite1.getServices().add(s2);
       
        Binding b2 = new TestBindingImpl();
        s2.getBindings().add(b2);
       
        return composite1;
    }
View Full Code Here

        assertEquals(((PolicySetAttachPoint)composite).getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));

        Composite include = composite.getIncludes().get(0);
        assertEquals(include.getName(), new QName("http://calc", "TestAllDivide"));

        CompositeService calcCompositeService = (CompositeService)composite.getServices().get(0);
        assertEquals(calcCompositeService.getName(), "CalculatorService");
        assertTrue(calcCompositeService.getPromotedService().isUnresolved());
        assertEquals(calcCompositeService.getPromotedService().getName(),
                     "CalculatorService");
        assertEquals(calcCompositeService.getRequiredIntents().get(0).getName(),
                     new QName("http://test", "confidentiality"));
        assertEquals(calcCompositeService.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
        // TODO test operations
        Callback calcServiceCallback = calcCompositeService.getCallback();
        assertNotNull(calcServiceCallback);
        assertEquals(calcServiceCallback.getRequiredIntents().get(0).getName(),
                     new QName("http://test", "confidentiality"));
        assertEquals(calcServiceCallback.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
        // TODO test operations
View Full Code Here

        // 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$." + serviceName;
                        }
                        componentContext =
                            ((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext();
                        return componentContext.createSelfReference(businessInterface, compositeService.getPromotedService());
                    }
                    break;
                }
            }
            // No matching service found
View Full Code Here

        // 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$." + serviceName;
                        }
                        componentContext =
                            ((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext();
                        return componentContext.createSelfReference(businessInterface, compositeService
                            .getPromotedService());
                    }
                    break;
                }
            }
View Full Code Here

        Component component = null;
        Property property = null;
        ComponentService componentService = null;
        ComponentReference componentReference = null;
        ComponentProperty componentProperty = null;
        CompositeService compositeService = null;
        CompositeReference compositeReference = null;
        Contract contract = null;
        Wire wire = null;
        Callback callback = null;
        QName name = null;

        // Read the composite document
        while (reader.hasNext()) {
            int event = reader.getEventType();
            switch (event) {
                case START_ELEMENT:
                    name = reader.getName();

                    if (COMPOSITE_QNAME.equals(name)) {

                        // Read a <composite>
                        composite = assemblyFactory.createComposite();
                        composite.setName(new QName(getString(reader, TARGET_NAMESPACE), getString(reader, NAME)));
                        if(isSet(reader, AUTOWIRE)) {
                            composite.setAutowire(getBoolean(reader, AUTOWIRE));
                        }
                        composite.setLocal(getBoolean(reader, LOCAL));
                        composite.setConstrainingType(readConstrainingType(reader));
                        policyProcessor.readPolicies(composite, reader);

                    } else if (INCLUDE_QNAME.equals(name)) {

                        // Read an <include>
                        include = assemblyFactory.createComposite();
                        include.setName(getQName(reader, NAME));
                        include.setURI(getString(reader, URI));
                        include.setUnresolved(true);
                        composite.getIncludes().add(include);

                    } else if (SERVICE_QNAME.equals(name)) {
                        if (component != null) {

                            // Read a <component><service>
                            componentService = assemblyFactory.createComponentService();
                            contract = componentService;
                            componentService.setName(getString(reader, NAME));
                            component.getServices().add(componentService);
                            policyProcessor.readPolicies(contract, reader);
                        } else {

                            // Read a <composite><service>
                            compositeService = assemblyFactory.createCompositeService();
                            contract = compositeService;
                            compositeService.setName(getString(reader, NAME));

                            String promoted = getString(reader, PROMOTE);
                            String promotedComponentName;
                            String promotedServiceName;
                            int s = promoted.indexOf('/');
                            if (s == -1) {
                                promotedComponentName = promoted;
                                promotedServiceName = null;
                            } else {
                                promotedComponentName = promoted.substring(0, s);
                                promotedServiceName = promoted.substring(s + 1);
                            }

                            Component promotedComponent = assemblyFactory.createComponent();
                            promotedComponent.setUnresolved(true);
                            promotedComponent.setName(promotedComponentName);
                            compositeService.setPromotedComponent(promotedComponent);

                            ComponentService promotedService = assemblyFactory.createComponentService();
                            promotedService.setUnresolved(true);
                            promotedService.setName(promotedServiceName);
                            compositeService.setPromotedService(promotedService);

                            composite.getServices().add(compositeService);
                            policyProcessor.readPolicies(contract, reader);
                        }
View Full Code Here

            writeEnd(writer);
        }

        // Write <service> elements
        for (Service service : composite.getServices()) {
            CompositeService compositeService = (CompositeService)service;
            Component promotedComponent = compositeService.getPromotedComponent();
            ComponentService promotedService = compositeService.getPromotedService();
            String promote;
            if (promotedService != null) {
                if (promotedService.getName() != null) {
                    promote = promotedComponent.getName() + '/' + promotedService.getService();
                } else {
View Full Code Here

        // Process nested composites recursively
        activateNestedCompositeServices(composite);

        // Process top level composite services
        for (Service service : composite.getServices()) {
            CompositeService compositeService = (CompositeService)service;

            // Get the inner most promoted service
            ComponentService promotedService = getPromotedComponentService(compositeService);
            if (promotedService != null) {
                Component promotedComponent = getPromotedComponent(compositeService);

                // Default to use the interface from the promoted service
                if (compositeService.getInterfaceContract() == null && promotedService.getInterfaceContract() != null) {
                    compositeService.setInterfaceContract(promotedService.getInterfaceContract());
                }

                // Create a new component service to represent this composite
                // service on the promoted component
                ComponentService newComponentService = assemblyFactory.createComponentService();
                newComponentService.setName("$promoted$." + compositeService.getName());
                promotedComponent.getServices().add(newComponentService);
                newComponentService.setService(promotedService.getService());
                newComponentService.getBindings().addAll(compositeService.getBindings());
                newComponentService.setInterfaceContract(compositeService.getInterfaceContract());
                if (compositeService.getInterfaceContract() != null && compositeService
                    .getInterfaceContract().getCallbackInterface() != null) {
                    newComponentService.setCallback(assemblyFactory.createCallback());
                    if (compositeService.getCallback() != null) {
                        newComponentService.getCallback().getBindings().addAll(compositeService
                            .getCallback().getBindings());
                    }
                }

                // Change the composite service to now promote the newly
                // created component service directly
                compositeService.setPromotedComponent(promotedComponent);
                compositeService.setPromotedService(newComponentService);
            }
        }
    }
View Full Code Here

                // Process the component services declared on components
                // in this composite
                for (ComponentService componentService : component.getServices()) {
                    Service implService = componentService.getService();
                    if (implService != null && implService instanceof CompositeService) {
                        CompositeService compositeService = (CompositeService)implService;

                        // Get the inner most promoted service
                        ComponentService promotedService =
                            getPromotedComponentService(compositeService);
                        if (promotedService != null) {
                            Component promotedComponent = getPromotedComponent(compositeService);

                            // Default to use the interface from the promoted
                            // service
                            if (compositeService.getInterfaceContract() == null) {
                                compositeService.setInterfaceContract(promotedService
                                    .getInterfaceContract());
                            }
                            if (componentService.getInterfaceContract() == null) {
                                componentService.setInterfaceContract(promotedService
                                    .getInterfaceContract());
                            }

                            // Create a new component service to represent this
                            // composite service on the promoted component
                            ComponentService newComponentService =
                                assemblyFactory.createComponentService();
                            newComponentService.setName("$promoted$." + compositeService.getName());
                            promotedComponent.getServices().add(newComponentService);
                            newComponentService.setService(promotedService.getService());
                            newComponentService.getBindings()
                                .addAll(compositeService.getBindings());
                            newComponentService.setInterfaceContract(compositeService
                                .getInterfaceContract());
                            if (compositeService.getInterfaceContract() != null && compositeService
                                .getInterfaceContract().getCallbackInterface() != null) {
                                newComponentService.setCallback(assemblyFactory.createCallback());
                                if (compositeService.getCallback() != null) {
                                    newComponentService.getCallback().getBindings()
                                        .addAll(compositeService.getCallback().getBindings());
                                }
                            }

                            // Change the composite service to now promote the
                            // newly created component service directly
                            compositeService.setPromotedComponent(promotedComponent);
                            compositeService.setPromotedService(newComponentService);
                        }
                    }
                }
            }
        }
View Full Code Here

TOP

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

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.