Package org.apache.tuscany.sca.assembly

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


            if (callbackAddress != null ) {
                    // Check for special (& not allowed!) WS_Addressing values
                    checkCallbackAddress( callbackAddress, request );
                    //
                from = assemblyFactory.createEndpointReference();
                Endpoint fromEndpoint = assemblyFactory.createEndpoint();
                from.setTargetEndpoint(fromEndpoint);
                from.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
                requestMsg.setFrom(from);
                Endpoint callbackEndpoint = assemblyFactory.createEndpoint();
                //
                WebServiceBinding cbBinding = webServiceBindingFactory.createWebServiceBinding();
                cbBinding.setURI(callbackAddress);
                callbackEndpoint.setBinding(cbBinding);
                //
                callbackEndpoint.setURI(callbackAddress);
                callbackEndpoint.setUnresolved(true);
                from.setCallbackEndpoint(callbackEndpoint);
            }

            Message responseMsg = endpoint.invoke(operation, requestMsg);
           
View Full Code Here


           
            ComponentReference ref = (composite.getComponents().get(0).getReferences().get(0));
           
            Assert.assertEquals(1, ref.getEndpoints().size());
           
            Endpoint endpoint = ref.getEndpoints().get(0);
           
            EndpointResolverFactory<Endpoint> factory = new EndpointResolverFactoryImpl(extensionPoints);
           
            EndpointResolver endpointResolver = factory.createEndpointResolver(endpoint, null);
           
View Full Code Here

                                    break;
                                }
                            }
                        } else {
                            // create a new endpoint to represent this promoted binding
                            Endpoint endpoint = endpointFactory.createEndpoint();
                            endpoint.setTargetName(binding.getURI());
                            endpoint.setSourceComponent(null); // TODO - fixed up at start
                            endpoint.setSourceComponentReference(promotedReference)
                            endpoint.setInterfaceContract(reference.getInterfaceContract());
                            endpoint.setSourceBinding(binding);
                            endpointsToCopyDown.add(endpoint);
                        }
                    }
                }
               
                if (bindingsToCopyDown.size() > 0) {
                    promotedReference.getBindings().clear();
                    promotedReference.getBindings().addAll(bindingsToCopyDown);
                   
                    promotedReference.getEndpoints().clear();
                    promotedReference.getEndpoints().addAll(endpointsToCopyDown);
                }
            }
           
            if (promotedReference.getBindings().size() > 1) {
                warning(monitor, "ComponentReferenceMoreWire", promotedReference, promotedReference.getName());               
            }
        } else {
            // if necessary merge the promoted endpoints (and bindings) with the top level bindings
            if (reference.getBindings().size() > 0 ){
               
                for (Binding binding : reference.getBindings()) {
                    if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) {
                        promotedReference.getBindings().add(binding);
                       
                        if (reference instanceof ComponentReference){
                            for (Endpoint endpoint : ((ComponentReference)reference).getEndpoints()){
                                if ( endpoint.getSourceBinding() == binding){
                                    promotedReference.getEndpoints().add(endpoint);
                                    break;
                                }
                            }
                        } else {
                            // create a new endpoint to represent this promoted binding
                            Endpoint endpoint = endpointFactory.createEndpoint();
                            endpoint.setTargetName(binding.getURI());
                            endpoint.setSourceComponent(null); // TODO - fixed up at start
                            endpoint.setSourceComponentReference(promotedReference);
                            endpoint.setInterfaceContract(reference.getInterfaceContract());
                            endpoint.setSourceBinding(binding);
                            promotedReference.getEndpoints().add(endpoint);
                        }
                    }
                }               
            }           
