Package org.apache.tuscany.sca.runtime

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


        }
        wireProcessor.process(this);
    }
   
    private void initReferenceBindingInvocationChains() {
        RuntimeComponentReference reference = (RuntimeComponentReference)endpointReference.getReference();
        Binding referenceBinding = endpointReference.getBinding();
       
        // add the binding interceptors to the reference binding wire
        ReferenceBindingProvider provider = reference.getBindingProvider(referenceBinding);
        if ((provider != null) &&
            (provider instanceof ReferenceBindingProviderRRB)){
            ((ReferenceBindingProviderRRB)provider).configureBindingChain(this);
        }
       
View Full Code Here


     * @param service
     * @return
     */
    public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, ComponentService service) {
        try {
            RuntimeComponentReference ref =
                (RuntimeComponentReference)createSelfReference(component, service, businessInterface);
            ref.setComponent(component);
            return getServiceReference(businessInterface, ref, null);
        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
        }
    }
View Full Code Here

     */
    public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface,
                                                       RuntimeComponentReference reference,
                                                       Binding binding) {
        try {
            RuntimeComponentReference ref = (RuntimeComponentReference)reference;
            InterfaceContract interfaceContract = reference.getInterfaceContract();
            Reference componentTypeReference = reference.getReference();
            if (componentTypeReference != null && componentTypeReference.getInterfaceContract() != null) {
                interfaceContract = componentTypeReference.getInterfaceContract();
            }
            InterfaceContract refInterfaceContract = getInterfaceContract(interfaceContract, businessInterface);
            if (refInterfaceContract != interfaceContract) {
                ref = (RuntimeComponentReference)reference.clone();
                if (interfaceContract != null) {
                    ref.setInterfaceContract(interfaceContract);
                } else {
                    ref.setInterfaceContract(refInterfaceContract);
                }
            }
            ref.setComponent(component);
            return new ServiceReferenceImpl<B>(businessInterface, component, ref, binding, proxyFactory,
                                               compositeActivator);
        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
        }
View Full Code Here

    public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface,
                                                       RuntimeComponentReference reference,
                                                       RuntimeComponent component,
                                                       RuntimeComponentService service) {
        try {
            RuntimeComponentReference ref = (RuntimeComponentReference)reference.clone();
            InterfaceContract interfaceContract = reference.getInterfaceContract();
            Reference componentTypeReference = reference.getReference();
            if (componentTypeReference != null && componentTypeReference.getInterfaceContract() != null) {
                interfaceContract = componentTypeReference.getInterfaceContract();
            }
            InterfaceContract refInterfaceContract = getInterfaceContract(interfaceContract, businessInterface);
            if (refInterfaceContract != interfaceContract) {
                ref = (RuntimeComponentReference)reference.clone();
                ref.setInterfaceContract(interfaceContract);
            }
            ref.getTargets().add(service);
            ref.getBindings().clear();
            for (Binding binding : service.getBindings()) {
                if (binding instanceof OptimizableBinding) {
                    OptimizableBinding optimizableBinding = (OptimizableBinding)((OptimizableBinding)binding).clone();
                    optimizableBinding.setTargetBinding(binding);
                    optimizableBinding.setTargetComponent(component);
                    optimizableBinding.setTargetComponentService(service);
                    ref.getBindings().add(optimizableBinding);
                } else {
                    ref.getBindings().add(binding);
                }
            }
            return new ServiceReferenceImpl<B>(businessInterface, component, ref, proxyFactory, compositeActivator);
        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
View Full Code Here

        try {
            if (businessInterface == null) {
                InterfaceContract contract = service.getInterfaceContract();
                businessInterface = (Class<B>)((JavaInterface)contract.getInterface()).getJavaClass();
            }
            RuntimeComponentReference ref =
                (RuntimeComponentReference)createSelfReference(component, service, businessInterface);
            ref.setComponent(component);
            return new CallableReferenceImpl<B>(businessInterface, component, ref, null, proxyFactory,
                                                compositeActivator);
        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
        }
View Full Code Here

    @SuppressWarnings("unchecked")
    public <CB> CallableReference<CB> getCallbackReference() {
        Message msgContext = ThreadMessageContext.getMessageContext();
        EndpointReference to = msgContext.getTo();
        RuntimeComponentService service = (RuntimeComponentService) to.getContract();
        RuntimeComponentReference callbackReference = (RuntimeComponentReference)service.getCallbackReference();
        if (callbackReference == null) {
            return null;
        }
        JavaInterface javaInterface = (JavaInterface) callbackReference.getInterfaceContract().getInterface();
        Class<CB> javaClass = (Class<CB>)javaInterface.getJavaClass();
        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();
View Full Code Here

    public RuntimeComponentReference bindComponentReference(Class<?> businessInterface,
                                                            RuntimeComponentReference reference,
                                                            RuntimeComponent component,
                                                            RuntimeComponentService service)
        throws CloneNotSupportedException, InvalidInterfaceException {
        RuntimeComponentReference ref = (RuntimeComponentReference)reference.clone();
        InterfaceContract interfaceContract = reference.getInterfaceContract();
        Reference componentTypeReference = reference.getReference();
        if (componentTypeReference != null && componentTypeReference.getInterfaceContract() != null) {
            interfaceContract = componentTypeReference.getInterfaceContract();
        }
        InterfaceContract refInterfaceContract = getInterfaceContract(interfaceContract, businessInterface);
        if (refInterfaceContract != interfaceContract) {
            ref = (RuntimeComponentReference)reference.clone();
            ref.setInterfaceContract(interfaceContract);
        }
        ref.setComponent(component);
        ref.getTargets().add(service);
        ref.getBindings().clear();
        for (Binding binding : service.getBindings()) {
            if (binding instanceof OptimizableBinding) {
                OptimizableBinding optimizableBinding = (OptimizableBinding)((OptimizableBinding)binding).clone();
                optimizableBinding.setTargetBinding(binding);
                optimizableBinding.setTargetComponent(component);
                optimizableBinding.setTargetComponentService(service);
                ref.getBindings().add(optimizableBinding);
            } else {
                ref.getBindings().add(binding);
            }
        }
        return ref;
    }
View Full Code Here

            if (boundWire != null) {
                return boundWire;
            }
            try {
                Contract contract = resolvedEndpoint.getContract();
                RuntimeComponentReference ref = null;
                if (contract == null) {
                    //TODO - EPR - does it ever go through here?
                    boundWire = (RuntimeWire)wire.clone();

                } else if (contract instanceof RuntimeComponentReference) {
                    ref = (RuntimeComponentReference)contract;
                    //TODO - EPR - get the bound wire based on endpont reference no binding
                    //boundWire = ref.getRuntimeWire(resolvedEndpoint.getBinding());
                    for (RuntimeWire runtimeWire : ref.getRuntimeWires()){
                        if (runtimeWire.getEndpointReference().getBinding().getName().equals(resolvedEndpoint.getBinding().getName())){
                            boundWire = runtimeWire;
                            break;
                        }
                    }

                } else // contract instanceof RuntimeComponentService
                    ref = bind((RuntimeComponentReference)wire.getSource().getContract(),
                                resolvedEndpoint);
                    boundWire = ref.getRuntimeWires().get(0);
                }
                configureWire(boundWire);
                ((RuntimeWireImpl2)wire).addToCache(resolvedEndpoint, boundWire);
            } catch (CloneNotSupportedException e) {
                // will not happen
View Full Code Here

    private static RuntimeComponentReference bind(RuntimeComponentReference reference,
                                                  EndpointReference resolvedEndpoint) throws CloneNotSupportedException {
        RuntimeComponent component = resolvedEndpoint.getComponent();
        RuntimeComponentService service = (RuntimeComponentService)resolvedEndpoint.getContract();
       
        RuntimeComponentReference ref = (RuntimeComponentReference)reference.clone();
        ref.getTargets().add(service);
        ref.getBindings().clear();
        for (Binding binding : service.getBindings()) {
            if (binding instanceof OptimizableBinding) {
                OptimizableBinding optimizableBinding = (OptimizableBinding)((OptimizableBinding)binding).clone();
                optimizableBinding.setTargetBinding(binding);
                optimizableBinding.setTargetComponent(component);
                optimizableBinding.setTargetComponentService(service);
                ref.getBindings().add(optimizableBinding);
            } else {
                ref.getBindings().add(binding);
            }
        }
       
        ref.getEndpointReferences().clear();
       
        for(EndpointReference2 endpointReference : reference.getEndpointReferences()){
            EndpointReference2 clone = (EndpointReference2)endpointReference.clone();
           
            clone.setReference(ref);
            clone.getBinding().setURI(resolvedEndpoint.getURI());
           
            clone.getTargetEndpoint().setComponent(resolvedEndpoint.getComponent());
            clone.getTargetEndpoint().setService((ComponentService)resolvedEndpoint.getContract())
            clone.getTargetEndpoint().setBinding(resolvedEndpoint.getBinding());
           
            ref.getEndpointReferences().add(clone);
        }
      
        return ref;
    }
View Full Code Here

        Binding binding = wire.getSource().getBinding();
        binding.setURI(resolvedEndpoint.getURI());

        // set the target contract as it varies for the sca binding depending on
        // whether it is local or remote
        RuntimeComponentReference ref = (RuntimeComponentReference)wire.getSource().getContract();
       
        // TODO - EPR
        wire.getEndpointReference().getTargetEndpoint().setInterfaceContract(ref.getBindingProvider(binding).getBindingInterfaceContract());
    }
View Full Code Here

TOP

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

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.