Examples of Multiplicity


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

       
        if (componentReference.getAutowire() == Boolean.TRUE) {

            // Find suitable targets in the current composite for an
            // autowired reference
            Multiplicity multiplicity = componentReference.getMultiplicity();
            for (Component targetComponent : composite.getComponents()) {
                for (ComponentService targetComponentService : targetComponent.getServices()) {
                    if (componentReference.getInterfaceContract() == null ||
                        interfaceContractMapper.isCompatible(componentReference.getInterfaceContract(), targetComponentService.getInterfaceContract())) {
                        Target target = new Target(targetComponent, targetComponentService);
View Full Code Here

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

       
        if (componentReference.getAutowire() == Boolean.TRUE) {

            // Find suitable targets in the current composite for an
            // autowired reference
            Multiplicity multiplicity = componentReference.getMultiplicity();
            for (Component targetComponent : composite.getComponents()) {
                for (ComponentService targetComponentService : targetComponent.getServices()) {
                    if (componentReference.getInterfaceContract() == null ||
                        interfaceContractMapper.isCompatible(componentReference.getInterfaceContract(), targetComponentService.getInterfaceContract())) {
                        Target target = new Target(targetComponent, targetComponentService);
View Full Code Here

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

            reference.setMultiplicity(Multiplicity.ONE_ONE);
        }
    }

    protected XAttr writeMultiplicity(AbstractReference reference) {
        Multiplicity multiplicity = reference.getMultiplicity();
        if (multiplicity != null) {
            String value = null;
            if (Multiplicity.ZERO_ONE.equals(multiplicity)) {
                value = ZERO_ONE;
            } else if (Multiplicity.ONE_N.equals(multiplicity)) {
View Full Code Here

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

        // as problems with dependencies mean we still do this during build
        if (endpointReference.getStatus() == EndpointReference.Status.AUTOWIRE_PLACEHOLDER){
          
            // do autowire matching
            // will only be called at build time at the moment
            Multiplicity multiplicity = endpointReference.getReference().getMultiplicity();
            for (Endpoint endpoint : domainRegistry.getEndpoints()){
//              if (endpoint is in the same composite as endpoint reference){
                    if ((multiplicity == Multiplicity.ZERO_ONE ||
                         multiplicity == Multiplicity.ONE_ONE) &&
                        (endpointReference.getReference().getEndpointReferences().size() > 1)) {
View Full Code Here

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

    public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName)
        throws IllegalArgumentException {

        for (ComponentReference ref : component.getReferences()) {
            if (referenceName.equals(ref.getName())) {
                Multiplicity multiplicity = ref.getMultiplicity();
                if (multiplicity == Multiplicity.ZERO_N || multiplicity == Multiplicity.ONE_N) {
                    throw new IllegalArgumentException("Reference " + referenceName
                        + " has multiplicity "
                        + multiplicity);
                }
View Full Code Here

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

        if (componentReference.getAutowire() == Boolean.TRUE
                && componentReference.getTargets().isEmpty()) {

            // Find suitable targets in the current composite for an
            // autowired reference
            Multiplicity multiplicity = componentReference.getMultiplicity();
            for (Component targetComponent : composite.getComponents()) {
                // prevent autowire connecting to self
                boolean skipSelf = false;
                for (ComponentReference targetComponentReference : targetComponent
                        .getReferences()) {
                    if (componentReference == targetComponentReference) {
                        skipSelf = true;
                    }
                }

                if (!skipSelf) {
                    for (ComponentService targetComponentService : targetComponent
                            .getServices()) {
                        if (componentReference.getInterfaceContract() == null
                                || interfaceContractMapper.isCompatible(
                                        componentReference
                                                .getInterfaceContract(),
                                        targetComponentService
                                                .getInterfaceContract())) {

                            Endpoint endpoint = endpointFactory
                                    .createEndpoint();
                            endpoint.setTargetName(targetComponent.getName());
                            endpoint.setSourceComponent(null); // TODO - fixed
                                                               // up at start
                            endpoint
                                    .setSourceComponentReference(componentReference);
                            endpoint.setInterfaceContract(componentReference
                                    .getInterfaceContract());
                            endpoint.setTargetComponent(targetComponent);
                            endpoint
                                    .setTargetComponentService(targetComponentService);
                            endpoint.getCandidateBindings().addAll(
                                    componentReference.getBindings());
                            endpoints.add(endpoint);

                            if (multiplicity == Multiplicity.ZERO_ONE
                                    || multiplicity == Multiplicity.ONE_ONE) {
                                break;
                            }
                        }
                    }
                }
            }

            if (multiplicity == Multiplicity.ONE_N
                    || multiplicity == Multiplicity.ONE_ONE) {
                if (endpoints.size() == 0) {
                    warning(monitor, "NoComponentReferenceTarget",
                            componentReference, componentReference.getName());
                }
            }

        } else if (!componentReference.getTargets().isEmpty()) {

            // Check if the component reference does not mix the use of
            // endpoints specified via
            // binding elements with target endpoints specified via the target
            // attribute
            for (Binding binding : componentReference.getBindings()) {
                if (binding.getURI() != null) {
                    warning(monitor, "ReferenceEndPointMixWithTarget",
                            composite, componentReference.getName());
                }
            }

            // Resolve targets specified on the component reference
            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())) {

                        Endpoint endpoint = endpointFactory.createEndpoint();
                        endpoint.setTargetName(targetComponent.getName());
                        endpoint.setSourceComponent(null); // TODO - fixed up at
                                                           // start
                        endpoint
                                .setSourceComponentReference(componentReference);
                        endpoint.setInterfaceContract(componentReference
                                .getInterfaceContract());
                        endpoint.setTargetComponent(targetComponent);
                        endpoint
                                .setTargetComponentService(targetComponentService);
                        endpoint.getCandidateBindings().addAll(
                                componentReference.getBindings());
                        endpoints.add(endpoint);

                        // 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(monitor, "ReferenceIncompatibleInterface",
                                composite, composite.getName().toString(),
                                componentReference.getName(), componentService
                                        .getName());
                    }
                } 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());

                    Endpoint endpoint = endpointFactory.createEndpoint();
                    endpoint.setTargetName(name);
                    endpoint.setSourceComponent(null); // TODO - fixed up at
                                                       // start
                    endpoint.setSourceComponentReference(componentReference);
                    endpoint.setInterfaceContract(componentReference
                            .getInterfaceContract());
                    endpoint.getCandidateBindings().addAll(
                            componentReference.getBindings());
                    endpoints.add(endpoint);

                    // The bindings will be cloned back into the reference when
                    // the
                    // target is finally resolved.
                    warning(monitor, "ComponentReferenceTargetNotFound",
                            composite, composite.getName().toString(),
                            componentService.getName());
                }
            }
        } else if ((componentReference.getReference() != null)
                && (!componentReference.getReference().getTargets().isEmpty())) {

            // 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));
                }

                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())) {

                        Endpoint endpoint = endpointFactory.createEndpoint();
                        endpoint.setTargetName(targetComponent.getName());
                        endpoint.setSourceComponent(null); // TODO - fixed up at
                                                           // start
                        endpoint
                                .setSourceComponentReference(componentReference);
                        endpoint.setInterfaceContract(componentReference
                                .getInterfaceContract());
                        endpoint.setTargetComponent(targetComponent);
                        endpoint
                                .setTargetComponentService(targetComponentService);
                        endpoint.getCandidateBindings().addAll(
                                componentReference.getBindings());
                        endpoints.add(endpoint);

                        // 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(monitor, "ComponentIncompatibleInterface",
                                composite, componentReference.getName(),
                                componentService.getName());
                    }
                } 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.

                    Endpoint endpoint = endpointFactory.createEndpoint();
                    endpoint.setTargetName(name);
                    endpoint.setSourceComponent(null); // TODO - fixed up at
                                                       // start
                    endpoint.setSourceComponentReference(componentReference);
                    endpoint.setInterfaceContract(componentReference
                            .getInterfaceContract());
                    endpoint.getCandidateBindings().addAll(
                            componentReference.getBindings());
                    endpoints.add(endpoint);

                    warning(monitor, "ComponentReferenceTargetNotFound",
                            composite, composite.getName().toString(),
                            componentService.getName());
                }
            }
        } else if (componentReference.getAutowire() == Boolean.TRUE) {

            // Find suitable targets in the current composite for an
            // autowired reference
            Multiplicity multiplicity = componentReference.getMultiplicity();
            for (Component targetComponent : composite.getComponents()) {
                // prevent autowire connecting to self
                boolean skipSelf = false;
                for (ComponentReference targetComponentReference : targetComponent
                        .getReferences()) {
View Full Code Here

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

    public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) {
        try {
            for (ComponentReference ref : component.getReferences()) {
                if (referenceName.equals(ref.getName())) {
                    /* ******************** Contribution for issue TUSCANY-2281 ******************** */
                    Multiplicity multiplicity = ref.getMultiplicity();
                    if (multiplicity == Multiplicity.ZERO_N || multiplicity == Multiplicity.ONE_N) {
                        throw new IllegalArgumentException("Reference " + referenceName
                            + " has multiplicity "
                            + multiplicity);
                    }
View Full Code Here

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

            reference.setMultiplicity(Multiplicity.ONE_ONE);
        }
    }
   
    protected XAttr writeMultiplicity(AbstractReference reference) {
        Multiplicity multiplicity = reference.getMultiplicity();
        if (multiplicity != null) {
            String value = null;
            if (Multiplicity.ZERO_ONE.equals(multiplicity)) {
                value = ZERO_ONE;
            } else if (Multiplicity.ONE_N.equals(multiplicity)) {
View Full Code Here

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

            reference.setMultiplicity(Multiplicity.ONE_ONE);
        }
    }

    protected XAttr writeMultiplicity(AbstractReference reference) {
        Multiplicity multiplicity = reference.getMultiplicity();
        if (multiplicity != null) {
            String value = null;
            if (Multiplicity.ZERO_ONE.equals(multiplicity)) {
                value = ZERO_ONE;
            } else if (Multiplicity.ONE_N.equals(multiplicity)) {
View Full Code Here

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

    public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) {
        try {
            for (ComponentReference ref : component.getReferences()) {
                if (referenceName.equals(ref.getName())) {
                    /* ******************** Contribution for issue TUSCANY-2281 ******************** */
                    Multiplicity multiplicity = ref.getMultiplicity();
                    if (multiplicity == Multiplicity.ZERO_N || multiplicity == Multiplicity.ONE_N) {
                        throw new IllegalArgumentException("Reference " + referenceName
                            + " has multiplicity "
                            + multiplicity);
                    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.