Examples of ReferenceParameters


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

        Object payload = msg.getBody();

        Object contextId = null;

        EndpointReference from = msg.getFrom();
        ReferenceParameters parameters = null;
        if (from != null) {
            parameters = from.getReferenceParameters();
        }
        // check what sort of context is required
        if (scopeContainer != null) {
            Scope scope = scopeContainer.getScope();
            if (scope == Scope.REQUEST) {
                contextId = Thread.currentThread();
            } else if (scope == Scope.CONVERSATION && parameters != null) {
                contextId = parameters.getConversationID();
            }
        }

        try {
            // The following call might create a new conversation, as a result, the msg.getConversationID() might
            // return a new value
            InstanceWrapper wrapper = scopeContainer.getWrapper(contextId);

            // detects whether the scope container has created a conversation Id. This will
            // happen in the case that the component has conversational scope but only the
            // callback interface is conversational. Or in the callback case if the service interface
            // is conversational and the callback interface isn't. If we are in this situation we need
            // to get the contextId of this component and remove it after we have invoked the method on
            // it. It is possible that the component instance will not go away when it is removed below
            // because a callback conversation will still be holding a reference to it
            boolean removeTemporaryConversationalComponentAfterCall = false;
            if (parameters != null && (contextId == null) && (parameters.getConversationID() != null)) {
                contextId = parameters.getConversationID();
                removeTemporaryConversationalComponentAfterCall = true;
            }

            Object instance = wrapper.getInstance();

            // If the method couldn't be computed statically, or the instance being
            // invoked is a user-specified callback object that doesn't implement
            // the service interface from which the reflective method was obtained,
            // compute the method object dynamically for this invocation.
            Method imethod = method;
            if (imethod == null || !imethod.getDeclaringClass().isInstance(instance)) {
                try {
                    imethod = JavaInterfaceUtil.findMethod(instance.getClass(), operation);
                } catch (NoSuchMethodException e) {
                    throw new IllegalArgumentException("Callback object does not provide method " + e.getMessage());
                }
            }
           
            Object ret;
            if (payload != null && !payload.getClass().isArray()) {
                ret = imethod.invoke(instance, payload);
            } else {
                ret = imethod.invoke(instance, (Object[])payload);
            }

            scopeContainer.returnWrapper(wrapper, contextId);

            if ((sequence == ConversationSequence.CONVERSATION_END) || (removeTemporaryConversationalComponentAfterCall)) {
                // if end conversation, or we have the special case where a conversational
                // object was created to service the stateless half of a stateful component
                scopeContainer.remove(contextId);
                parameters.setConversationID(null);
            }
            msg.setBody(ret);
        } catch (InvocationTargetException e) {
            Throwable cause = e.getTargetException();
            boolean isChecked = false;
            for (DataType<?> d : operation.getFaultTypes()) {
                if (d.getPhysical().isInstance(cause)) {
                    isChecked = true;
                    msg.setFaultBody(cause);
                    break;
                }
            }

           
            if (sequence != ConversationSequence.CONVERSATION_NONE ){
                try {
//                    // If the exception is not a business exception then end the conversation
//                    boolean businessException = false;
//                   
//                    for (DataType dataType : operation.getFaultTypes()){
//                        if ((dataType.getPhysical() == e.getCause().getClass()) &&
//                            (contextId != null) ){
//                            businessException = true;
//                            break;
//                        }
//                    }
                   
                    if (!isChecked && contextId != null) {
                        scopeContainer.remove(contextId);
                        parameters.setConversationID(null);
                    }
                } catch (Exception ex){
                    // TODO - sure what the best course of action is here. We have
                    //        a system exception in the middle of a business exception
                }
View Full Code Here

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

        //fill message with QoS context info
        fillQoSContext(msg, inMC);
       
        // if reference parameters are needed, create a new "From" EPR to hold them
        EndpointReference from = null;
        ReferenceParameters parameters = null;
        if (callbackAddress != null ||
            callbackID != null ||
            conversationID != null) {
            from = createEndpointReference(null);
            parameters = from.getReferenceParameters();
            msg.setFrom(from);
        }

        // set the reference parameters into the "From" EPR
        if (callbackAddress != null) {
            parameters.setCallbackReference(createEndpointReference(callbackAddress));
        }
        if (callbackID != null) {
            parameters.setCallbackID(callbackID);
        }
        if (conversationID != null) {
            parameters.setConversationID(conversationID);
        }

        if (basicAuthenticationPolicy != null) {
            Axis2BindingBasicAuthenticationConfigurator.parseHTTPHeader(inMC, msg, basicAuthenticationPolicy);
        }
View Full Code Here

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

        EndpointReference to = msgContext.getTo();
        RuntimeComponentService service = (RuntimeComponentService) to.getContract();
        RuntimeComponent component = (RuntimeComponent) to.getComponent();
       
        CallableReference<B> callableReference = component.getComponentContext().getCallableReference(null, component, service);
        ReferenceParameters parameters = msgContext.getFrom().getReferenceParameters();
        ((CallableReferenceExt<B>) callableReference).attachCallbackID(parameters.getCallbackID());
        ((CallableReferenceExt<B>) callableReference).attachConversation(parameters.getConversationID());
        return callableReference;
    }
View Full Code Here

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

        List<RuntimeWire> wires = callbackReference.getRuntimeWires();
        ProxyFactory proxyFactory = new ExtensibleProxyFactory(proxyFactoryExtensionPoint);
        CallbackReferenceImpl ref = CallbackReferenceImpl.newInstance(javaClass, proxyFactory, wires);
        if (ref != null) { 
            //ref.resolveTarget();
            ReferenceParameters parameters = msgContext.getFrom().getReferenceParameters();
            ref.attachCallbackID(parameters.getCallbackID());
            if (ref.getConversation() != null) {
                ref.attachConversationID(parameters.getConversationID());
            }
        }
        return ref;
    }
