Package org.apache.tuscany.sca.assembly

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


            Component promotedComponent = ((CompositeService)service).getPromotedComponent();
            ComponentService promotedService = ((CompositeService)service).getPromotedService();
           
            if (promotedService != null) {
                for (Binding binding : service.getBindings()){
                    Endpoint2 endpoint = assemblyFactory.createEndpoint();
                    endpoint.setComponent(promotedComponent);
                    endpoint.setService(promotedService);
                    endpoint.setBinding(binding);
                    endpoint.setUnresolved(false);
                    promotedService.getEndpoints().add(endpoint);
                }
            }
        }
    }
View Full Code Here


                    endpointComponent = ServiceConfigurationUtil.getPromotedComponent(compositeService);
                }
               
               
                for (Binding binding : service.getBindings()){
                    Endpoint2 endpoint = assemblyFactory.createEndpoint();
                    endpoint.setComponent(endpointComponent);
                    endpoint.setService(endpointService);
                    endpoint.setBinding(binding);
                    endpoint.setUnresolved(false);
                    service.getEndpoints().add(endpoint);
                }
            }
        }
    }
View Full Code Here

            wireSource.setCallbackEndpoint(callbackEndpoint);
        }
*/

        InterfaceContract bindingContract = getInterfaceContract(reference, endpointReference.getBinding());
        Endpoint2 endpoint = endpointReference.getTargetEndpoint();
        endpoint.setInterfaceContract(bindingContract);
   
