Examples of RuntimeEndpoint


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

        //      - will find it here if the system has constructed the callback binding based on the forward binding
        //
        // 2 and 3 are conflated in the distributed case as be write any derived callback bindings out into the
        // callback structure as the endpoint is serialized across the domain
       
        RuntimeEndpoint callbackEndpoint = null;
       
        // 1/ look in callback endpoints at the reference
        //      - exploiting the assumption that the user will specific callback bindings of
        //        the same type as the forward binding
        match1:
        for(Endpoint loopCallbackEndpoint : callbackService.getEndpoints()){
            if(loopCallbackEndpoint.getBinding().getType().equals(endpointReference.getBinding().getType())){
                callbackEndpoint = (RuntimeEndpoint)loopCallbackEndpoint;
                break match1;
            }
        }  
       
        // if no callback endpoint was found then create a new callback endpoint
        if (callbackEndpoint == null ){
            callbackEndpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
            callbackEndpoint.setComponent(endpointReference.getComponent());
            callbackEndpoint.setService(callbackService);
           
            Binding forwardBinding = endpointReference.getBinding();
            Binding callbackBinding = null;
           
            // 2/  look in the service callback structure
            Callback serviceCallback = endpointReference.getTargetEndpoint().getService().getCallback();
           
            if (serviceCallback != null){
                for(Binding loopCallbackBinding : serviceCallback.getBindings()){
                    if(loopCallbackBinding.getType().equals(endpointReference.getBinding().getType())){
                        callbackBinding = loopCallbackBinding;
                        break;
                    }
                }
            }

            // 3/ look in the service endpoint callback reference structure
            ComponentReference callbackReference = endpointReference.getTargetEndpoint().getService().getCallbackReference();
           
            if (callbackReference != null){
                for (EndpointReference loopEndpointReference : callbackReference.getEndpointReferences()){
                    if (loopEndpointReference.getBinding().getType().equals(endpointReference.getBinding().getType())){
                        callbackBinding = loopEndpointReference.getBinding();
                        break;
                    }
                }
            }
           
            // if all else fails clone the forward binding
            // TODO - do we ever get here?
            if (callbackBinding == null){
                try {
                    callbackBinding = (Binding)forwardBinding.clone();
                } catch (CloneNotSupportedException ex){
                } 
            }

            // 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

    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

                from = assemblyFactory.createEndpointReference();
                Endpoint fromEndpoint = assemblyFactory.createEndpoint();
                from.setTargetEndpoint(fromEndpoint);
                from.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
                requestMsg.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);
            }

            Message responseMsg = endpoint.invoke(operation, requestMsg);
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

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

        for (ComponentService service : component.getServices()) {
            if (logger.isLoggable(Level.FINE)) {
                logger.fine("Stopping component service: " + component.getURI() + "#" + service.getName());
            }
            for (Endpoint endpoint : service.getEndpoints()) {
                RuntimeEndpoint ep = (RuntimeEndpoint) endpoint;
                stop(ep);
            }
        }
        for (ComponentReference reference : component.getReferences()) {
            if (logger.isLoggable(Level.FINE)) {
View Full Code Here

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

        if (chain == null) {
            throw new IllegalArgumentException("No matching operation is found: " + method);
        }

        // Organize for an async service
        RuntimeEndpoint theEndpoint = getAsyncCallback(source);
        boolean isAsyncService = false;
        if (theEndpoint != null) {
            // ... the service is asynchronous but binding does not support async natively ...
            attachFuture(theEndpoint, future);
        } // end if
View Full Code Here

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

        ReferenceBindingProvider eprProvider = epr.getBindingProvider();
        if( eprProvider instanceof EndpointReferenceAsyncProvider) {
          if( ((EndpointReferenceAsyncProvider)eprProvider).supportsNativeAsync() ) return null;
        } // end if
       
        RuntimeEndpoint endpoint;
        synchronized (epr) {
            endpoint = (RuntimeEndpoint)epr.getCallbackEndpoint();
            // If the async callback endpoint is already created, return it...
            if (endpoint != null)
                return endpoint;
            // Create the endpoint for the async callback
            endpoint = createAsyncCallbackEndpoint(epr);
            epr.setCallbackEndpoint(endpoint);
        } // end synchronized

        // Activate the new callback endpoint
        startEndpoint(epr.getCompositeContext(), endpoint);
        endpoint.getInvocationChains();

        return endpoint;
    } // end method setupAsyncCallback
View Full Code Here

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

     * @return - a RuntimeEndpoint representing the callback endpoint
     */
    private RuntimeEndpoint createAsyncCallbackEndpoint(RuntimeEndpointReference epr) {
        CompositeContext compositeContext = epr.getCompositeContext();
        RuntimeAssemblyFactory assemblyFactory = getAssemblyFactory(compositeContext);
        RuntimeEndpoint endpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
        endpoint.bind(compositeContext);

        // Create a pseudo-component and pseudo-service
        // - need to end with a chain with an invoker into the AsyncCallbackHandler class
        RuntimeComponent fakeComponent = null;
        try {
            fakeComponent = (RuntimeComponent)epr.getComponent().clone();
            applyImplementation(fakeComponent);
        } catch (CloneNotSupportedException e2) {
            // will not happen
        } // end try
        endpoint.setComponent(fakeComponent);

        // Create pseudo-service
        ComponentService service = assemblyFactory.createComponentService();
        ExtensionPointRegistry registry = compositeContext.getExtensionPointRegistry();
        FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
        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 = epr.getReference().getName() + "_asyncCallback";
        service.setName(serviceName);
        // MJE 06/12/2010 - fixup for JMS binding code which looks at the implementation service
        // as well as the component service...
        // Create a pseudo implementation service...
        Service implService = assemblyFactory.createService();
        implService.setName(serviceName);
        implService.setInterfaceContract(interfaceContract);
        service.setService(implService);
        //
        endpoint.setService(service);
        // Set pseudo-service onto the pseudo-component
        List<ComponentService> services = fakeComponent.getServices();
        services.clear();
        services.add(service);

        // Create a binding
        Binding binding = createMatchingBinding(epr.getBinding(), fakeComponent, service, registry);
        endpoint.setBinding(binding);

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

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

        this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
    }

    public InterfaceContract getBindingInterfaceContract() {
        // Check if there is a target
        RuntimeEndpoint endpoint = (RuntimeEndpoint)endpointReference.getTargetEndpoint();
        if (endpoint != null) {
            return endpoint.getComponentTypeServiceInterfaceContract();
        } else {
            return endpointReference.getComponentTypeReferenceInterfaceContract();
        }
    }
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.