Examples of InvocationChain


Examples of org.apache.tuscany.sca.invocation.InvocationChain

        invoker.invokeAsync(msg);
    }
   
    public void invokeAsyncResponse(Message msg){
      // If there is a Binding Chain, invoke it first...
        InvocationChain chain = this.getBindingInvocationChain();
        if( chain != null ) {
          Invoker tailInvoker = chain.getTailInvoker();
          if (tailInvoker != null) {
            ((InvokerAsyncResponse)tailInvoker).invokeAsyncResponse(msg);
      } // end if
        } // end if
       
        chain = this.getInvocationChain(msg.getOperation());
        Invoker tailInvoker = chain.getTailInvoker();
        ((InvokerAsyncResponse)tailInvoker).invokeAsyncResponse(msg);  
    } // end method invokeAsyncResponse    
View Full Code Here

Examples of org.apache.tuscany.sca.invocation.InvocationChain

                        + " is found in reference "
                        + getComponent().getURI()
                        + "#"
                        + reference.getName());
                }
                InvocationChain chain = new InvocationChainImpl(operation, targetOperation, true, phaseManager, isAsyncInvocation());
                if (operation.isNonBlocking()) {
                    addNonBlockingInterceptor(chain);
                }
                chainList.add(chain);
                addReferenceBindingInterceptor(chain, operation);
            }           
        }

        // Set the chains until it's fully populated. If we initialize too early, any exception could
        // leave this endpoint reference in a wrong state with an empty chain.
        chains = chainList;
        wireProcessor.process(this);
       
        if (isAsyncInvocation()){
            // Fix up all of the operation chain response paths to point back to the implementation provided
            // async response handler
            //ImplementationProvider implementationProvider = ((RuntimeComponent)getComponent()).getImplementationProvider();
          RuntimeComponentReference theReference = (RuntimeComponentReference)this.getReference();
          RuntimeComponent theComponent = theReference.getComponent();
            ImplementationProvider implementationProvider = theComponent.getImplementationProvider();
            if (implementationProvider instanceof ImplementationAsyncProvider){
                for (InvocationChain chain : getInvocationChains()){
                    InvokerAsyncResponse asyncResponseInvoker = ((ImplementationAsyncProvider)implementationProvider).createAsyncResponseInvoker(chain.getSourceOperation());
                    if (chain.getHeadInvoker() instanceof InterceptorAsync){
                        ((InterceptorAsync)chain.getHeadInvoker()).setPrevious(asyncResponseInvoker);
                    } else {
                        //TODO - throw error once the old async code is removed
                    } // end if
                } // end for
            } // end if
View Full Code Here

Examples of org.apache.tuscany.sca.invocation.InvocationChain

     * A dummy invocation chain representing null as ConcurrentHashMap doesn't allow null values
     */
    private static final InvocationChain NULL_CHAIN = new InvocationChainImpl(null, null, false, null, false);

    public InvocationChain getInvocationChain(Operation operation) {
        InvocationChain cached = invocationChainMap.get(operation);
        if (cached == null) {
            for (InvocationChain chain : getInvocationChains()) {
                Operation op = chain.getTargetOperation();

                // We used to check compatibility here but this is now validated when the
View Full Code Here

Examples of org.apache.tuscany.sca.invocation.InvocationChain

                    + " is found in service "
                    + serviceComponent.getURI()
                    + "#"
                    + service.getName());
            }
            InvocationChain chain = new InvocationChainImpl(operation, targetOperation, false, phaseManager, isAsyncInvocation());
            if (operation.isNonBlocking()) {
                addNonBlockingInterceptor(chain);
            }
            addServiceBindingInterceptor(chain, operation);
            addImplementationInterceptor(serviceComponent, service, chain, targetOperation);
            chains.add(chain);
           
            // Handle cases where the operation is an async server
            if( targetOperation.isAsyncServer() ) {
              createAsyncServerCallback();
            } // end if
        }

        wireProcessor.process(this);
       
        // If we have to support async and there is no binding chain
        // then set the response path to point directly to the
        // binding provided async response handler
        if (isAsyncInvocation() &&
            bindingInvocationChain == null){
            // fix up the operation chain response path to point back to the
            // binding provided async response handler
            ServiceBindingProvider serviceBindingProvider = getBindingProvider();
            if (serviceBindingProvider instanceof EndpointAsyncProvider){
                EndpointAsyncProvider asyncEndpointProvider = (EndpointAsyncProvider)serviceBindingProvider;
                InvokerAsyncResponse asyncResponseInvoker = asyncEndpointProvider.createAsyncResponseInvoker();
               
                for (InvocationChain chain : getInvocationChains()){
                    Invoker invoker = chain.getHeadInvoker();
                    if (invoker instanceof InterceptorAsync){
                        ((InterceptorAsync)invoker).setPrevious(asyncResponseInvoker);
                    } else {
                        //TODO - throw error once the old async code is removed
                    } // end if
View Full Code Here

Examples of org.apache.tuscany.sca.invocation.InvocationChain

    public Invoker getInvoker(Binding binding, Operation operation) {
        return getInvoker(binding, null, operation);
    }

    public Invoker getInvoker(Binding binding, InterfaceContract interfaceContract, Operation operation) {
        InvocationChain chain = getInvocationChain(binding, interfaceContract, operation);
        if (chain != null) {
            return chain.getHeadInvoker();
        } else {
            return null;
        }
    }
View Full Code Here

Examples of org.apache.tuscany.sca.invocation.InvocationChain

            return invokeObjectMethod(method, args);
        }
        if (wire == null) {
            throw new ServiceRuntimeException("No runtime wire is available");
        }
        InvocationChain chain = getInvocationChain(method, wire);
        if (chain == null) {
            throw new IllegalArgumentException("No matching operation is found: " + method);
        }

        // send the invocation down the wire
View Full Code Here

Examples of org.apache.tuscany.sca.invocation.InvocationChain

    protected synchronized InvocationChain getInvocationChain(Method method, RuntimeWire wire) {
        if (fixedWire && chains.containsKey(method)) {
            return chains.get(method);
        }
        InvocationChain found = null;
        for (InvocationChain chain : wire.getInvocationChains()) {
            Operation operation = chain.getSourceOperation();
            if (operation.isDynamic()) {
                operation.setName(method.getName());
                found = chain;
View Full Code Here

Examples of org.apache.tuscany.sca.invocation.InvocationChain

*/
public class InvocationChainImplTestCase extends TestCase {

    public void testInsertAtEnd() throws Exception {
        Operation op = newOperation("foo");
        InvocationChain chain = new InvocationChainImpl(op, op, true);
        Interceptor inter2 = new MockInterceptor();
        Interceptor inter1 = new MockInterceptor();
        chain.addInterceptor(inter1);
        chain.addInterceptor(inter2);
        Interceptor head = (Interceptor)chain.getHeadInvoker();
        assertEquals(inter1, head);
        assertEquals(inter2, head.getNext());
        assertEquals(inter2, chain.getTailInvoker());

    }
View Full Code Here

Examples of org.apache.tuscany.sca.invocation.InvocationChain

    }

    public void testAddByPhase() throws Exception {
        Operation op = newOperation("foo");
        InvocationChain chain = new InvocationChainImpl(op, op, false);
        Interceptor inter1 = new MockInterceptor();
        Interceptor inter2 = new MockInterceptor();
        Interceptor inter3 = new MockInterceptor();
        Interceptor inter4 = new MockInterceptor();
        chain.addInterceptor(inter3); // SERVICE
        chain.addInterceptor(Phase.IMPLEMENTATION_POLICY, inter4);
        chain.addInterceptor(Phase.SERVICE_POLICY, inter2);
        chain.addInterceptor(Phase.SERVICE_BINDING, inter1);
        Interceptor head = (Interceptor)chain.getHeadInvoker();
        assertEquals(inter1, head);
        assertEquals(inter2, inter1.getNext());
        assertEquals(inter3, inter2.getNext());
        assertEquals(inter4, inter3.getNext());
        assertEquals(inter4, chain.getTailInvoker());
    }
View Full Code Here

Examples of org.apache.tuscany.sca.invocation.InvocationChain

                        + " is found in reference "
                        + wireSource.getComponent().getURI()
                        + "#"
                        + reference.getName());
                }
                InvocationChain chain = new InvocationChainImpl(operation, targetOperation, true);
                if (operation.isNonBlocking()) {
                    addNonBlockingInterceptor(reference, refBinding, chain);
                }
                addReferenceBindingInterceptor(reference, refBinding, chain, operation);
                chains.add(chain);
            }
        } else {
            // It's the service wire
            RuntimeComponentService service = (RuntimeComponentService)wireTarget.getContract();
            RuntimeComponent serviceComponent = wireTarget.getComponent();
            Binding serviceBinding = wireTarget.getBinding();
            for (Operation operation : sourceContract.getInterface().getOperations()) {
                Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
                if (targetOperation == null) {
                    throw new ServiceRuntimeException("No matching operation for " + operation.getName()
                        + " is found in service "
                        + serviceComponent.getURI()
                        + "#"
                        + service.getName());
                }
                InvocationChain chain = new InvocationChainImpl(operation, targetOperation, false);
                if (operation.isNonBlocking()) {
                    addNonBlockingInterceptor(service, serviceBinding, chain);
                }
                addImplementationInterceptor(serviceComponent, service, chain, targetOperation);
                chains.add(chain);
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.