Package org.apache.tuscany.sca.invocation

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


            msg.setFrom(epr);
            msg.setTo(epr.getTargetEndpoint());
        }
       
        Operation operation = msg.getOperation();
        InvocationChain chain = invocable.getInvocationChain(operation);

        if (chain == null) {
            throw new IllegalArgumentException("No matching operation is found: " + operation.getName());
        }
       
        // create an async message ID if there isn't one there already
        if (!msg.getHeaders().containsKey(Constants.MESSAGE_ID)){
            msg.getHeaders().put(Constants.MESSAGE_ID, UUID.randomUUID().toString());UUID.randomUUID().toString();
        }

        // Perform the async invocation
        Invoker headInvoker = chain.getHeadInvoker();

        Message msgContext = ThreadMessageContext.setMessageContext(msg);
        try {
            try {
                ((InvokerAsyncRequest)headInvoker).invokeAsyncRequest(msg);
View Full Code Here


     * exchange along the response part of the wire.
     *
     * @param msg the response message
     */
    public void invokeAsyncResponse(Message msg) { 
      InvocationChain chain = invocable.getInvocationChain(msg.getOperation());
        Invoker tailInvoker = chain.getTailInvoker();
        ((InvokerAsyncResponse)tailInvoker).invokeAsyncResponse(msg);      
    } // end method invokeAsyncResponse
View Full Code Here

                epr.rebuild();
                chains.clear();
            }
        }
       
        InvocationChain chain = getInvocationChain(method, source);
       
        if (chain == null) {
            throw new IllegalArgumentException("No matching operation is found: " + method);
        }       

        // Holder pattern. Items stored in a Holder<T> are promoted to T.
        // After the invoke, the returned data <T> are placed back in Holder<T>.
        Object [] promotedArgs = promoteHolderArgs( args );
       
        // Strip out OUT-only arguments.  Not too sure if the presence
        // of a sourceOperation is exactly the right check to use to
        // know whether or not to do this, but will assume it is until
        // learning otherwise.
        Operation sourceOp = chain.getSourceOperation();       
        if (sourceOp != null) {
            promotedArgs = removeOutOnlyArgs(sourceOp, promotedArgs );
        }
       
        Object result = invoke(method, chain, promotedArgs, source);
View Full Code Here

            return source.getBindingInvocationChain();
        }
        if (fixedWire && chains.containsKey(method)) {
            return chains.get(method);
        }
        InvocationChain found = null;
        for (InvocationChain chain : source.getInvocationChains()) {
            Operation operation = chain.getSourceOperation();
            if (operation.isDynamic()) {
                operation.setName(method.getName());
                found = chain;
View Full Code Here

                epr.rebuild();
                chains.clear();
            }
        } // end if

        InvocationChain chain = getInvocationChain(method, source);

        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
       
        if( isAsyncInvocation((RuntimeEndpointReference)source ) ) {
          isAsyncService = true;
          // Get hold of the JavaAsyncResponseHandler from the chain dealing with the async response
          Invoker theInvoker = chain.getHeadInvoker();
          if( theInvoker instanceof InterceptorAsync ) {
            InvokerAsyncResponse responseInvoker = ((InterceptorAsync)theInvoker).getPrevious();
            if( responseInvoker instanceof JDKAsyncResponseInvoker ) {
              // Register the future as the response object with its ID
              ((JDKAsyncResponseInvoker)responseInvoker).registerAsyncResponse(future.getUniqueID(), future);
View Full Code Here

            throw new ServiceRuntimeException("No callback wire found");
        }

        setEndpoint(((CallbackServiceReferenceImpl)callableReference).getResolvedEndpoint());

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

        try {
View Full Code Here

        EndpointReference target = wire.getTarget();
        if (target != null) {
            RuntimeComponentService service = (RuntimeComponentService)target.getContract();
            if (service != null) { // not a callback wire
                SCABinding scaBinding = service.getBinding(SCABinding.class);
                InvocationChain chain =
                    service.getInvocationChain(scaBinding, wire.getSource().getInterfaceContract(), operation);
                return chain == null ? null : new SCABindingInvoker(chain);
            }
        }
        return null;
View Full Code Here

            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

    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

public class InvocationChainImplTestCase {

    @Test
    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

TOP

Related Classes of org.apache.tuscany.sca.invocation.InvocationChain

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.