Package org.apache.tuscany.spi.wire

Examples of org.apache.tuscany.spi.wire.InboundInvocationChain


        assertEquals(TestReference.class, ref.getInterface());

    }

    public void testPrepare() throws Exception {
        InboundInvocationChain chain = createMock(InboundInvocationChain.class);
        Operation<Type> operation = new Operation<Type>("test", null, null, null, false, null);
        chain.setTargetInvoker(null);
        expectLastCall();
        chain.getOperation();
        expectLastCall().andReturn(operation);
        chain.prepare();
        expectLastCall();
        InboundWire wire = createMock(InboundWire.class);
        wire.getInvocationChains();
        Map<Operation, InvocationChain> chains = new HashMap<Operation, InvocationChain>();
        chains.put(operation, chain);
View Full Code Here


        throws InvalidServiceContractException {
        Map<Operation<?>, InboundInvocationChain> invocations = new HashMap<Operation<?>, InboundInvocationChain>();
        JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
        ServiceContract<?> contract = registry.introspect(interfaze);
        for (Operation<?> operation : contract.getOperations().values()) {
            InboundInvocationChain chain = new InboundInvocationChainImpl(operation);
            // add tail interceptor
            //chain.addInterceptor(new InvokerInterceptor());
            invocations.put(operation, chain);
        }
        return invocations;
View Full Code Here

        Operation operation = contract.getOperations().get("hello");
        OutboundInvocationChain source = new OutboundInvocationChainImpl(operation);
        MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
        source.addInterceptor(sourceInterceptor);

        InboundInvocationChain target = new InboundInvocationChainImpl(operation);
        MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
        target.addInterceptor(targetInterceptor);
        target.addInterceptor(new InvokerInterceptor());

        // connect the source to the target
        source.setTargetInterceptor(target.getHeadInterceptor());
        source.prepare();
        target.prepare();
        MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
        source.setTargetInvoker(invoker);

        Message msg = new MessageImpl();
        msg.setTargetInvoker(invoker);
View Full Code Here

            }
            TargetException e = new TargetException("Operation not configured");
            e.setIdentifier(method.getName());
            throw e;
        }
        InboundInvocationChain chain = holder.chain;
        TargetInvoker invoker;
        if (holder.cachedInvoker == null) {
            assert chain != null;
            if (chain.getTargetInvoker() == null) {
                TargetException e = new TargetException("No target invoker configured for operation");
                e.setIdentifier(chain.getOperation().getName());
                throw e;
            }
            if (chain.getTargetInvoker().isCacheable()) {
                // clone and store the invoker locally
                holder.cachedInvoker = (TargetInvoker) chain.getTargetInvoker().clone();
                invoker = holder.cachedInvoker;
            } else {
                invoker = chain.getTargetInvoker();
            }
        } else {
            assert chain != null;
            invoker = chain.getTargetInvoker();
        }
        messageId = context.getCurrentMessageId();
        context.setCurrentMessageId(null);
        correlationId = context.getCurrentCorrelationId();
        context.setCurrentCorrelationId(null);
