Examples of RuntimeEndpoint


Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

    public void createAsyncCallbackEndpoint(){
        CompositeContext compositeContext = getCompositeContext();
        FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
        RuntimeAssemblyFactory assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
       
        RuntimeEndpoint endpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
        endpoint.bind(compositeContext);
        endpoint.setComponent(getComponent());

        // Create pseudo-service
        ComponentService service = assemblyFactory.createComponentService();
        JavaInterfaceFactory javaInterfaceFactory =
            (JavaInterfaceFactory)modelFactories.getFactory(JavaInterfaceFactory.class);
        JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
        try {
            interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(AsyncResponseService.class));
        } catch (InvalidInterfaceException e1) {
            // Nothing to do here - will not happen
        } // end try
       
        service.setInterfaceContract(interfaceContract);
       
        String serviceName = getReference().getName() + "_asyncCallback";
        service.setName(serviceName);
        service.getEndpoints().add(endpoint);
        service.setForCallback(true);
        endpoint.setService(service);
       
        // Set pseudo-service onto the component
        getComponent().getServices().add(service);
       
        // if the reference has a WSDL contract reset the response endpoint to be WSDL also
        InterfaceContract referenceInterfaceContract = getComponentTypeReferenceInterfaceContract();
        if (referenceInterfaceContract instanceof WSDLInterfaceContract){
            WSDLInterfaceContract wsdlInterfaceContract = (WSDLInterfaceContract)endpoint.getGeneratedWSDLContract(interfaceContract);
            service.setInterfaceContract(wsdlInterfaceContract);
        }        

        // Create a binding
        // Mike had to go via the XML but I don't remember why
        Binding binding = null;
        try {
            binding = (Binding)getBinding().clone();
        } catch (Exception ex){
            //
        }
        String callbackURI = "/" + component.getName() + "/" + service.getName();
        binding.setURI(callbackURI);
       
        BuilderExtensionPoint builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
        BindingBuilder builder = builders.getBindingBuilder(binding.getType());
        if (builder != null) {
            org.apache.tuscany.sca.assembly.builder.BuilderContext builderContext = new BuilderContext(registry);
            builder.build(component, service, binding, builderContext, true);
        } // end if
       
        endpoint.setBinding(binding);

        // Need to establish policies here (binding has some...)
        endpoint.getRequiredIntents().addAll(getRequiredIntents());
        endpoint.getPolicySets().addAll(getPolicySets());
        String epURI = getComponent().getName() + "#service-binding(" + serviceName + "/" + serviceName + ")";
        endpoint.setURI(epURI);
        endpoint.setUnresolved(false);
       
        setCallbackEndpoint(endpoint);
    }
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

    // Need to establish policies here (binding has some...)
    epr.getRequiredIntents().addAll( endpoint.getRequiredIntents() );
    epr.getPolicySets().addAll( endpoint.getPolicySets() );
   
    // Attach a dummy endpoint to the epr
    RuntimeEndpoint ep = (RuntimeEndpoint)assemblyFactory.createEndpoint();
    ep.setUnresolved(false);
    epr.setTargetEndpoint(ep);
    //epr.setStatus(EndpointReference.Status.RESOLVED_BINDING);
    epr.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
    epr.setUnresolved(false);
   
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

            throw new JMSBindingException(e);
    }
    } // end method invokeRequest
   
    protected String getCallbackDestinationName(RuntimeEndpointReference reference) {
        RuntimeEndpoint endpoint = (RuntimeEndpoint) reference.getCallbackEndpoint();
        if (endpoint != null) {
            JMSBindingServiceBindingProvider bp = (JMSBindingServiceBindingProvider)endpoint.getBindingProvider();
            return bp.getDestinationName();
        }
        return null;
   
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

    public void configureBinding(Object configuration){
    }

    protected InvocationChain getInvocationChain() {
        if (subject instanceof RuntimeEndpoint) {
            RuntimeEndpoint endpoint = (RuntimeEndpoint)subject;
            List<InvocationChain> chains = endpoint.getInvocationChains();
            for (InvocationChain chain : chains) {
                configure(chain, chain.getTargetOperation());
            }

        } else if (subject instanceof RuntimeEndpointReference) {
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

          EndpointReference from = assemblyFactory.createEndpointReference();
            Endpoint fromEndpoint = assemblyFactory.createEndpoint();
            from.setTargetEndpoint(fromEndpoint);
            from.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
            msg.setFrom(from);
            RuntimeEndpoint callbackEndpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
            //
            WebServiceBinding cbBinding = webServiceBindingFactory.createWebServiceBinding();
            cbBinding.setURI(callbackAddress);
            callbackEndpoint.setBinding(cbBinding);
            //
            callbackEndpoint.setURI(callbackAddress);
            callbackEndpoint.setUnresolved(true);
            from.setCallbackEndpoint(callbackEndpoint);
        } // end if
    } // end method createCallbackEPR
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

            logger.warning("Mapped binding for binding.sca is not supported: " + bindingType);
            return null;
        }

        // create a copy of the endpoint  but with the web service binding in
        RuntimeEndpoint ep = null;
        try {
            ep = (RuntimeEndpoint)endpoint.clone();
        } catch (Exception ex) {
            // we know we can clone endpoint references
        }

        Binding binding = map(endpoint.getBinding(), bindingType);
        ep.setBinding(binding);
        BindingBuilder builder = getBindingBuilder(bindingType);
        if (builder != null) {
            builder.build(ep.getComponent(), ep.getService(), binding, new BuilderContext(registry), false);
        }
        return ep;
    }
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

        FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
        RuntimeAssemblyFactory assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
        WebServiceBindingFactory webServiceBindingFactory = (WebServiceBindingFactory)modelFactories.getFactory(WebServiceBindingFactory.class);
   
        // Create the endpoint
        RuntimeEndpoint callbackEndpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
        // Add a binding
        WebServiceBinding cbBinding = webServiceBindingFactory.createWebServiceBinding();
        cbBinding.setURI(callbackAddress);
        callbackEndpoint.setBinding(cbBinding);
        // Embed the response Address URI
        callbackEndpoint.setURI(callbackAddress);
        callbackEndpoint.setUnresolved(true);
    return callbackEndpoint;
  } // end method createAsyncResponseEndpoint
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

     */
    private void selectCallbackEndpoint(EndpointReference endpointReference, ComponentService callbackService, Audit matchAudit, BuilderContext builderContext, boolean runtime) {
     
        // find the first callback endpoint that matches a callback endpoint reference
        // at the service
        RuntimeEndpoint callbackEndpoint = null;
        match:
        for ( EndpointReference callbackEndpointReference : endpointReference.getTargetEndpoint().getCallbackEndpointReferences()){
            for (Endpoint endpoint : callbackService.getEndpoints()){
                if (haveMatchingPolicy(callbackEndpointReference, endpoint, matchAudit, builderContext) &&
                    haveMatchingInterfaceContracts(callbackEndpointReference, endpoint, matchAudit)){
                    callbackEndpoint = (RuntimeEndpoint)endpoint;
                    break match;
                }
            }
        }
       
        // if no callback endpoint was found or if the binding is the SCA binding and it doesn't match
        // the forward binding then create a new callback endpoint
        // TODO - there is a hole here in that the user may explicitly specify an SCA binding for the
        //        callback that is different from the forward binding. Waiting for feedback form OASIS
        //        before doing more drastic surgery to fix this corner case as there are other things
        //        wrong with the default case, such as what to do about policy
        if (callbackEndpoint == null ||
            (callbackEndpoint.getBinding().getType().equals(SCABinding.TYPE) &&
             !endpointReference.getBinding().getType().equals(SCABinding.TYPE))){
            // no endpoint in place so we need to create one
            callbackEndpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
            callbackEndpoint.setComponent(endpointReference.getComponent());
            callbackEndpoint.setService(callbackService);
           
            Binding forwardBinding = endpointReference.getBinding();
            Binding callbackBinding = null;
            for (EndpointReference callbackEPR : endpointReference.getTargetEndpoint().getCallbackEndpointReferences()){
                if (callbackEPR.getBinding().getType().equals(forwardBinding.getType())){
                    try {
                        callbackBinding = (Binding)callbackEPR.getBinding().clone();
                    } catch (CloneNotSupportedException ex){
                       
                    } 
                    break;
                }
            }
           
            // get the callback binding URI by looking at the SCA binding
            // that will have been added at build time
            callbackBinding.setURI(null);
            for (Endpoint endpoint : callbackService.getEndpoints()){
                if (endpoint.getBinding().getType().equals(SCABinding.TYPE)){
                    callbackBinding.setURI(endpoint.getBinding().getURI());
                }
            }
           
            callbackEndpoint.setBinding(callbackBinding);
            callbackService.getBindings().add(callbackBinding);
           
            callbackEndpoint.setUnresolved(false);
            callbackService.getEndpoints().add(callbackEndpoint);
           
            // build it
            build(callbackEndpoint);
           
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

            logger.fine("Activating component service: " + component.getURI() + "#" + service.getName());
        }

        // Add a wire for each service Endpoint
        for ( Endpoint endpoint : service.getEndpoints()){
            RuntimeEndpoint ep = (RuntimeEndpoint) endpoint;
            activate(compositeContext, ep);

            // create the interface contract for the binding and service ends of the wire
            // that are created as forward only contracts
            // FIXME: [rfeng] We might need a better way to get the impl interface contract
View Full Code Here

Examples of org.apache.tuscany.sca.runtime.RuntimeEndpoint

            for (ComponentService service : component.getServices()) {
                if (logger.isLoggable(Level.FINE)) {
                    logger.fine("Starting component service: " + component.getURI() + "#" + service.getName());
                }
                for (Endpoint endpoint : service.getEndpoints()) {
                    RuntimeEndpoint ep = (RuntimeEndpoint)endpoint;
                    startEndpoint(compositeContext, ep, providers);
                }
            }
           
            // Reference start is done after all components have been started to make sure everything
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.