Package org.apache.tuscany.sca.assembly

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


            writeEnd(writer);
        }

        // Write <reference> elements
        for (Reference reference : composite.getReferences()) {
            CompositeReference compositeReference = (CompositeReference) reference;

            // Write list of promoted references
            List<String> promote = new ArrayList<String>();
            for (ComponentReference promoted : compositeReference
                    .getPromotedReferences()) {
                promote.add(promoted.getName());
            }

            // Write <reference> element
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"));
        assertEquals(calcCompositeReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
        // TODO test operations
        Callback calcCallback = calcCompositeReference.getCallback();
        assertEquals(calcCompositeReference.getRequiredIntents().get(0).getName(),
                     new QName("http://test", "confidentiality"));
        assertEquals(calcCompositeReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
        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

     */
    public void build(Composite composite) throws CompositeBuilderException {
   
        // Process composite references declared in this composite
        for (Reference reference : composite.getReferences()) {
            CompositeReference compositeReference = (CompositeReference)reference;

            // If the composite reference is a promotion override, override the
            // configuration of the promoted reference. 
            //FIXME: Policy configuration or wiring of domain-level composite references
            // doesn't cause a promotion override, unless the composite reference has
            // additional bindings.  Do we need to detect this and force an override?
            if (compositeReference.isPromotionOverride()) {
                List<ComponentReference> promotedReferences =
                    ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference);
                for (ComponentReference promotedReference : promotedReferences) {
                    ReferenceConfigurationUtil.reconcileReferenceBindings(
                            compositeReference, promotedReference, assemblyFactory, endpointFactory, monitor);
                    if (compositeReference.getInterfaceContract() != null && // can be null in unit tests
                        compositeReference.getInterfaceContract().getCallbackInterface() != null) {
                        SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class);
                        if (promotedReference.getCallback() != null) {
                            promotedReference.getCallback().getBindings().clear();
                        } else {
                            promotedReference.setCallback(assemblyFactory.createCallback());
                        }
                        if (scaCallbackBinding != null) {
                            promotedReference.getCallback().getBindings().add(scaCallbackBinding);
                        }
                        if (compositeReference.getCallback() != null) {
                            promotedReference.getCallback().getBindings().addAll(compositeReference.getCallback()
                                .getBindings());
                        }
                    }
                }
            }
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)));
   
                            if(!isSet(reader, TARGET_NAMESPACE)){
                                // spec says that a composite must have a namespace
                                warning("NoCompositeNamespace", composite, composite.getName().toString());  
                            }
                           
                            if(isSet(reader, AUTOWIRE)) {
                                composite.setAutowire(getBoolean(reader, AUTOWIRE));
                            }
                           
                            //handle extension attributes
                            this.readExtendedAttributes(reader, composite);
   
                            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));
                               
                                //handle extension attributes
                                this.readExtendedAttributes(reader, componentService);
   
                                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);
                                if (promoted != null) {
                                    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);
                                }
   
                                //handle extension attributes
                                this.readExtendedAttributes(reader, compositeService);
   
                                composite.getServices().add(compositeService);
                                policyProcessor.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);
                                if (isSet(reader, AUTOWIRE)) {
                                    componentReference.setAutowire(getBoolean(reader, AUTOWIRE));
                                }
                                readTargets(componentReference, reader);
                                componentReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
                               
                                //handle extension attributes
                                this.readExtendedAttributes(reader, componentReference);
   
                                component.getReferences().add(componentReference);
                                policyProcessor.readPolicies(contract, reader);
                            } else {
                                // Read a <composite><reference>
                                compositeReference = assemblyFactory.createCompositeReference();
                                contract = compositeReference;
                                compositeReference.setName(getString(reader, NAME));
                                readMultiplicity(compositeReference, reader);
                                readTargets(compositeReference, reader);
                                String promote = reader.getAttributeValue(null, Constants.PROMOTE);
                                if (promote != null) {
                                    for (StringTokenizer tokens = new StringTokenizer(promote); tokens.hasMoreTokens();) {
                                        ComponentReference promotedReference =
                                            assemblyFactory.createComponentReference();
                                        promotedReference.setUnresolved(true);
                                        promotedReference.setName(tokens.nextToken());
                                        compositeReference.getPromotedReferences().add(promotedReference);
                                    }
                                }
                                compositeReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
                               
                                //handle extension attributes
                                this.readExtendedAttributes(reader, compositeReference);
   
                                composite.getReferences().add(compositeReference);                           
View Full Code Here

            writeEnd(writer);
        }

        // Write <reference> elements
        for (Reference reference : composite.getReferences()) {
            CompositeReference compositeReference = (CompositeReference)reference;

            // Write list of promoted references
            List<String> promote = new ArrayList<String>();
            for (ComponentReference promoted: compositeReference.getPromotedReferences()) {
                promote.add(promoted.getName());
            }
           
            // Write <reference> element
            writeStart(writer, REFERENCE, new XAttr(NAME, reference.getName()),
View Full Code Here

                if (compositeService.getPromotedService() != null) {
                    compositeService.getPromotedService().setUnresolved(true);
                }
            }
            for (Reference reference : clone.getReferences()) {
                CompositeReference compositeReference = (CompositeReference)reference;
                for (ComponentReference ref : compositeReference.getPromotedReferences()) {
                    // Force the promoted reference to be rebuilt against the clone
                    ref.setUnresolved(true);
                }
            }
View Full Code Here

                if (componentReference.getTargets().isEmpty()) {

                    // No warning 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.isCallback()) {
View Full Code Here

        }
   
        // Connect composite references to the component references
        // that they promote
        for (Reference reference : composite.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) {
   
                        // Point to the resolved component reference
                        promotedReferences.set(i, componentReference);
   
                        // Use the interface contract from the component
                        // reference if none
                        // is specified on the composite reference
                       
                        InterfaceContract compositeReferenceInterfaceContract = compositeReference.getInterfaceContract();
                        InterfaceContract componentReferenceInterfaceContract = componentReference.getInterfaceContract();
                        if (compositeReferenceInterfaceContract == null) {
                            compositeReference.setInterfaceContract(componentReferenceInterfaceContract);
                        } else if (componentReferenceInterfaceContract != null) {
                          // Check the compositeInterfaceContract and componentInterfaceContract
                          boolean isCompatible = interfaceContractMapper.isCompatible(compositeReferenceInterfaceContract, componentReferenceInterfaceContract);
                          if (!isCompatible) {
                              warning("ReferenceInterfaceNotSubSet", compositeReference, componentReferenceName);
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.