Package org.apache.tuscany.sca.runtime

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


            EndpointReference wireSource = new EndpointReferenceImpl((RuntimeComponent)component,
                                                                     (RuntimeComponentReference)reference, binding,
                                                                     sourceContract);

            EndpointReference wireTarget = new EndpointReferenceImpl(null, null, binding, bindingContract);
            RuntimeWire wire = new RuntimeWireImpl(wireSource, wireTarget);

            for (Operation operation : sourceContract.getInterface().getOperations()) {
                Operation targetOperation = interfaceContractMapper.map(bindingContract.getInterface(), operation);
                InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
                if (operation.isNonBlocking()) {
                    chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
                }
                addBindingInterceptor(component, reference, binding, chain, operation, false);
                wire.getInvocationChains().add(chain);
            }
            if (sourceContract.getCallbackInterface() != null) {
                for (Operation operation : sourceContract.getCallbackInterface().getOperations()) {
                    Operation targetOperation = interfaceContractMapper.map(bindingContract.getCallbackInterface(),
                                                                            operation);
                    InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
                    if (operation.isNonBlocking()) {
                        chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
                    }
                    addBindingInterceptor(component, reference, binding, chain, operation, true);
                    wire.getCallbackInvocationChains().add(chain);
                }
            }
            runtimeRef.getRuntimeWires().add(wire);
            wireProcessor.process(wire);
            // TODO: For non-SCA binding, how do we deal with targets? For now, assuming targets only apply to SCABinding
            return;
        }
        for (ComponentService service : reference.getTargets()) {
            Component target = null;
            SCABinding scaBinding = service.getBinding(SCABinding.class);
            if (scaBinding != null) {
                target = scaBinding.getComponent();
            }

            // FIXME: [rfeng] Ignore unresolved services
            if (service.isUnresolved()) {
                continue;
            }

            // FIXME: [rfeng] We might need a better way to get the impl interface contract
            InterfaceContract targetContract = service.getService().getInterfaceContract();

            EndpointReference wireSource = new EndpointReferenceImpl((RuntimeComponent)component,
                                                                     (RuntimeComponentReference)reference, binding,
                                                                     bindingContract);

            EndpointReference wireTarget = new EndpointReferenceImpl((RuntimeComponent)target,
                                                                     (RuntimeComponentService)service, binding,
                                                                     targetContract);

            RuntimeWire wire = new RuntimeWireImpl(wireSource, wireTarget);

            for (Operation operation : bindingContract.getInterface().getOperations()) {
                Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
                InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
                if (operation.isNonBlocking()) {
                    chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
                }
                addBindingInterceptor(component, reference, binding, chain, operation, false);
                if (target != null) {
                    addImplementationInterceptor(target, service, chain, targetOperation, false);
                }
                wire.getInvocationChains().add(chain);
            }
            if (bindingContract.getCallbackInterface() != null) {
                if (reference.getName().startsWith("$self$.")) {
                    // No callback is needed
                    continue;
                }
                for (Operation operation : bindingContract.getCallbackInterface().getOperations()) {
                    Operation targetOperation = interfaceContractMapper.map(targetContract.getCallbackInterface(),
                                                                            operation);
                    InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
                    if (operation.isNonBlocking()) {
                        chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
                    }
                    addBindingInterceptor(component, reference, binding, chain, operation, true);
                    addImplementationInterceptor(component, null, chain, targetOperation, true);
                    wire.getCallbackInvocationChains().add(chain);
                }
            }

            runtimeRef.getRuntimeWires().add(wire);
            if (!wire.getCallbackInvocationChains().isEmpty()) {
                if (wire.getTarget().getContract() != null) {
                    ((RuntimeComponentService) wire.getTarget().getContract()).getCallbackWires().add(wire);
                }
            }
            wireProcessor.process(wire);
        }
    }
View Full Code Here


        EndpointReference wireTarget = new EndpointReferenceImpl((RuntimeComponent)component,
                                                                 (RuntimeComponentService)service, binding,
                                                                 targetContract);

        RuntimeWire wire = new RuntimeWireImpl(wireSource, wireTarget);

        for (Operation operation : sourceContract.getInterface().getOperations()) {
            Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
            InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
            /* lresende */
            if (operation.isNonBlocking()) {
                chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
            }

            addImplementationInterceptor(component, service, chain, targetOperation, false);
            wire.getInvocationChains().add(chain);
        }
        // if (sourceContract.getCallbackInterface() != null) {
        // for (Operation operation :
        // sourceContract.getCallbackInterface().getOperations()) {
        // Operation targetOperation =
