Package org.apache.tuscany.sca.invocation

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


        } else {
            msg.setFrom(epFrom);
        }
        msg.setTo(wire.getTarget());

        Invoker headInvoker = chain.getHeadInvoker();
        Operation operation = chain.getTargetOperation();
        msg.setOperation(operation);

        Message msgContext = ThreadMessageContext.getMessageContext();
        Object currentConversationID = msgContext.getFrom().getReferenceParameters().getConversationID();

        ThreadMessageContext.setMessageContext(msg);
        try {
            conversationPreinvoke(msg);
            // handleCallback(msg, currentConversationID);
            // dispatch the wire down the chain and get the response
            Message resp = headInvoker.invoke(msg);
            Object body = resp.getBody();
            if (resp.isFault()) {
                throw new InvocationTargetException((Throwable)body);
            }
            return body;
View Full Code Here


    public Invoker createInvoker(Operation operation) {
        if (isTargetRemote()) {
            return getDistributedProvider().createInvoker(operation);
        } else {
            RuntimeWire wire = reference.getRuntimeWire(binding);
            Invoker invoker = getInvoker(wire, operation);
            if (invoker == null) {
                throw new ServiceUnavailableException("Unable to create SCA binding invoker for local target " + component.getName()
                    + " reference "
                    + reference.getName()
                    + " (bindingURI="
View Full Code Here

                String convIdFromThread = createConversationID();
                msg.setConversationID(convIdFromThread);
            }
        }

        Invoker headInvoker = chain.getHeadInvoker();
        msg.setCorrelationID(msgContext.getCorrelationID());
        Operation operation = chain.getTargetOperation();
        Interface contract = operation.getInterface();
        if (contract != null && contract.isConversational()) {
            ConversationSequence sequence = chain.getTargetOperation().getConversationSequence();
            if (sequence == ConversationSequence.CONVERSATION_END) {
                msg.setConversationSequence(ConversationSequence.CONVERSATION_END);
                conversationStarted = false;
            } else if (sequence == ConversationSequence.CONVERSATION_CONTINUE) {
                if (conversationStarted) {
                    msg.setConversationSequence(ConversationSequence.CONVERSATION_CONTINUE);
                } else {
                    conversationStarted = true;
                    msg.setConversationSequence(ConversationSequence.CONVERSATION_START);
                }
            }
        }
        msg.setBody(args);
        msg.setFrom(wire.getSource());
        msg.setTo(wire.getTarget());
        ThreadMessageContext.setMessageContext(msg);
        try {
            // dispatch the wire down the chain and get the response
            Message resp = headInvoker.invoke(msg);
            Object body = resp.getBody();
            if (resp.isFault()) {
                throw (Throwable)body;
            }
            return body;
View Full Code Here

        this.sourceOperation = sourceOperation;
    }

    public void addInterceptor(int index, Interceptor interceptor) {
        int i = 0;
        Invoker next = invokerChainHead;
        Invoker prev = null;
        while (next != null && i < index) {
            prev = next;
            if (next instanceof Interceptor) {
                next = ((Interceptor)next).getNext();
                i++;
View Full Code Here

        Servlet servlet = null;
        for (InvocationChain invocationChain : wire.getInvocationChains()) {
            Operation operation = invocationChain.getTargetOperation();
            String operationName = operation.getName();
            if (operationName.equals("get")) {
                Invoker getInvoker = invocationChain.getHeadInvoker();
                servlet = new HTTPGetListenerServlet(getInvoker, messageFactory);
                break;
            } else if (operationName.equals("service")) {
                Invoker serviceInvoker = invocationChain.getHeadInvoker();
                servlet = new HTTPServiceListenerServlet(serviceInvoker, messageFactory);
                break;
            }
        }
        if (servlet == null) {
View Full Code Here

    public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
        if ("get".equals(operation.getName())) {
           
            // Return an instance of our get resource invoker
            Invoker invoker = new GetResourceInvoker(implementation.getLocationURL().toString());
            return invoker;
           
        } else {
           
            // Return a dummy invoker that returns an "unsupported operation"
            // exception for now
            return new Invoker() {
                public Message invoke(Message msg) {
                    msg.setFaultBody(new UnsupportedOperationException());
                    return msg;
                }
            };
View Full Code Here

                                                Binding binding,
                                                InvocationChain chain,
                                                Operation operation) {
        ReferenceBindingProvider provider = ((RuntimeComponentReference)reference).getBindingProvider(binding);
        if (provider != null) {
            Invoker invoker = provider.createInvoker(operation);
            if (invoker != null) {
                chain.addInvoker(invoker);
            }
        }
        List<PolicyProvider> pps = ((RuntimeComponentReference)reference).getPolicyProviders(binding);
View Full Code Here

                                              ComponentService service,
                                              InvocationChain chain,
                                              Operation operation) {
        ImplementationProvider provider = ((RuntimeComponent)component).getImplementationProvider();
        if (provider != null) {
            Invoker invoker = null;
            invoker = provider.createInvoker((RuntimeComponentService)service, operation);
            chain.addInvoker(invoker);
        }
        List<PolicyProvider> pps = ((RuntimeComponent)component).getPolicyProviders();
        if (pps != null) {
View Full Code Here

        if (target != null) {
            msg.setTo(target);
        } else {
            msg.setTo(wire.getTarget());
        }
        Invoker headInvoker = chain.getHeadInvoker();
        Operation operation = chain.getTargetOperation();
        msg.setOperation(operation);
        msg.setBody(args);

        Message msgContext = ThreadMessageContext.getMessageContext();
        Object currentConversationID = msgContext.getFrom().getReferenceParameters().getConversationID();

        conversationPreinvoke(msg, wire);
        handleCallback(msg, wire, currentConversationID);
        ThreadMessageContext.setMessageContext(msg);
        boolean abnormalEndConversation = false;
        try {
            // dispatch the wire down the chain and get the response
            Message resp = headInvoker.invoke(msg);
            Object body = resp.getBody();
            if (resp.isFault()) {
                // mark the conversation as ended if the exception is not a business exception
                if (currentConversationID != null ){
                    try {
View Full Code Here

        // that it's an implementation.resource
        RuntimeComponentService componentService = (RuntimeComponentService) service;
        RuntimeWire wire = componentService.getRuntimeWire(binding);
       
        // Get the getLocationURL invoker
        Invoker getLocationInvoker = null;
        for (InvocationChain invocationChain : wire.getInvocationChains()) {
            String operationName = invocationChain.getSourceOperation().getName();
            if (operationName.equals("getLocationURL")) {
                getLocationInvoker = invocationChain.getHeadInvoker();
            }
        }
        if (getLocationInvoker == null) {
            throw new IllegalStateException("No getLocationURL operation found on target component");
        }

        // Get the location URL
        Message message = messageFactory.createMessage();
        message = getLocationInvoker.invoke(message);
        URL locationURL = message.getBody();
       
        // Register the default resource servlet with the servlet host
        DefaultResourceServlet resourceServlet = new DefaultResourceServlet(locationURL.toString());
        servletHost.addServletMapping(uri, resourceServlet);
View Full Code Here

TOP

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

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.