Package org.apache.tuscany.sca.assembly

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


        }
    }

    @Override
    public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
        Reference reference = null;
        if ( (reference = getReference(method, type)) != null ) {
            readIntents(method.getAnnotation(Requires.class), reference.getRequiredIntents());
            readPolicySets(method.getAnnotation(PolicySets.class), reference.getPolicySets());
        } else {
            if ( type instanceof OperationsConfigurator ) {
                //Read the intents specified on the given implementation method
                if ( (method.getAnnotation(Requires.class) != null ||
                        method.getAnnotation(PolicySets.class) != null ) &&
View Full Code Here


    }
   
    public ComponentType read(XMLStreamReader reader) throws ContributionReadException {
        ComponentType componentType = null;
        Service service = null;
        Reference reference = null;
        Contract contract = null;
        Property property = null;
        Callback callback = null;
        QName name = null;
       
        try {
            // Read the componentType document
            while (reader.hasNext()) {
                int event = reader.getEventType();
                switch (event) {
                    case START_ELEMENT:
                        name = reader.getName();
   
                        if (Constants.COMPONENT_TYPE_QNAME.equals(name)) {
   
                            // Read a <componentType>
                            componentType = assemblyFactory.createComponentType();
                            componentType.setConstrainingType(readConstrainingType(reader));
   
                        } else if (Constants.SERVICE_QNAME.equals(name)) {
   
                            // Read a <service>
                            service = assemblyFactory.createService();
                            contract = service;
                            service.setName(getString(reader, Constants.NAME));
                            componentType.getServices().add(service);
                            policyProcessor.readPolicies(service, reader);
   
                        } else if (Constants.REFERENCE_QNAME.equals(name)) {
   
                            // Read a <reference>
                            reference = assemblyFactory.createReference();
                            contract = reference;
                            reference.setName(getString(reader, Constants.NAME));
                            reference.setWiredByImpl(getBoolean(reader, Constants.WIRED_BY_IMPL));
                            readMultiplicity(reference, reader);
                            readTargets(reference, reader);
                            componentType.getReferences().add(reference);
                            policyProcessor.readPolicies(reference, reader);
   
View Full Code Here

    }
   
    public ComponentType read(XMLStreamReader reader) throws ContributionReadException {
        ComponentType componentType = null;
        Service service = null;
        Reference reference = null;
        Contract contract = null;
        Property property = null;
        Callback callback = null;
        QName name = null;
       
        try {
            // Read the componentType document
            while (reader.hasNext()) {
                int event = reader.getEventType();
                switch (event) {
                    case START_ELEMENT:
                        name = reader.getName();
   
                        if (Constants.COMPONENT_TYPE_QNAME.equals(name)) {
   
                            // Read a <componentType>
                            componentType = assemblyFactory.createComponentType();
                            componentType.setConstrainingType(readConstrainingType(reader));
   
                        } else if (Constants.SERVICE_QNAME.equals(name)) {
   
                            // Read a <service>
                            service = assemblyFactory.createService();
                            contract = service;
                            service.setName(getString(reader, Constants.NAME));
                            componentType.getServices().add(service);
                            policyProcessor.readPolicies(service, reader);
   
                        } else if (Constants.REFERENCE_QNAME.equals(name)) {
   
                            // Read a <reference>
                            reference = assemblyFactory.createReference();
                            contract = reference;
                            reference.setName(getString(reader, Constants.NAME));
                            reference.setWiredByImpl(getBoolean(reader, Constants.WIRED_BY_IMPL));
                            readMultiplicity(reference, reader);
                            readTargets(reference, reader);
                            componentType.getReferences().add(reference);
                            policyProcessor.readPolicies(reference, reader);
   
View Full Code Here

     * @return
     */
    private Reference generateReference( String name, PortType myRolePT,
        PortType partnerRolePT, Collection<WSDLInterface> theInterfaces) throws ContributionResolveException {
       
        Reference reference = assemblyFactory.createReference();
        WSDLInterfaceContract interfaceContract = wsdlFactory.createWSDLInterfaceContract();
        reference.setInterfaceContract(interfaceContract);

        // Establish whether there is just a call interface or a call + callback
        // interface
        PortType callPT = null;
        PortType callbackPT = null;
        if (myRolePT != null) {
            callPT = myRolePT;
            // If the 2 port types are not the same one, there is a callback...
            if (partnerRolePT != null) {
                if (!myRolePT.getQName().equals(partnerRolePT.getQName())) {
                    callbackPT = partnerRolePT;
                } // end if
            } // end if
        } else if (partnerRolePT != null) {
            callPT = partnerRolePT;
        } // end if

        // No interfaces mean an error
        if (callPT == null && callbackPT == null) {
            error("MyRolePartnerRoleNull", theInterfaces);
        } // end if

        // Set the name of the reference to the supplied name and the
        // multiplicity of the reference
        // to 1..1
        // TODO: support other multiplicities
        reference.setName(name);
        reference.setMultiplicity(Multiplicity.ONE_ONE);

        if (callPT != null) {
            // Set the call interface and, if present, the callback interface
            WSDLInterface callInterface = null;
            for (WSDLInterface anInterface : theInterfaces) {
                if (anInterface.getPortType().getQName().equals(callPT.getQName()))
                    callInterface = anInterface;
            } // end for
            if (callInterface == null) {
                error("NoInterfaceForPortType", theInterfaces, callPT.getQName().toString());
            } else
                reference.getInterfaceContract().setInterface(callInterface);
        }

        // There is a callback if the partner role is not null and if the
        // partner role port type
        // is not the same as the port type for my role
        if (callbackPT != null) {
            WSDLInterface callbackInterface = null;
            for (WSDLInterface anInterface : theInterfaces) {
                if (anInterface.getPortType().getQName().equals(callbackPT.getQName()))
                    callbackInterface = anInterface;
            } // end for
            if (callbackInterface == null) {
                error("NoInterfaceForPortType", theInterfaces, callbackPT.getQName().toString());
            } else
                reference.getInterfaceContract().setCallbackInterface(callbackInterface);
        } // end if

        return reference;
    } // end generateReference
View Full Code Here

     * @return
     */
    private static void collectPromotedComponentReferences(CompositeReference compositeReference,
                                                           List<ComponentReference> componentReferences) {
        for (ComponentReference componentReference : compositeReference.getPromotedReferences()) {
            Reference reference = componentReference.getReference();
            if (reference instanceof CompositeReference) {
   
                // Continue to follow the reference promotion chain
                collectPromotedComponentReferences((CompositeReference)reference, componentReferences);
   
View Full Code Here

        // Propagate interfaces from inner composite components' references to
        // their component references
        for (Component component : composite.getComponents()) {
            if (component.getImplementation() instanceof Composite) {
                for (ComponentReference componentReference : component.getReferences()) {
                    Reference reference = componentReference.getReference();
                    if (reference != null) {
                        if (componentReference.getInterfaceContract() == null) {
                            componentReference.setInterfaceContract(reference.getInterfaceContract());
                        }
                    }
                }
            }
        }
View Full Code Here

        // Process component references declared on components in this composite
        for (Component component : composite.getComponents()) {
            Implementation implementation = component.getImplementation();
            if (implementation instanceof Composite) {
                for (ComponentReference componentReference : component.getReferences()) {
                    Reference implReference = componentReference.getReference();
                    if (implReference != null && implReference instanceof CompositeReference) {

                        // If the component reference is wired, it is a promotion override
                        if (!componentReference.getEndpointReferences().isEmpty()) {
                            componentReference.setPromotionOverride(true);
View Full Code Here

    public EndpointReference getEndpointReference() {
        try {
            resolve();

            // Use the interface contract of the reference on the component type
            Reference componentTypeRef = reference.getReference();
            InterfaceContract sourceContract =
                componentTypeRef == null ? reference.getInterfaceContract() : componentTypeRef.getInterfaceContract();
            sourceContract = sourceContract.makeUnidirectional(false);
            EndpointReference epr = new EndpointReferenceImpl(component, reference, binding, sourceContract);
            ReferenceParameters parameters = getReferenceParameters();
            epr.setReferenceParameters(parameters);
            return epr;
View Full Code Here

        // Connect each component reference to the corresponding reference
        for (ComponentReference componentReference : component.getReferences()) {
            if (componentReference.getReference() != null || componentReference.isCallback()) {
                continue;
            }
            Reference reference = references.get(componentReference.getName());
            if (reference != null) {
                componentReference.setReference(reference);
            } else {
                if (!componentReference.getName().startsWith("$self$.")) {
                    error(monitor, "ReferenceNotFound", component, component.getName(), componentReference.getName());
                }
            }
        }

        // Create a component reference for each reference
        if (component.getImplementation() != null) {
            for (Reference reference : component.getImplementation().getReferences()) {
                if (!componentReferences.containsKey(reference.getName())) {
                    ComponentReference componentReference =
                        assemblyFactory.createComponentReference();
                    componentReference.setIsCallback(reference.isCallback());
                    componentReference.setName(reference.getName());
                    componentReference.setReference(reference);
                    component.getReferences().add(componentReference);
                }
            }
        }

        // Reconcile each component reference with its reference
        for (ComponentReference componentReference : component.getReferences()) {
            Reference reference = componentReference.getReference();
            if (reference != null) {
                // Reconcile multiplicity
                if (componentReference.getMultiplicity() != null) {
                    if (!ReferenceConfigurationUtil.isValidMultiplicityOverride(reference.getMultiplicity(),
                                                                   componentReference
                                                                       .getMultiplicity())) {
                        warning(monitor, "ReferenceIncompatibleMultiplicity", component, component.getName(), componentReference.getName());
                    }
                } else {
                    componentReference.setMultiplicity(reference.getMultiplicity());
                }

                // Reconcile interface
                InterfaceContract interfaceContract = reference.getInterfaceContract();
                if (componentReference.getInterfaceContract() != null) {
                    if (interfaceContract != null && !componentReference.getInterfaceContract().equals(reference
                        .getInterfaceContract())) {
                        if (!interfaceContractMapper.isCompatible(componentReference.getInterfaceContract(),
                                                                  interfaceContract)) {
                            warning(monitor, "ReferenceIncompatibleComponentInterface", component, component.getName(), componentReference.getName());
                        }
                    }
                } else {
                    componentReference.setInterfaceContract(interfaceContract);
                }

                // Reconcile bindings
                if (componentReference.getBindings().isEmpty()) {
                    componentReference.getBindings().addAll(reference.getBindings());
                }
               
                // Reconcile callback bindings
                if (componentReference.getCallback() == null) {
                    componentReference.setCallback(reference.getCallback());
                    if (componentReference.getCallback() == null) {
                        // Create an empty callback to avoid null check
                        componentReference.setCallback(assemblyFactory.createCallback());
                    }

                } else if (componentReference.getCallback().getBindings().isEmpty() && reference
                    .getCallback() != null) {
                    componentReference.getCallback().getBindings().addAll(reference.getCallback()
                        .getBindings());
                }
               
                // Propagate autowire setting from the component
                if (componentReference.getAutowire() == null) {
                    componentReference.setAutowire(component.getAutowire());
                }

                // Reconcile targets
                if (componentReference.getTargets().isEmpty()) {
                    componentReference.getTargets().addAll(reference.getTargets());
                }
            }
        }
    }
View Full Code Here

    private void addReferenceWire(Component component, ComponentReference reference, EndpointReference2 endpointReference) {
        RuntimeComponentReference runtimeRef = (RuntimeComponentReference)reference;
       
        // Use the interface contract of the reference on the component type and if there
        // isn't one then use the one from the reference itself
        Reference componentTypeRef = reference.getReference();

        InterfaceContract sourceContract;
        if (componentTypeRef == null || componentTypeRef.getInterfaceContract() == null) {
            sourceContract = reference.getInterfaceContract();
        } else {
            sourceContract = componentTypeRef.getInterfaceContract();
        }
      
        // TODO - EPR - interface contract seems to be null in the implementation.web
        //              case. Not introspecting the CT properly?
        if (sourceContract == null){
View Full Code Here

TOP

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

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.