Package org.apache.tuscany.sca.assembly

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


        return response;
    }

    protected void setHeaders(SOAPHeader sh, Message msg, String action) throws SOAPException {

        Endpoint callbackEndpoint = msg.getFrom().getCallbackEndpoint();

        // add WS-Addressing header for the invocation of a bidirectional
        // service
        // FIXME: is there any way to use the Axis2 addressing support for this?
        //
        // IIUC, this 'if (callbackEndpoint != null)' will be true if:
        //   1)  This is a bidirectional interface  
        //      AND
        //   2)  We are invoking in the forward direction of the bidirectional interface.
        //
        if (callbackEndpoint != null) {
            // // Load the actual callback endpoint URI into an Axis EPR ready
            // to form the content of the wsa:From header
            // EndpointReference fromEPR = new
            // EndpointReference(callbackEndpoint.getBinding().getURI());
            //
            // addWSAFromHeader(sh, fromEPR);
            SOAPHeaderElement fromH = sh.addHeaderElement(QNAME_WSA_FROM);
            SOAPElement fromAddress = fromH.addChildElement(QNAME_WSA_ADDRESS);           
            fromAddress.setTextContent(callbackEndpoint.getDeployedURI());

            addWSAActionHeader(sh, action);

            // We need a wsa:MessageId for request-response operation per WS-Addressing core specification,
            // (and Axis2 will choke if addressing module is enabled.)
View Full Code Here


        // if target endpoint was not specified when this invoker was created,
        // use dynamically specified target endpoint passed in with the message

        String to = getPortLocation();
        if (to == null) {
            Endpoint ep = msg.getTo();
            if (ep != null && ep.getBinding() != null) {
                address = ep.getDeployedURI();
            } else {
                throw new ServiceRuntimeException(
                                                  "[BWS20025] Unable to determine destination endpoint for endpoint reference " + endpointReference);
            }
        } else {
View Full Code Here

    public Endpoint readEndpoint(String xml) {
        try {
            //System.out.println("Read Endpoint string >> " + xml);
            XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml));
            Endpoint result = processor.read(reader, new ProcessorContext(registry));
            result.setRemote(true);
            reader.close();
            return result;
        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
        }
View Full Code Here

                   
                    if (haveMatchingPolicy(endpointReference, endpoint, matchAudit, builderContext) &&
                        haveMatchingInterfaceContracts(endpointReference, endpoint, matchAudit)){
                        // matching service so find if this reference already has
                        // an endpoint reference for this endpoint
                        Endpoint autowireEndpoint = null;
                       
                        for (EndpointReference epr : endpointReference.getReference().getEndpointReferences()){
                            if (epr.getTargetEndpoint() == endpoint){
                                autowireEndpoint = endpoint;
                                break;
View Full Code Here

        Binding b = null;
        if (unknownEndpointHandler != null) {
            b = unknownEndpointHandler.handleUnknownEndpoint(endpointReference);
        }
        if (b != null) {
            Endpoint matchedEndpoint = new RuntimeEndpointImpl(extensionPoints);
            matchedEndpoint.setBinding(b);
            matchedEndpoint.setRemote(true);
            endpointReference.setTargetEndpoint(matchedEndpoint);
            endpointReference.setBinding(b);
            endpointReference.setUnresolved(false);
            endpointReference.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
            matchAudit.append("Match because the UnknownEndpointHandler provided a binding: " + b.getType() + " uri: " + b.getURI());
View Full Code Here

     * @param endpointReference
     * @param endpoints
     */
    private void selectForwardEndpoint(EndpointReference endpointReference, List<Endpoint> endpoints, Audit matchAudit, BuilderContext builderContext, boolean runtime) {   
            
        Endpoint matchedEndpoint = null;
       
        if (endpointReference.getReference().getName().startsWith("$self$.")){
            // just select the first one and don't do any policy matching
            if (endpointReference.getTargetEndpoint() != null && !endpointReference.getTargetEndpoint().isUnresolved()) {
                matchedEndpoint = endpointReference.getTargetEndpoint();
            } else {
                matchedEndpoint = endpoints.get(0);
            }
        } else {
            // find the endpoints that match this endpoint reference
            List<Endpoint> matchedEndpoints = new ArrayList<Endpoint>();
           
            for (Endpoint endpoint : endpoints){
                if (haveMatchingPolicy(endpointReference, endpoint, matchAudit, builderContext) &&
                    haveMatchingInterfaceContracts(endpointReference, endpoint, matchAudit)){
                    matchedEndpoints.add(endpoint);
                }
            }
           
            // TUSCANY-4005 - raise an error if a reference target that only specifies the
            //                component name matches more than one component service
            if (endpointReference.getTargetEndpoint().getService() == null &&
                endpointReference.getTargetEndpoint().getBinding() == null &&
                matchedEndpoints.size() > 1   ) {
               
                String serviceName = null;
                for (Endpoint endpoint : matchedEndpoints){
                    // ignore service names called "default" as these indicate dynamic services
                    // created for the likes of implementation.python
                    if (serviceName == null &&
                        !endpoint.getService().getName().equals("default")){
                        serviceName = endpoint.getService().getName();
                    }
                   
                    if (serviceName != null &&
                        !endpoint.getService().getName().equals("default") &&
                        !endpoint.getService().getName().equals(serviceName)){
                        if (runtime){
                            Monitor.error(monitor,
                                          this,
                                          "endpoint-validation-messages",
                                          "TooManyTargetServices",
                                          endpointReference.toString(),
                                          endpointReference.getTargetEndpoint().toString(),
                                          matchAudit);
                            throw new ServiceRuntimeException("Unable to bind " +
                                                              monitor.getLastProblem().toString());
                        } else {
                            Monitor.warning(monitor,
                                            this,
                                            "endpoint-validation-messages",
                                            "TooManyTargetServices",
                                            endpointReference.toString(),
                                            endpointReference.getTargetEndpoint().toString());
                            return;
                        }
                    }
                }
            }
           
            // TUSCANY-3941 check for the case where the user has provided a
            //              binding.sca at the reference and make sure we pick
            //              a binding.sca at the service regardless of how many
            //              other bindings are provided
            if (endpointReference.getBinding() != null &&
                endpointReference.getBinding() instanceof SCABinding ){
                for (Endpoint endpoint : matchedEndpoints){
                    if (endpoint.getBinding() instanceof SCABinding){
                        matchedEndpoint = endpoint;
                        break;
                    }
                }
            }

            if (matchedEndpoint == null) {
                // just take the first matched endpoint from the list
                if (matchedEndpoints.size() > 0){
                    matchedEndpoint = matchedEndpoints.get(0);
                }
            }
        }
       
        if (matchedEndpoint == null){
            return;
        } else {
            endpointReference.setTargetEndpoint(matchedEndpoint);
            Binding binding = matchedEndpoint.getBinding();
            try {
                endpointReference.setBinding((Binding)binding.clone());
            } catch (CloneNotSupportedException e) {
                // shouldn't happen
                throw new RuntimeException(e);
            }
            // TUSCANY-3873 - add policy from the service
            //                we don't care about intents at this stage
            endpointReference.getPolicySets().addAll(matchedEndpoint.getPolicySets());
           
            // TODO - we need to re-run the appliesTo processing here but there is some question about what
            //        appliesTo means. It's also difficult to get to the PolicyAppliesToBuilder from here and
            //        need a new EntensionInterface to support access. So for now I'm just cheating and looking to
            //        see if the XPath expression contains the binding type as a string while we discuss appliesTo
View Full Code Here

     * Checks to see if the registry has been updated since the reference was last matched
     *
     * @return true is the registry has changed
     */
    public boolean isOutOfDate(DomainRegistry domainRegistry, EndpointReference endpointReference) {
        Endpoint te = endpointReference.getTargetEndpoint();
        if (te != null && !te.isUnresolved()
            && te.getURI() != null
            && endpointReference.getStatus() != EndpointReference.Status.RESOLVED_BINDING) {
            return domainRegistry.isOutOfDate(endpointReference);
        }
        return false;
    }
View Full Code Here

        return null;

    }

    public synchronized void updateEndpoint(String uri, Endpoint endpoint) {
        Endpoint oldEndpoint = getEndpoint(uri);
        if (oldEndpoint == null) {
            throw new IllegalArgumentException("Endpoint is not found: " + uri);
        }
        endpoints.remove(oldEndpoint);
        endpoints.add(endpoint);
View Full Code Here

    public synchronized void start() {
    }

    public synchronized void stop() {
        for (Iterator<Endpoint> i = endpoints.iterator(); i.hasNext();) {
            Endpoint ep = i.next();
            i.remove();
            endpointRemoved(ep);
        }
        endpointreferences.clear();
        listeners.clear();
View Full Code Here

    public QName getArtifactType() {
        return ENDPOINT_QNAME;
    }

    public Endpoint read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
        Endpoint endpoint = assemblyFactory.createEndpoint();
        if (reader.getEventType() == XMLStreamConstants.START_DOCUMENT) {
            reader.nextTag();
        }
        if (reader.getEventType() == XMLStreamConstants.START_ELEMENT && ENDPOINT_QNAME.equals(reader.getName())) {
            // Skip the "endpoint" element wrapper
            reader.nextTag();
        }
        Object model = extensionProcessor.read(reader, context);
        if (model instanceof Composite) {
            Composite composite = (Composite)model;
            Component component = composite.getComponents().get(0);
            ComponentService service = component.getServices().get(0);
            Binding binding = service.getBindings().isEmpty() ? null : service.getBindings().get(0);
            endpoint.setComponent(component);
            endpoint.setService(service);
            endpoint.setBinding(binding);
           
            // We use the name of the composite to indicate if this is a callback endpoint
            // saves passing other extension attributes
            if (composite.getName().equals(CALLBACK_ENDPOINT_QNAME)){
                service.setForCallback(true);
            }
           
            // retrieve the stash of intents and policy sets from the component
            endpoint.getRequiredIntents().addAll(component.getRequiredIntents());
            endpoint.getPolicySets().addAll(component.getPolicySets());
        }
        return endpoint;
    }
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.