Package org.apache.tuscany.sca.assembly

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


    }
   
    private void verifyComposite(Composite c) {
      assertEquals("Calculator", c.getName().getLocalPart());
      assertEquals(1, c.getComponents().size());
      Component component = c.getComponents().get(0);
      assertEquals("AddServiceComponent", component.getName());
      assertEquals(1, component.getAttributeExtensions().size());
      Extension extension = component.getAttributeExtensions().get(0);
      assertEquals("customAttribute", extension.getQName().getLocalPart());
      assertEquals("http://test", extension.getQName().getNamespaceURI());
      assertEquals("customValue", extension.getValue());
    }
View Full Code Here


       
        // Read
        InputStream is = getClass().getResourceAsStream("NestedCalculator.composite");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        Composite composite = compositeProcessor.read(reader, context);
        Component component = composite.getComponents().get(0);
        Composite implementation = (Composite)component.getImplementation();
        QName qname = implementation.getName();

        // Write
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        XMLStreamWriter writer = outputFactory.createXMLStreamWriter(bos);
        compositeProcessor.write(composite, writer, context);
        writer.close();
        System.out.println("Writtent ouput is:\n" + bos);
       
        // Read again
        is = new ByteArrayInputStream(bos.toByteArray());
        reader = inputFactory.createXMLStreamReader(is);
        composite = compositeProcessor.read(reader, context);
       
        // Compare
        component = composite.getComponents().get(0);
        implementation = (Composite)component.getImplementation();
       
        assertEquals(qname, implementation.getName());
    }
View Full Code Here

        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

        Component calcComponent = composite.getComponents().get(0);
        assertEquals(calcComponent.getName(), "CalculatorServiceComponent");
        assertEquals(calcComponent.getAutowire(), Boolean.FALSE);
        assertEquals(calcComponent.getRequiredIntents().get(0).getName(), new QName("http://test",
                                                                                    "confidentiality"));
        assertEquals(calcComponent.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));

        ComponentService calcComponentService = calcComponent.getServices().get(0);
        assertEquals(calcComponentService.getName(), "CalculatorService");
        assertEquals(calcComponentService.getRequiredIntents().get(0).getName(),
                     new QName("http://test", "confidentiality"));
        assertEquals(calcComponentService.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
        // TODO test operations

        ComponentReference calcComponentReference = calcComponent.getReferences().get(0);
        assertEquals(calcComponentReference.getName(), "addService");
        assertEquals(calcComponentReference.getAutowire(), Boolean.FALSE);
        assertEquals(calcComponentReference.isWiredByImpl(), false);
        assertEquals(calcComponentReference.getRequiredIntents().get(0).getName(),
                     new QName("http://test", "confidentiality"));
        assertEquals(calcComponentReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
        // TODO test operations

        Property property = calcComponent.getProperties().get(0);
        assertEquals(property.getName(), "round");
        Document doc = (Document) property.getValue();
        Element element = doc.getDocumentElement();
        String value = element.getTextContent();
        assertEquals(value, "true");
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$." + serviceName;
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$." + serviceName;
View Full Code Here

                }
                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);
   
View Full Code Here

            for (ComponentService componentService : componentReference.getTargets()) {
               
                // Resolve the target component and service
                String name = componentService.getName();
                ComponentService targetComponentService = componentServices.get(name);
                Component targetComponent;
                int s = name.indexOf('/');
                if (s == -1) {
                    targetComponent = components.get(name);
                } else {
                    targetComponent = components.get(name.substring(0, s));
                }
               
                if (targetComponentService != null) {

                    // Check that the target component service provides
                    // a superset of the component reference interface
                    if (componentReference.getInterfaceContract() == null ||
                        interfaceContractMapper.isCompatible(componentReference.getInterfaceContract(), targetComponentService.getInterfaceContract())) {

                        Target target = new Target(targetComponent, targetComponentService);
                        targets.add(target);

                        // mark the reference target as resolved. Used later when we are looking to
                        // see if an sca binding is associated with a resolved target or not
                        componentService.setUnresolved(false);
                    } else {
                        warning("Incompatible interfaces on component reference and target: " + componentReference
                                    .getName()
                                    + " : "
                                    + componentService.getName(),
                                composite);
                    }
                } else {
                    // add all the reference bindings into the target so that they
                    // can be used for comparison when the target is resolved at runtime
                    componentService.getBindings().addAll(componentReference.getBindings());
                   
                    // The bindings will be cloned back into the reference when the
                    // target is finally resolved.
                   
                    warning("Component reference target not found, it might be a remote service: " + componentService.getName(), composite);
                }
            }
        } else if (componentReference.getReference() != null) {

            // Resolve targets from the corresponding reference in the
            // componentType
            for (ComponentService componentService : componentReference.getReference().getTargets()) {

                // Resolve the target component and service
                String name = componentService.getName();
                ComponentService targetComponentService = componentServices.get(name);
                Component targetComponent;
                int s = name.indexOf('/');
                if (s == -1) {
                    targetComponent = components.get(name);
                } else {
                    targetComponent = components.get(name.substring(0, s));
View Full Code Here

            }
            List<Binding> selectedCallbackBindings = bidirectional ? new ArrayList<Binding>() : null;
   
            for (Target target : targets) {
               
                Component targetComponent = target.getComponent();
                ComponentService targetComponentService = target.getService();
                if (targetComponentService.getService() instanceof CompositeService) {
                    CompositeService compositeService = (CompositeService) targetComponentService.getService();
                    // Find the promoted component service
                    targetComponentService = CompositeConfigurationBuilderImpl.getPromotedComponentService(compositeService);
View Full Code Here

            componentName = name;
            serviceName = null;
        }

        // Lookup the component in the domain
        Component component = components.get(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$." + serviceName;
View Full Code Here

        }
        return null;
    }

    public void startComponent(String componentName) throws ActivationException {
        Component component = getComponent(componentName);
        if (component == null) {
            throw new IllegalArgumentException("no component: " + componentName);
        }
        CompositeActivator compositeActivator = runtime.getCompositeActivator();
        compositeActivator.start(component);
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.