View Full Code Here

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

    /**
     * @see org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor#read(javax.xml.stream.XMLStreamReader)
     */
    public ReferenceParameters read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
        ReferenceParameters parameters = new ReferenceParametersImpl();
        parameters.setConversationID(reader.getAttributeValue(null, "conversationID"));
        parameters.setCallbackID(reader.getAttributeValue(null, "callbackID"));
        return parameters;
    }
View Full Code Here

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

                this.component = (RuntimeComponent)c;
                compositeActivator.configureComponentContext(this.component);
                this.reference = (RuntimeComponentReference)c.getReferences().get(0);
                this.reference.setComponent(this.component);
                clonedRef = reference;
                ReferenceParameters parameters = null;
                for (Object ext : reference.getExtensions()) {
                    if (ext instanceof ReferenceParameters) {
                        parameters = (ReferenceParameters)ext;
                        break;
                    }
                }
                if (parameters != null) {
                    refParams = parameters;
                    this.callbackID = parameters.getCallbackID();
                    attachConversation(parameters.getConversationID());
                }

                for (Binding binding : reference.getBindings()) {
                    if (binding instanceof OptimizableBinding) {
                        // Resolve the Component
View Full Code Here

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

            this.conversation = null;
        }
    }

    protected ReferenceParameters getReferenceParameters() {
        ReferenceParameters parameters = new ReferenceParametersImpl();
        parameters.setCallbackID(callbackID);
        if (getConversation() != null) {
            parameters.setConversationID(conversation.getConversationID());
        }
        return parameters;
    }
View Full Code Here

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

            Reference componentTypeRef = reference.getReference();
            InterfaceContract sourceContract =
                componentTypeRef == null ? reference.getInterfaceContract() : componentTypeRef.getInterfaceContract();
            sourceContract = sourceContract.makeUnidirectional(false);
            EndpointReference epr = new EndpointReferenceImpl(component, reference, binding, sourceContract);
            ReferenceParameters parameters = getReferenceParameters();
            epr.setReferenceParameters(parameters);
            return epr;
        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
        }
View Full Code Here

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

        this.callback = callback;
    }

    @Override
    protected ReferenceParameters getReferenceParameters() {
        ReferenceParameters parameters = super.getReferenceParameters();
        if (callback != null) {
            if (callback instanceof ServiceReference) {
                EndpointReference callbackRef = ((CallableReferenceExt)callback).getEndpointReference();
                parameters.setCallbackReference(callbackRef);
            } else {
                EndpointReference callbackRef = getRuntimeWire().getSource().getCallbackEndpoint();
                parameters.setCallbackReference(callbackRef);
                parameters.setCallbackObjectID(callback);
            }
        }
        return parameters;
    }
View Full Code Here

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

        init(wire);
    }

    protected void init(RuntimeWire wire) {
        if (wire != null) {
            ReferenceParameters parameters = wire.getSource().getReferenceParameters();
            this.callbackID = parameters.getCallbackID();
            this.callbackObject = parameters.getCallbackReference();
            this.conversationID = parameters.getConversationID();
            InterfaceContract contract = wire.getSource().getInterfaceContract();
            this.conversational = contract.getInterface().isConversational();
        }
    }
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.