/* TODO - EPR review in the light of new matching code       
        // TUSCANY-2029 - We should use the URI of the serviceBinding because the target may be a Component in a
        // nested composite.
        if (serviceBinding != null) {
View Full Code Here

                            endpointRef.setReference(reference);
                            endpointRef.setUnresolved(false);
                           
                            // create dummy endpoint. This will be replaced when policies
                            // are matched and bindings are configured later
                            Endpoint2 endpoint = assemblyFactory.createEndpoint();
                            endpoint.setComponent(targetComponent);
                            endpoint.setService(targetComponentService);
                            endpoint.setUnresolved(true);
                            endpointRef.setTargetEndpoint(endpoint);
                           
                            reference.getEndpointReferences().add(endpointRef);

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

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

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

            // Check that the component reference does not mix the use of
            // endpoint references specified via the target attribute with
            // the presence of binding elements
            if (reference.getBindings().size() > 0) {
                warning(monitor, "ReferenceEndPointMixWithTarget",
                        composite, reference.getName());
            }

            // Resolve targets specified on the component reference
            for (ComponentService target : reference.getTargets()) {              
               
                String targetName = target.getName();
                ComponentService targetComponentService = componentServices.get(targetName);
               
                Component targetComponent;
                int s = targetName.indexOf('/');
                if (s == -1) {
                    targetComponent = components.get(targetName);
                } else {
                    targetComponent = components.get(targetName.substring(0, s));
                }

                if (targetComponentService != null) {

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

                        // create endpoint reference
                        EndpointReference2 endpointRef = assemblyFactory.createEndpointReference();
                        endpointRef.setComponent(component);
                        endpointRef.setReference(reference);
                        endpointRef.setUnresolved(false);

                        // create dummy endpoint. This will be replaced when policies
                        // are matched and bindings are configured later
                        Endpoint2 endpoint = assemblyFactory.createEndpoint();
                        endpoint.setComponent(targetComponent);
                        endpoint.setService(targetComponentService);
                        endpoint.setUnresolved(true);
                        endpointRef.setTargetEndpoint(endpoint);
                       
                        reference.getEndpointReferences().add(endpointRef);
                    } else {
                        warning(monitor,
                                "ReferenceIncompatibleInterface",
                                composite,
                                composite.getName().toString(),
                                reference.getName(),
                                targetName);
                    }
                } else {
                    // add an unresolved endpoint reference
                    EndpointReference2 endpointRef = assemblyFactory.createEndpointReference();
                    endpointRef.setComponent(component);
                    endpointRef.setReference(reference);
                    endpointRef.setUnresolved(true);
                               
                    // create an unresolved endpoint to go with it
                    Endpoint2 endpoint = assemblyFactory.createEndpoint();
                    endpoint.setUnresolved(true);
                    endpointRef.setTargetEndpoint(endpoint);
                   
                    warning(monitor,
                            "ComponentReferenceTargetNotFound",
                            composite,
                            composite.getName().toString(),
                            targetName);
                }
            }
        } else if ((reference.getReference() != null)
                && (!reference.getReference().getTargets().isEmpty())) {

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

                String targetName = target.getName();
                ComponentService targetComponentService = componentServices.get(targetName);
               
                Component targetComponent;
                int s = targetName.indexOf('/');
                if (s == -1) {
                    targetComponent = components.get(targetName);
                } else {
                    targetComponent = components.get(targetName.substring(0, s));
                }

                if (targetComponentService != null) {

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

                        // create endpoint reference
                        EndpointReference2 endpointRef = assemblyFactory.createEndpointReference();
                        endpointRef.setComponent(component);
                        endpointRef.setReference(reference);
                        endpointRef.setUnresolved(false);
                       
                        // create dummy endpoint. This will be replaced when policies
                        // are matched and bindings are configured later
                        Endpoint2 endpoint = assemblyFactory.createEndpoint();
                        endpoint.setComponent(targetComponent);
                        endpoint.setService(targetComponentService);
                        endpoint.setUnresolved(true);
                        endpointRef.setTargetEndpoint(endpoint);
                       
                        reference.getEndpointReferences().add(endpointRef);
                    } else {
                        warning(monitor,
                                "ReferenceIncompatibleInterface",
                                composite,
                                composite.getName().toString(),
                                reference.getName(),
                                targetName);
                    }
                } else {
                    // add an unresolved endpoint reference
                    EndpointReference2 endpointRef = assemblyFactory.createEndpointReference();
                    endpointRef.setComponent(component);
                    endpointRef.setReference(reference);
                    endpointRef.setUnresolved(true);
                   
                    // create an unresolved endpoint to go with it
                    Endpoint2 endpoint = assemblyFactory.createEndpoint();
                    endpoint.setUnresolved(true);
                    endpointRef.setTargetEndpoint(endpoint);                   
                   
                    warning(monitor,
                            "ComponentReferenceTargetNotFound",
                            composite,
                            composite.getName().toString(),
                            targetName);
                }
            }
        }


        // if no endpoints have found so far the bindings become targets.
        if (reference.getEndpointReferences().isEmpty()) {
            for (Binding binding : reference.getBindings()) {

                String uri = binding.getURI();

                // user hasn't put a uri on the binding so it's not a target
                // name
                if (uri == null) {
                    // create endpoint reference for manually configured bindings
                    EndpointReference2 endpointRef = assemblyFactory.createEndpointReference();
                    endpointRef.setComponent(component);
                    endpointRef.setReference(reference);
                    endpointRef.setBinding(binding);
                    endpointRef.setTargetEndpoint(null);
                    endpointRef.setUnresolved(false);
                   
                    // create a resolved endpoint to signify that this
                    // reference is pointing at some unwired endpoint
                    Endpoint2 endpoint = assemblyFactory.createEndpoint();
                    endpoint.setUnresolved(false);
                    endpointRef.setTargetEndpoint(endpoint);
                   
                    reference.getEndpointReferences().add(endpointRef);
                   
                    continue;
                }

                // user might have put a local target name in the uri
                // see if it refers to a target we know about
                // - if it does the reference binding will be matched with a
                // service binding
                // - if it doesn't it is assumed to be an external reference
                Component targetComponent = null;
                ComponentService targetComponentService = null;


                if (uri.startsWith("/")) {
                    uri = uri.substring(1);
                }

                // Resolve the target component and service
                targetComponentService = componentServices.get(uri);
                int s = uri.indexOf('/');
                if (s == -1) {
                    targetComponent = components.get(uri);
                } else {
                    targetComponent = components.get(uri.substring(0, s));
                }

                // if the binding URI matches a component in the
                // composite then configure an endpoint reference with this component as
                // the target. If not then the binding URI will be assumed to reference an
                // external service
                if (targetComponentService != null) {

                    // Check that the target component service provides
                    // a superset of the component reference interface
                    if (reference.getInterfaceContract() == null ||
                        interfaceContractMapper.isCompatible(reference.getInterfaceContract(),
                                                             targetComponentService.getInterfaceContract())) {
                        // create enpoint reference
                        EndpointReference2 endpointRef = assemblyFactory.createEndpointReference();
                        endpointRef.setComponent(component);
                        endpointRef.setReference(reference);
                        endpointRef.setBinding(binding);
                        endpointRef.setUnresolved(false);

                        // create dummy endpoint. This will be replaced when policies
                        // are matched and bindings are configured later
                        Endpoint2 endpoint = assemblyFactory.createEndpoint();
                        endpoint.setComponent(targetComponent);
                        endpoint.setService(targetComponentService);
                        endpoint.setUnresolved(true);
                        endpointRef.setTargetEndpoint(endpoint);
                       
                        reference.getEndpointReferences().add(endpointRef);
                    } else {
                        warning(monitor,
                                "ReferenceIncompatibleInterface",
                                composite,
                                composite.getName().toString(),
                                reference.getName(),
                                uri);
                    }
                } else {
                    // create endpoint reference for manually configured bindings
                    EndpointReference2 endpointRef = assemblyFactory.createEndpointReference();
                    endpointRef.setComponent(component);
                    endpointRef.setReference(reference);
                    endpointRef.setBinding(binding);
                    endpointRef.setTargetEndpoint(null);
                    endpointRef.setUnresolved(false);
                   
                    // create a resolved endpoint to signify that this
                    // reference is pointing at some unwired endpoint
                    Endpoint2 endpoint = assemblyFactory.createEndpoint();
                    endpoint.setUnresolved(false);
                    endpointRef.setTargetEndpoint(endpoint);
                   
                    reference.getEndpointReferences().add(endpointRef);
                }
            }
View Full Code Here

        endpointReference.setComponent(component);
        endpointReference.setReference(componentReference);
         endpointReference.setUnresolved(false);

        // create endpoint.
        Endpoint2 endpoint = assemblyFactory.createEndpoint();
        endpoint.setComponent(component);
        endpoint.setService(service);
        endpoint.setUnresolved(true);
        endpointReference.setTargetEndpoint(endpoint);
       
        componentReference.getEndpointReferences().add(endpointReference);
       
        // do binding matching
View Full Code Here

     *
     * @param endpoint
     * @param monitor
     */
    public void build(EndpointReference2 endpointReference, Monitor monitor) {
        Endpoint2 endpoint = endpointReference.getTargetEndpoint();
     
        if (endpoint == null){
            // an error?
        } else {         
            if (endpoint.isUnresolved() == false){
                // everything is resolved
                return;
            }
           
            if (endpointReference.isUnresolved() == false ){ 
View Full Code Here

    // TODO - EPR - In OASIS case there are no bindings to match with on the
    //        reference side.
    private void matchForwardBinding(EndpointReference2 endpointReference,
                                     Monitor monitor) {
       
        Endpoint2 endpoint = endpointReference.getTargetEndpoint();

        List<Binding> matchedReferenceBinding = new ArrayList<Binding>();
        List<Endpoint2> matchedServiceEndpoint = new ArrayList<Endpoint2>();

        // Find the corresponding bindings from the service side
        for (Binding referenceBinding : endpointReference.getReference().getBindings()) {
            for (Endpoint2 serviceEndpoint : endpoint.getService().getEndpoints()) {

                if (referenceBinding.getClass() == serviceEndpoint.getBinding().getClass() &&
                    hasCompatiblePolicySets(referenceBinding, serviceEndpoint.getBinding())) {

                    matchedReferenceBinding.add(referenceBinding);
                    matchedServiceEndpoint.add(serviceEndpoint);
                }
            }
        }

        if (matchedReferenceBinding.isEmpty()) {
            // No matching binding
            endpointReference.setBinding(null);
            endpointReference.setTargetEndpoint(null);
            warning(monitor,
                    "NoMatchingBinding",
                    endpointReference.getReference(),
                    endpointReference.getReference().getName(),
                    endpoint.getService().getName());
            return;
        } else {
            // default to using the first matched binding
            int selectedBinding = 0;

            for (int i = 0; i < matchedReferenceBinding.size(); i++) {
                // If binding.sca is present, use it
                if (SCABinding.class.isInstance(matchedReferenceBinding.get(i))) {
                    selectedBinding = i;
                }
            }

            Binding referenceBinding = matchedReferenceBinding.get(selectedBinding);
            Endpoint2 serviceEndpoint = matchedServiceEndpoint.get(selectedBinding);

            // populate the endpoint reference
            try {

                Binding cloned = (Binding) referenceBinding.clone();

                // Set the binding URI to the URI of the target service
                // that has been matched
                if (referenceBinding.getURI() == null) {
                    cloned.setURI(serviceEndpoint.getBinding().getURI());
                }
               
                // TODO - EPR can we remove this?
                if (cloned instanceof OptimizableBinding) {
                    OptimizableBinding optimizableBinding = (OptimizableBinding)cloned;
                    optimizableBinding.setTargetComponent(serviceEndpoint.getComponent());
                    optimizableBinding.setTargetComponentService(serviceEndpoint.getService());
                    optimizableBinding.setTargetBinding(serviceEndpoint.getBinding());
                }

                endpointReference.setBinding(cloned);
                endpointReference.setTargetEndpoint(serviceEndpoint);
View Full Code Here

            endpointReference.getReference().getInterfaceContract().getCallbackInterface() == null ||
            endpointReference.getReference().getName().startsWith("$self$.")){
                return;
        }
       
        Endpoint2 endpoint = endpointReference.getTargetEndpoint();
       
        List<Endpoint2> callbackEndpoints = endpointReference.getReference().getCallbackService().getEndpoints();
        List<EndpointReference2> callbackEndpointReferences = endpoint.getCallbackEndpointReferences();
       
        List<Endpoint2> matchedEndpoint = new ArrayList<Endpoint2>();
       
        if ((callbackEndpoints != null) &&  (callbackEndpointReferences != null)){
            // Find the corresponding bindings from the service side
            for (EndpointReference2 epr : callbackEndpointReferences) {
                for (Endpoint2 ep : callbackEndpoints) {
   
                    if (epr.getBinding().getClass() == ep.getBinding().getClass() &&
                        hasCompatiblePolicySets(epr.getBinding(), ep.getBinding())) {
                       
                        matchedEndpoint.add(ep);             
                    }
                }
            }
        }
       
        if (matchedEndpoint.isEmpty()) {
            // No matching binding
            endpointReference.setCallbackEndpoint(null);
            warning(monitor,
                    "NoMatchingCallbackBinding",
                    endpointReference.getReference(),
                    endpointReference.getReference().getName(),
                    endpoint.getService().getName());
            return;
        } else {
            // default to using the first matched binding
            int selectedEndpoint = 0;
           
View Full Code Here

        assertEquals(policiedComposite.getRequiredIntents().size(), 1);
        assertEquals(policiedComposite.getRequiredIntents().get(0).getName(),
                     new QName(namespaceUri, "tuscanyIntent_1"));

        Component component = composite.getComponents().get(0);
        Endpoint2 ep = component.getServices().get(0).getEndpoints().get(0);
        EndpointReference2 epr = component.getReferences().get(0).getEndpointReferences().get(0);

        System.out.println(ep.getRequiredIntents());
        System.out.println(epr.getRequiredIntents());
    }
View Full Code Here

TOP

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

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.