Package org.apache.tuscany.sca.assembly

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


            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.getName();
                } else {
View Full Code Here


            }
        }

        // Add model resolver to promoted components
        for (Service service : composite.getServices()) {
            CompositeService compositeService = (CompositeService)service;
            Component promotedComponent = compositeService.getPromotedComponent();
            if (promotedComponent instanceof ResolverExtension) {
                ((ResolverExtension)promotedComponent).setModelResolver(resolver);
            }
        }
    }
View Full Code Here

        }
   
        // Connect composite services to the component services that they
        // promote
        for (Service service : composite.getServices()) {
            CompositeService compositeService = (CompositeService)service;
            ComponentService componentService = compositeService.getPromotedService();
            if (componentService != null && componentService.isUnresolved()) {
               
                String promotedComponentName = compositeService.getPromotedComponent().getName();
                String promotedServiceName;
                if (componentService.getName() != null) {
                    promotedServiceName = promotedComponentName + '/' + componentService.getName();
                } else {
                    promotedServiceName = promotedComponentName;
                }
                ComponentService promotedService = componentServices.get(promotedServiceName);
                if (promotedService != null) {
   
                    // Point to the resolved component
                    Component promotedComponent = components.get(promotedComponentName);
                    compositeService.setPromotedComponent(promotedComponent);
                   
                    // Point to the resolved component service
                    compositeService.setPromotedService(promotedService);
   
                    // Use the interface contract from the component service if
                    // none is specified on the composite service
                    InterfaceContract compositeServiceInterfaceContract = compositeService.getInterfaceContract();
                    InterfaceContract promotedServiceInterfaceContract = promotedService.getInterfaceContract();
                    if (compositeServiceInterfaceContract == null) {
                        compositeService.setInterfaceContract(promotedServiceInterfaceContract);
                    } else if (promotedServiceInterfaceContract != null) {
                        // Check the compositeServiceInterfaceContract and promotedServiceInterfaceContract
                        boolean isCompatible = interfaceContractMapper.isCompatible(compositeServiceInterfaceContract, promotedServiceInterfaceContract);
                        if(!isCompatible){
                            warning(monitor, "ServiceInterfaceNotSubSet", compositeService, promotedServiceName);
View Full Code Here

               
                // TODO - EPR - We maintain all endpoints at the right level now
                //              but endpoints for promoting services must point down
                //              to the services they promote.
                if (service.getService() instanceof CompositeService) {
                    CompositeService compositeService = (CompositeService)service.getService();
                    endpointService = ServiceConfigurationUtil.getPromotedComponentService(compositeService);
                    endpointComponent = ServiceConfigurationUtil.getPromotedComponent(compositeService);
                }
               
               
View Full Code Here

                        ComponentService targetService = resolveServiceURI(bindingURI, targetComponent);

                        // if the target service is a promoted service then find the
                        // service it promotes
                        if ((targetService != null) && (targetService.getService() instanceof CompositeService)) {
                            CompositeService compositeService = (CompositeService)targetService.getService();
                            // Find the promoted component service
                            ComponentService promotedComponentService = getPromotedComponentService(compositeService);
                            if (promotedComponentService != null && !promotedComponentService.isUnresolved()) {
                                targetService = promotedComponentService;
                            }
View Full Code Here

            inheritFromService(subject, composite, component, ((ComponentService)service).getService());
            // Component service also inherits the intents/policySets from composite/component
            inherit(subject, composite, component);
        } else if (service instanceof CompositeService) {
            // composite!=null, component is not used
            CompositeService compositeService = (CompositeService)service;
            // Handle the promoted component service
            inheritFromService(subject, composite, compositeService.getPromotedComponent(), compositeService
                .getPromotedService());
        }
        // For atomic service, the composite is not used
        inherit(subject, component.getImplementation(), service);
    }
View Full Code Here

        configureNestedCompositeServices(composite);

        // TODO - In OASIS the treatment of top level composite services it different
        // Process top level composite services
        for (Service service : composite.getServices()) {
            CompositeService compositeService = (CompositeService)service;

            // Get the next lower level promoted service
            ComponentService promotedService = compositeService.getPromotedService();
            if (promotedService != null) {

                // Set the bindings using the top level bindings to override the lower level bindings
                if (!bindingsSpecifiedManually(compositeService.getBindings()) &&
                    bindingsSpecifiedManually(promotedService.getBindings())) {
                    compositeService.getBindings().clear();
                    for (Binding binding : promotedService.getBindings()) {
                        try {
                            compositeService.getBindings().add((Binding)binding.clone());
                        } catch (CloneNotSupportedException ex) {
                            // this binding can't be used in the promoted service
                        }
                    }                   
                }
                if (compositeService.getInterfaceContract() != null &&
                    compositeService.getInterfaceContract().getCallbackInterface() != null) {
                    if (!(compositeService.getCallback() != null &&
                          bindingsSpecifiedManually(compositeService.getCallback().getBindings())) &&
                        promotedService.getCallback() != null &&
                        bindingsSpecifiedManually(promotedService.getCallback().getBindings())) {
                        if (compositeService.getCallback() != null) {
                            compositeService.getCallback().getBindings().clear();
                        } else {
                            compositeService.setCallback(assemblyFactory.createCallback());
                        }
                        for (Binding binding : promotedService.getCallback().getBindings()) {
                            try {
                                compositeService.getCallback().getBindings().add((Binding)binding.clone());
                            } catch (CloneNotSupportedException ex) {
                                // this binding can't be used in the promoted service
                            }
                        }                         
                    }
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 next lower level promoted service
                        ComponentService promotedService = compositeService.getPromotedService();
                        if (promotedService != null) {

                            // Set the bindings using the top level bindings to override the lower level bindings
                            if (!bindingsSpecifiedManually(compositeService.getBindings()) &&
                                bindingsSpecifiedManually(promotedService.getBindings()) ) {
                                compositeService.getBindings().clear();
                                for (Binding binding : promotedService.getBindings()) {
                                    try {
                                        compositeService.getBindings().add((Binding)binding.clone());
                                    } catch (CloneNotSupportedException ex) {
                                        // this binding can't be used in the promoted service
                                    }
                                }                   
                            }
                            if (!bindingsSpecifiedManually(componentService.getBindings()) &&
                                bindingsSpecifiedManually(compositeService.getBindings()) ) {
                                componentService.getBindings().clear();
                                componentService.getBindings().addAll(compositeService.getBindings());
                            }
                            if (componentService.getInterfaceContract() != null &&
                                componentService.getInterfaceContract().getCallbackInterface() != null) {
                                if (!(compositeService.getCallback() != null &&
                                      bindingsSpecifiedManually(compositeService.getCallback().getBindings())) &&
                                    promotedService.getCallback() != null &&
                                    bindingsSpecifiedManually(promotedService.getCallback().getBindings())) {
                                    if (compositeService.getCallback() != null) {
                                        compositeService.getCallback().getBindings().clear();
                                    } else {
                                        compositeService.setCallback(assemblyFactory.createCallback());
                                    }
                                    for (Binding binding : promotedService.getCallback().getBindings()) {
                                        try {
                                            compositeService.getCallback().getBindings().add((Binding)binding.clone());
                                        } catch (CloneNotSupportedException ex) {
                                            // this binding can't be used in the promoted service
                                        }
                                    }                         
                                }
                                if (!(componentService.getCallback() != null &&
                                      bindingsSpecifiedManually(componentService.getCallback().getBindings())) &&
                                    compositeService.getCallback() != null &&
                                    bindingsSpecifiedManually(compositeService.getCallback().getBindings())) {
                                    if (componentService.getCallback() != null) {
                                        componentService.getCallback().getBindings().clear();
                                    } else {
                                        componentService.setCallback(assemblyFactory.createCallback());
                                    }
                                    componentService.getCallback().getBindings().addAll(
                                            compositeService.getCallback().getBindings());
                                }
                            }
                        }
                    }
                }
View Full Code Here

        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

        assertEquals(((PolicySubject)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

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.