View Full Code Here

            return;
        }
        // match outbound to inbound chains
        for (OutboundInvocationChain outboundChain : sourceWire.getInvocationChains().values()) {
            Operation<?> operation = outboundChain.getOperation();
            InboundInvocationChain inboundChain = targetChains.get(operation);
            if (inboundChain == null) {
                BuilderConfigException e =
                    new BuilderConfigException("Incompatible source and target interfaces for reference");
                e.setIdentifier(sourceWire.getReferenceName());
                throw e;
            }
            Operation<?> inboundOperation = inboundChain.getOperation();
            boolean isOneWayOperation = operation.isNonBlocking();
            boolean operationHasCallback = contract.getCallbackName() != null;
            if (isOneWayOperation && operationHasCallback) {
                throw new ComponentRuntimeException("Operation cannot be marked one-way and have a callback");
            }
            TargetInvoker invoker = null;
            if (target instanceof Component) {
                Component component = (Component) target;
                if (isOneWayOperation || operationHasCallback) {
                    invoker = component.createAsyncTargetInvoker(targetWire, inboundOperation);
                } else {
                    String portName = sourceWire.getTargetName().getPortName();
                    invoker = component.createTargetInvoker(portName, inboundOperation);
                }
            } else if (target instanceof Reference) {
                Reference reference = (Reference) target;
                if (!(reference instanceof CompositeReference) && operationHasCallback) {
                    // Notice that for bound references we only use async target invokers for callback operations
                    invoker = reference.createAsyncTargetInvoker(sourceWire, inboundOperation);
                } else {
                    ServiceContract targetContract = targetWire.getServiceContract();
                    invoker = reference.createTargetInvoker(targetContract, inboundOperation);
                }
            } else if (target instanceof CompositeService) {
                CompositeService compServ = (CompositeService) target;
                invoker = compServ.createTargetInvoker(targetWire.getServiceContract(), inboundChain.getOperation());
            }

            if (source instanceof Service && !(source instanceof CompositeService)) {
                // services are a special case: invoker must go on the inbound chain
                if (target instanceof Component && (isOneWayOperation || operationHasCallback)) {
                    // if the target is a component and the operation is non-blocking
                    connect(outboundChain, inboundChain, null, true);
                } else {
                    connect(outboundChain, inboundChain, null, false);
                }
                Service service = (Service) source;
                InboundInvocationChain chain = service.getInboundWire().getInvocationChains().get(operation);
                chain.setTargetInvoker(invoker);
            } else {
                if (target instanceof Component && (isOneWayOperation || operationHasCallback)) {
                    // if the target is a component and the operation is non-blocking
                    connect(outboundChain, inboundChain, invoker, true);
                } else {
View Full Code Here

    private OutboundInvocationChain createChain(Operation operation) {
        OutboundInvocationChain source = new OutboundInvocationChainImpl(operation);
        MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
        source.addInterceptor(sourceInterceptor);

        InboundInvocationChain target = new InboundInvocationChainImpl(operation);
        MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
        target.addInterceptor(targetInterceptor);
        target.addInterceptor(new InvokerInterceptor());

        // connect the source to the target
        source.setTargetInterceptor(targetInterceptor);
        source.prepare();
        target.prepare();
        Method method = JavaIDLUtils.findMethod(operation, SimpleTarget.class.getMethods());
        MockStaticInvoker invoker = new MockStaticInvoker(method, new SimpleTargetImpl());
        source.setTargetInvoker(invoker);
        return source;
    }
View Full Code Here

    private Interceptor tailInterceptor;

    public void testConnectReferenceWires() {

        // create the inbound wire and chain
        InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
        EasyMock.expect(inboundChain.getOperation()).andReturn(operation).atLeastOnce();
        inboundChain.addInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
        inboundChain.setTargetInvoker(null);
        inboundChain.prepare();
        EasyMock.replay(inboundChain);
        Map<Operation<?>, InboundInvocationChain> inboundChains = new HashMap<Operation<?>, InboundInvocationChain>();
        inboundChains.put(operation, inboundChain);
        InboundWire inboundWire = EasyMock.createMock(InboundWire.class);
        EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
View Full Code Here

        EasyMock.verify(outboundChain);
    }

    public void testConnectServiceWires() {
        // create the inbound wire and chain for the target
        InboundInvocationChain targetChain = EasyMock.createMock(InboundInvocationChain.class);
        EasyMock.expect(targetChain.getOperation()).andReturn(operation).atLeastOnce();
        EasyMock.expect(targetChain.getHeadInterceptor()).andReturn(headInterceptor);
        targetChain.prepare();
        EasyMock.replay(targetChain);
        Map<Operation<?>, InboundInvocationChain> targetChains = new HashMap<Operation<?>, InboundInvocationChain>();
        targetChains.put(operation, targetChain);
        InboundWire targetWire = EasyMock.createMock(InboundWire.class);
        EasyMock.expect(targetWire.getServiceContract()).andReturn(contract).anyTimes();
        EasyMock.expect(targetWire.getInvocationChains()).andReturn(targetChains);
        targetWire.getSourceCallbackInvocationChains("source");
        EasyMock.expectLastCall().andReturn(Collections.emptyMap());

        // create the target
        AtomicComponent target = EasyMock.createMock(AtomicComponent.class);
        EasyMock.expect(target.getScope()).andReturn(Scope.MODULE);
        EasyMock.expect(target.isSystem()).andReturn(false).atLeastOnce();
        target.getInboundWire(EasyMock.eq("FooService"));
        EasyMock.expectLastCall().andReturn(targetWire).atLeastOnce();
        target.createTargetInvoker(EasyMock.eq("FooService"), EasyMock.eq(operation));
        EasyMock.expectLastCall().andReturn(null);
        EasyMock.replay(target);

        EasyMock.expect(targetWire.getContainer()).andReturn(target);
        EasyMock.replay(targetWire);

        // create the parent composite
        CompositeComponent parent = EasyMock.createMock(CompositeComponent.class);
        EasyMock.expect(parent.getChild("target")).andReturn(target);
        EasyMock.replay(parent);

        // create the inbound wire and chain for the source service
        InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
        EasyMock.expect(inboundChain.getOperation()).andReturn(operation).atLeastOnce();
        inboundChain.addInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
        inboundChain.setTargetInvoker(null);
        EasyMock.replay(inboundChain);
        Map<Operation<?>, InboundInvocationChain> inboundChains = new HashMap<Operation<?>, InboundInvocationChain>();
        inboundChains.put(operation, inboundChain);
        InboundWire inboundWire = EasyMock.createMock(InboundWire.class);
        EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
View Full Code Here

     * Verifies connecting a wire from an atomic component to a target atomic component with one synchronous operation
     */
    public void testConnectAtomicComponentToAtomicComponentSyncWire() throws Exception {

        // create the inbound wire and chain
        InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
        EasyMock.expect(inboundChain.getOperation()).andReturn(operation).atLeastOnce();
        EasyMock.expect(inboundChain.getHeadInterceptor()).andReturn(headInterceptor);
        EasyMock.replay(inboundChain);
        Map<Operation<?>, InboundInvocationChain> inboundChains = new HashMap<Operation<?>, InboundInvocationChain>();
        inboundChains.put(operation, inboundChain);
        InboundWire targetWire = EasyMock.createMock(InboundWire.class);
        EasyMock.expect(targetWire.getServiceContract()).andReturn(contract).anyTimes();
View Full Code Here

        EasyMock.verify(target);
    }

    public void testConnectInboundAtomicComponentWires() {
        // create the inbound wire and chain
        InboundInvocationChain chain = EasyMock.createMock(InboundInvocationChain.class);
        EasyMock.expect(chain.getOperation()).andReturn(operation).atLeastOnce();
        chain.setTargetInvoker(null);
        chain.prepare();
        EasyMock.replay(chain);
        Map<Operation<?>, InboundInvocationChain> inboundChains = new HashMap<Operation<?>, InboundInvocationChain>();
        inboundChains.put(operation, chain);
        InboundWire wire = EasyMock.createMock(InboundWire.class);
        EasyMock.expect(wire.getServiceName()).andReturn("FooService");
View Full Code Here

TOP

Related Classes of org.apache.tuscany.spi.wire.InboundInvocationChain

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.