Package org.apache.tuscany.sca.runtime

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


    public void process(RuntimeEndpointReference endpointReference) {
        if(!(endpointReference instanceof RuntimeEndpointReference)) {
            return;
        }
        RuntimeEndpointReference epr = (RuntimeEndpointReference) endpointReference;
        Contract contract = epr.getReference();
        if (!(contract instanceof RuntimeComponentReference)) {
            return;
        }
        RuntimeComponent component = (RuntimeComponent) epr.getComponent();
        if (component == null) {
            return;
        }
        Implementation implementation = component.getImplementation();
        if (!(implementation instanceof JavaImplementation)) {
            return;
        }
        JavaImplementation javaImpl = (JavaImplementation)implementation;
        Endpoint callbackEndpoint = epr.getCallbackEndpoint();
        if (callbackEndpoint != null) {
            Interface iface = callbackEndpoint.getService().getInterfaceContract().getInterface();
            if (!supportsCallbackInterface(iface, javaImpl)) {
                // callback to this impl is not possible, so ensure a callback object is set
                for (InvocationChain chain : epr.getInvocationChains()) {
                    chain.addInterceptor(Phase.REFERENCE, new CallbackInterfaceInterceptor());
                }
            }
        }
    }
View Full Code Here


                RuntimeComponentReference callbackReference = (RuntimeComponentReference)service.getCallbackReference();
                if (callbackReference != null) {
                    List<EndpointReference> wires = callbackReference.getEndpointReferences();
                    if (!wires.isEmpty()) {
                        RuntimeEndpointReference epr = (RuntimeEndpointReference) wires.get(0);
                        callbackWires.put(epr.getComponentTypeReferenceInterfaceContract().getInterface().toString(),
                                          wires);
                    }
                }
            }
View Full Code Here

   * @param msg - the incoming message
   * @return - a CallBackServiceReference
   */
  @SuppressWarnings("unchecked")
  private ServiceReference<AsyncResponseHandler<?>> getAsyncCallbackRef( Message msg ) {
      RuntimeEndpointReference callbackEPR = (RuntimeEndpointReference) msg.getHeaders().get(Constants.ASYNC_CALLBACK);
      if( callbackEPR == null ) return null;
     
      CompositeContext compositeContext = callbackEPR.getCompositeContext();
        registry = compositeContext.getExtensionPointRegistry();
      ProxyFactory proxyFactory = ExtensibleProxyFactory.getInstance(registry);
      msgFactory = getMessageFactory();
      List<EndpointReference> eprList = new ArrayList<EndpointReference>();
      eprList.add(callbackEPR);
View Full Code Here

            if (logger.isLoggable(Level.FINE)) {
                logger.fine("Stopping component reference: " + component.getURI() + "#" + reference.getName());
            }

            for (EndpointReference endpointReference : reference.getEndpointReferences()) {
                RuntimeEndpointReference epr = (RuntimeEndpointReference) endpointReference;
                stop(epr);
            }
        }
        Implementation implementation = component.getImplementation();
        if (implementation instanceof Composite) {
View Full Code Here

        if (logger.isLoggable(Level.FINE)) {
            logger.fine("Starting component reference: " + component.getURI() + "#" + reference.getName());
        }
       
        for (EndpointReference endpointReference : reference.getEndpointReferences()){
            RuntimeEndpointReference epr = (RuntimeEndpointReference)endpointReference;

            // If the reference is already resolved then start it now. This currently
            // important for async references which have native async bindings as the
            // reference provider has to register a response listener regardless of
            // whether the reference has been used or not.
            if (epr.getStatus() == EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED ||
                epr.getStatus() == EndpointReference.Status.RESOLVED_BINDING){
               
                // As we only care about starting references at build time in the
                // async case at the moment check that the binding supports native async
                // and that the reference is an async reference
                ReferenceBindingProvider bindingProvider = epr.getBindingProvider();
                if (bindingProvider instanceof EndpointReferenceAsyncProvider &&
                    ((EndpointReferenceAsyncProvider)bindingProvider).supportsNativeAsync() &&
                    epr.isAsyncInvocation()){
                    // it's resolved so start it now
                    try {
                        // The act of getting invocation chains starts the reference in the late binding case
                        // so just use that here
                        epr.getInvocationChains();
                    } catch (Throwable ex){
                        Monitor.error(monitor, this, "core-messages", "StartException", ex);
                        rethrow(ex);
                   
                }
View Full Code Here

        if (logger.isLoggable(Level.FINE)) {
            logger.fine("Stopping component reference: " + component.getURI() + "#" + reference.getName());
        }
        RuntimeComponentReference runtimeRef = ((RuntimeComponentReference)reference);
        for ( EndpointReference endpointReference : runtimeRef.getEndpointReferences()){
            RuntimeEndpointReference epr = (RuntimeEndpointReference) endpointReference;
            stop(epr);
        }
    }
View Full Code Here

        if (source == null) {
            throw new ServiceRuntimeException("No runtime source is available");
        }

        if (source instanceof RuntimeEndpointReference) {
            RuntimeEndpointReference epr = (RuntimeEndpointReference)source;
            if (epr.isOutOfDate()) {
                epr.rebuild();
                chains.clear();
            }
        } // end if

        InvocationChain chain = getInvocationChain(method, source);
View Full Code Here

     * @return - the RuntimeEndpoint of the async callback
     */
    private RuntimeEndpoint getAsyncCallback(Invocable source) {
        if (!(source instanceof RuntimeEndpointReference))
            return null;
        RuntimeEndpointReference epr = (RuntimeEndpointReference)source;
        if (!isAsyncInvocation(epr)) return null;
       
        // Check to see if the binding supports async invocation natively
        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

     * @return - true if the invocation is async
     */
    private boolean isAsyncInvocation(Invocable source) {
        if (!(source instanceof RuntimeEndpointReference))
            return false;
        RuntimeEndpointReference epr = (RuntimeEndpointReference)source;
        // First check is to see if the EPR itself has the asyncInvocation intent marked
        for (Intent intent : epr.getRequiredIntents()) {
            if (intent.getName().equals(ASYNC_INVOKE))
                return true;
        } // end for

        // Second check is to see if the target service has the asyncInvocation intent marked
        Endpoint ep = epr.getTargetEndpoint();
        for (Intent intent : ep.getRequiredIntents()) {
            if (intent.getName().equals(ASYNC_INVOKE))
                return true;
        } // end for
        return false;
View Full Code Here

    } // end isAsyncInvocation
   
    private boolean supportsNativeAsync(Invocable source) {
      if (!(source instanceof RuntimeEndpointReference))
            return false;
        RuntimeEndpointReference epr = (RuntimeEndpointReference)source;
       
        // TODO - need to update this once BindingProvider interface is refactored to contain
        // supportsNativeAsync directly...
        ReferenceBindingProvider provider = epr.getBindingProvider();
        if( provider instanceof EndpointReferenceAsyncProvider ) {
          return ((EndpointReferenceAsyncProvider)provider).supportsNativeAsync();
        } else {
          return false;
        } // end if
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.runtime.RuntimeEndpointReference

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.