View Full Code Here

                    // 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("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("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("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("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()) {
                    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("NoComponentReferenceTarget", componentReference, componentReference.getName());
                }
            }
        }
           
               
        // if no endpoints have found so far retrieve any target names that are in binding URIs
        if (endpoints.isEmpty()){
            for (Binding binding : componentReference.getBindings()) {

                String uri = binding.getURI();
               
                // user hasn't put a uri on the binding so it's not a target name
                if (uri == null) {
                    continue;
                }
               
                // user might have put a local target name in the uri so get
                // the path part and 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;
                String path = null;
               
                try {
                    path = URI.create(uri).getPath();
                } catch(Exception ex){
                    // just assume that no target is identified if
                    // a URI related exception is thrown
                }
               
                if (path != null) {
                    if (path.startsWith("/")) {
                        path = path.substring(1);
                    }
                                                  
                    // Resolve the target component and service
                    targetComponentService = componentServices.get(path);
                    int s = path.indexOf('/');
                    if (s == -1) {
                        targetComponent = components.get(path);
                    } else {
                        targetComponent = components.get(path.substring(0, s));
                    }
                }

                // if the path of the binding URI matches a component in the
                // composite then configure an endpoint 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 (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().add(binding);
                        endpoints.add(endpoint);                       
                    } else {
                        warning("ReferenceIncompatibleInterface",
                                composite,
                                composite.getName().toString(),
                                componentReference.getName(),
                                uri);
                    }
                } else {
                   
                    // create endpoints for manually configured bindings
                    Endpoint endpoint = endpointFactory.createEndpoint();
                    endpoint.setTargetName(uri);
                    endpoint.setSourceComponent(null); // TODO - fixed up at start
                    endpoint.setSourceComponentReference(componentReference);  
                    endpoint.setInterfaceContract(componentReference.getInterfaceContract());
                    endpoint.setSourceBinding(binding);
                    endpoints.add(endpoint);
                }
            }
        }
View Full Code Here

        }

        // TODO: TUSCANY-2580: before returning null see if a candidate binding matches
        for (RuntimeWire wire : getRuntimeWires()) {
            if (wire instanceof EndpointWireImpl) {
                Endpoint endpoint = ((EndpointWireImpl)wire).getEndpoint();
                for (Binding b : endpoint.getCandidateBindings()) {
                    if (b == binding) {
                        return wire;
                    }
                }
            }
View Full Code Here

           
            ComponentReference ref = (composite.getComponents().get(0).getReferences().get(0));
           
            Assert.assertEquals(1, ref.getEndpoints().size());
           
            Endpoint endpoint = ref.getEndpoints().get(0);
           
            EndpointResolverFactory<Endpoint> factory = new EndpointResolverFactoryImpl(extensionPoints);
           
            EndpointResolver endpointResolver = factory.createEndpointResolver(endpoint, null);
           
View Full Code Here

        Object[] args = JSONUtil.decodePayloadForOperation(jsonParams, operation);
        Message msg = new MessageImpl();
        msg.getHeaders().put(Constants.MESSAGE_ID, channel.getId());
        msg.setBody(args);
        EndpointReference re = assemblyFactory.createEndpointReference(); //new RuntimeEndpointReferenceImpl();
        Endpoint callbackEndpoint = assemblyFactory.createEndpoint(); //new RuntimeEndpointImpl();
        callbackEndpoint.setURI(request.getOperation());
        re.setCallbackEndpoint(callbackEndpoint);
        msg.setFrom(re);
        endpoint.invoke(operation, msg);
    }
View Full Code Here

        reg2.stop();
    }

    private Endpoint assertExists(HazelcastDomainRegistry reg, String uri) throws InterruptedException {
        Endpoint ep = reg.getEndpoint(uri);
        Assert.assertNotNull(ep);
        Assert.assertEquals(uri, ep.getURI());
        return ep;
    }
View Full Code Here

        }
       
        InterfaceContract wsdlInterfaceContract = (WSDLInterfaceContract)endpointReference.getGeneratedWSDLContract(componentTypeRefInterfaceContract);

        // Validation may be unnecessary.  This check may already be guaranteed at this point, not sure.
        Endpoint target = endpointReference.getTargetEndpoint();
        InterfaceContract targetInterfaceContract = target.getComponentServiceInterfaceContract();
        try {
            interfaceContractMapper.checkCompatibility(wsdlInterfaceContract, targetInterfaceContract,
                                                       Compatibility.SUBSET, true, false);
        } catch (IncompatibleInterfaceContractException exc) {
            throw new ServiceRuntimeException(exc);
View Full Code Here

    @Override
    public Invoker createInvoker(Operation operation) {
        Invoker result = null;
        BindingSCATransformer bindingTransformer = null;
           
        Endpoint target = endpointReference.getTargetEndpoint();
        if (target != null) {
            RuntimeComponentService service = (RuntimeComponentService) target.getService();
            if (service != null) { // not a callback wire
                               
                InvocationChain chain = ((RuntimeEndpoint) target).getInvocationChain(operation);

                boolean passByValue = false;
View Full Code Here

TOP

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

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.