View Full Code Here

    private <B> B getService(Class<B> businessInterface, String referenceName) {
        List<ComponentReference> refs = component.getReferences();
        for (ComponentReference ref : refs) {
            if (ref.getName().equals(referenceName)) {
                RuntimeComponentReference attachPoint = (RuntimeComponentReference)ref;
                RuntimeWire wire = attachPoint.getRuntimeWires().get(0);
                return proxyService.createProxy(businessInterface, wire);
            }
        }
        return null;
    }
View Full Code Here

            // Relaxing this assumption, however, does not seem to be trivial,
            // it may depend on knowledge
            // of what actual callback method was invoked by the service at the
            // other end

            RuntimeWire wire = reference.getRuntimeWire(wsBinding);
            Operation callbackOperation = findCallbackOperation(wire);
            Axis2CallbackInvocationHandler invocationHandler = new Axis2CallbackInvocationHandler(messageFactory, wire);
            Axis2ReferenceCallbackTargetInvoker callbackInvoker = new Axis2ReferenceCallbackTargetInvoker(
                                                                                                          callbackOperation,
                                                                                                          wire,
View Full Code Here

    public void start() {

        // Get the target component implementation, for now we are assuming
        // that it's an implementation.resource
        RuntimeComponentService componentService = (RuntimeComponentService) service;
        RuntimeWire wire = componentService.getRuntimeWire(binding);
        Implementation implementation = wire.getTarget().getComponent().getImplementation();
        ResourceImplementation resourceImplementation = (ResourceImplementation)implementation;
       
        // Get the resource location URL
        URL locationURL = resourceImplementation.getLocationURL();
       
View Full Code Here

   
    protected org.osgi.framework.ServiceReference getOSGiServiceReference(
            EndpointReference from, Interface callbackInterface)
            throws ObjectCreationException {
       
        RuntimeWire refWire = null;
        String filter = null;
        for (RuntimeWire wire : referenceWires.keySet()) {
            if (wire.getSource() == from) {
                refWire = wire;
                break;
View Full Code Here

            } else {
                if (wireList == null && ref.getMultiplicity() == Multiplicity.ONE_ONE) {
                    throw new IllegalStateException("Required reference is missing: " + ref.getName());
                }
                if (wireList != null && !wireList.isEmpty()) {
                    RuntimeWire wire = wireList.get(0);
                    referenceWires.put(wire, ref);
                    componentReferenceWires.put(wire, compRef);
                }
               
            }
View Full Code Here

    public Object invoke(Operation operation, Message msg) throws InvocationTargetException {
        return invoke(wire, operation, msg);
    }

    public Object invoke(RuntimeWire wire, Operation operation, Message msg) throws InvocationTargetException {
        RuntimeWire runtimeWire = wire == null ? this.wire : wire;
        InvocationChain chain = runtimeWire.getInvocationChain(operation);
        return invoke(chain, msg, runtimeWire);
    }
View Full Code Here

        }
        return from.getReferenceParameters().getCallbackReference();
    }

    private RuntimeWire cloneAndBind(RuntimeWire wire) {
        RuntimeWire boundWire = null;
        if (resolvedEndpoint != null) {
            boundWire = ((RuntimeWireImpl)wire).lookupCache(resolvedEndpoint);
            if (boundWire != null) {
                return boundWire;
            }
View Full Code Here

        this.businessInterface = (Class<B>) ji.getJavaClass();
       
        // We need to re-create the callback wire. We need to do this on a clone of the Service
        // wire since we need to change some details on it.
        // FIXME: Is this the best way to do this?
        final RuntimeWire cbWire = ((RuntimeComponentService) targetService).getRuntimeWires().get(0);
        try {
            this.wire = (RuntimeWireImpl) cbWire.clone();
        } catch (CloneNotSupportedException e) {
            throw new IOException(e.toString());
        }

        // Setup the reference on the cloned wire
View Full Code Here

TOP

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

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.