Package org.apache.tuscany.sca.assembly

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


        a.setName("a");
        c1.getComponents().add(a);
        CompositeService s = assemblyFactory.createCompositeService();
        s.setName("s");
        c1.getServices().add(s);
        CompositeReference r = assemblyFactory.createCompositeReference();
        r.setName("r");
        c1.getReferences().add(r);

        Composite c2 = assemblyFactory.createComposite();
        c2.setName(new QName("http://foo", "C2"));
        c1.getIncludes().add(c2);
View Full Code Here


        a.setName("a");
        c1.getComponents().add(a);
        CompositeService s = assemblyFactory.createCompositeService();
        s.setName("s");
        c1.getServices().add(s);
        CompositeReference r = assemblyFactory.createCompositeReference();
        r.setName("r");
        c1.getReferences().add(r);

        Composite c2 = assemblyFactory.createComposite();
        c2.setName(new QName("http://foo", "C2"));
        Component b = assemblyFactory.createComponent();
View Full Code Here

        connectPromotedReferences(componentType, components, componentReferences, monitor);

        // look at each component type reference in turn and
        // calculate its configuration based on OASIS rules
        for (Reference reference : componentType.getReferences()) {
            CompositeReference compositeReference = (CompositeReference)reference;
            List<ComponentReference> promotedReferences = compositeReference.getPromotedReferences();

            for (ComponentReference promotedComponentReference : promotedReferences) {
               
                // promote multiplicity
                reconcileReferenceMultiplicity(componentType, compositeReference, promotedComponentReference, monitor);
View Full Code Here

                                           Map<String, ComponentReference> componentReferences,
                                           Monitor monitor) {

        // Connect composite (component type) references to the component references that they promote
        for (Reference reference : componentType.getReferences()) {
            CompositeReference compositeReference = (CompositeReference)reference;
            List<ComponentReference> promotedReferences = compositeReference.getPromotedReferences();
            for (int i = 0, n = promotedReferences.size(); i < n; i++) {
                ComponentReference componentReference = promotedReferences.get(i);
                if (componentReference.isUnresolved()) {
                    String componentReferenceName = componentReference.getName();
                    componentReference = componentReferences.get(componentReferenceName);
                    if (componentReference != null) {
                        // Set the promoted component
                        Component promotedComponent = compositeReference.getPromotedComponents().get(i);
                        promotedComponent = components.get(promotedComponent.getName());
                        compositeReference.getPromotedComponents().set(i, promotedComponent);

                        componentReference.setPromoted(true);

                        // Point to the resolved component reference
                        promotedReferences.set(i, componentReference);
View Full Code Here

                if (componentReference.getEndpointReferences().isEmpty()) {

                    // No error if the reference is promoted out of the current composite
                    boolean promoted = false;
                    for (Reference reference : composite.getReferences()) {
                        CompositeReference compositeReference = (CompositeReference)reference;
                        if (compositeReference.getPromotedReferences().contains(componentReference)) {
                            promoted = true;
                            break;
                        }
                    }
                    if (!promoted && !componentReference.isForCallback() && !componentReference.isWiredByImpl()) {
View Full Code Here

        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;
       
        try {
   
            // 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)));
                            composite.setAutowire(getBoolean(reader, AUTOWIRE));
                            composite.setLocal(getBoolean(reader, LOCAL));
                            composite.setConstrainingType(getConstrainingType(reader));
                            readPolicies(composite, reader);
   
                        } else if (INCLUDE_QNAME.equals(name)) {
   
                            // Read an <include>
                            include = assemblyFactory.createComposite();
                            include.setName(getQName(reader, "name"));
                            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);
                                readPolicies(contract, reader);
                            } else {
   
                                // Read a <composite><service>
                                compositeService = assemblyFactory.createCompositeService();
                                contract = compositeService;
                                compositeService.setName(getString(reader, NAME));
   
                                ComponentService promoted = assemblyFactory.createComponentService();
                                promoted.setUnresolved(true);
                                promoted.setName(getString(reader, PROMOTE));
                                compositeService.setPromotedService(promoted);
   
                                composite.getServices().add(compositeService);
                                readPolicies(contract, reader);
                            }
   
                        } else if (REFERENCE_QNAME.equals(name)) {
                            if (component != null) {
                                // Read a <component><reference>
                                componentReference = assemblyFactory.createComponentReference();
                                contract = componentReference;
                                componentReference.setName(getString(reader, NAME));
                                readMultiplicity(componentReference, reader);
                                componentReference.setAutowire(getBoolean(reader, AUTOWIRE));
                                readTargets(componentReference, reader);
                                componentReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
                                component.getReferences().add(componentReference);
                                readPolicies(contract, reader);
                            } else {
                                // Read a <composite><reference>
                                compositeReference = assemblyFactory.createCompositeReference();
                                contract = compositeReference;
                                compositeReference.setName(getString(reader, NAME));
                                readMultiplicity(compositeReference, reader);
                                readTargets(compositeReference, reader);
                                readPromotes(compositeReference, reader);
                                compositeReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
                                composite.getReferences().add(compositeReference);
                                readPolicies(contract, reader);
                            }
   
                        } else if (PROPERTY_QNAME.equals(name)) {
View Full Code Here

                writeEnd(writer);
            }
   
            for (Reference reference : composite.getReferences()) {
                // TODO handle multivalued promote attribute
                CompositeReference compositeReference = (CompositeReference)reference;
                String promote;
                if (!compositeReference.getPromotedReferences().isEmpty())
                    promote = compositeReference.getPromotedReferences().get(0).getName();
                else
                    promote = null;
                writeStart(writer, REFERENCE,
                           new XAttr(NAME, reference.getName()),
                           new XAttr(PROMOTE, promote));
View Full Code Here

        String value = element.getTextContent();
        assertEquals(value, "true");
        assertEquals(property.getXSDType(), new QName("http://www.w3.org/2001/XMLSchema", "boolean"));
        assertEquals(property.isMany(), false);

        CompositeReference calcCompositeReference = (CompositeReference)composite.getReferences().get(0);
        assertEquals(calcCompositeReference.getName(), "MultiplyService");
        assertTrue(calcCompositeReference.getPromotedReferences().get(0).isUnresolved());
        assertEquals(calcCompositeReference.getPromotedReferences().get(0).getName(),
                     "CalculatorServiceComponent/multiplyService");
        assertEquals(calcCompositeReference.getRequiredIntents().get(0).getName(),
                     new QName("http://test/confidentiality", "confidentiality"));
        assertEquals(calcCompositeReference.getPolicySets().get(0).getName(), new QName("http://test/secure", "secure"));
        // TODO test operations
        Callback calcCallback = calcCompositeReference.getCallback();
        assertEquals(calcCompositeReference.getRequiredIntents().get(0).getName(),
                     new QName("http://test/confidentiality", "confidentiality"));
        assertEquals(calcCompositeReference.getPolicySets().get(0).getName(), new QName("http://test/secure", "secure"));
        assertNotNull(calcCallback);
        // TODO test operations

        //new PrintUtil(System.out).print(composite);
    }
View Full Code Here

        a.setName("a");
        c1.getComponents().add(a);
        CompositeService s = assemblyFactory.createCompositeService();
        s.setName("s");
        c1.getServices().add(s);
        CompositeReference r = assemblyFactory.createCompositeReference();
        r.setName("r");
        c1.getReferences().add(r);

        Composite c2 = assemblyFactory.createComposite();
        c2.setName(new QName("http://foo", "C2"));
        c1.getIncludes().add(c2);
View Full Code Here

        a.setName("a");
        c1.getComponents().add(a);
        CompositeService s = assemblyFactory.createCompositeService();
        s.setName("s");
        c1.getServices().add(s);
        CompositeReference r = assemblyFactory.createCompositeReference();
        r.setName("r");
        c1.getReferences().add(r);

        Composite c2 = assemblyFactory.createComposite();
        c2.setName(new QName("http://foo", "C2"));
        Component b = assemblyFactory.createComponent();
View Full Code Here

TOP

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

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.