Package org.apache.tuscany.spi.wire

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


        wire.addInvocationChain(operation, chain);
        assertFalse(wire.isOptimizable());
    }

    public void testTargetWireInterceptorOptimization() throws Exception {
        InboundWire wire = new InboundWireImpl();
        InboundInvocationChain chain = new InboundInvocationChainImpl(operation);
        chain.addInterceptor(new OptimizableInterceptor());
        wire.addInvocationChain(operation, chain);
        assertTrue(wire.isOptimizable());
    }
View Full Code Here


        wire.addInvocationChain(operation, chain);
        assertTrue(wire.isOptimizable());
    }

    public void testTargetWireNonInterceptorOptimization() throws Exception {
        InboundWire wire = new InboundWireImpl();
        InboundInvocationChain chain = new InboundInvocationChainImpl(operation);
        chain.addInterceptor(new NonOptimizableInterceptor());
        wire.addInvocationChain(operation, chain);
        assertFalse(wire.isOptimizable());
    }
View Full Code Here

        wire.addInvocationChain(operation, chain);
        assertFalse(wire.isOptimizable());
    }

    public void testTargetWireNonTargetInvokerOptimization() throws Exception {
        InboundWire wire = new InboundWireImpl();
        InboundInvocationChain chain = new InboundInvocationChainImpl(operation);
        TargetInvoker invoker = new StaticPojoTargetInvoker(m, new Object());
        invoker.setCacheable(false);
        chain.setTargetInvoker(invoker);
        wire.addInvocationChain(operation, chain);
        assertFalse(wire.isOptimizable());
    }
View Full Code Here

        //TODO this should return a default service from a wire
        return scopeContainer.getInstance(this);
    }

    public Object getServiceInstance(String service) throws TargetException {
        InboundWire wire = getInboundWire(service);
        if (wire == null) {
            TargetException e = new TargetException("ServiceDefinition not found"); // TODO better error message
            e.setIdentifier(service);
            throw e;
        }
View Full Code Here

        Mediator mediator = new MediatorImpl();
        this.processor = new DataBindingWirePostProcessor(mediator);
    }

    public void testProcess1() {
        InboundWire inboundWire = createMock(InboundWire.class);
        OutboundWire outboundWire = createMock(OutboundWire.class);

        Component component = createMock(Component.class);
        CompositeComponent composite = createMock(CompositeComponent.class);
        expect(component.getParent()).andReturn(composite);
        expect(inboundWire.getContainer()).andReturn(component);
        expect(outboundWire.getContainer()).andReturn(component);

        Map<Operation<?>, OutboundInvocationChain> outboundChains =
            new HashMap<Operation<?>, OutboundInvocationChain>();
        DataType<Type> type1 = new DataType<Type>(String.class, String.class);
        List<DataType<Type>> types = new ArrayList<DataType<Type>>();
        types.add(type1);
        DataType<List<DataType<Type>>> inputType1 = new DataType<List<DataType<Type>>>(Object[].class, types);
        DataType<Type> outputType1 = new DataType<Type>(String.class, String.class);
        Operation<Type> op1 = new Operation<Type>("test", inputType1, outputType1, null);
        ServiceContract<Type> outboundContract = new JavaServiceContract(null);
        outboundContract.setDataBinding(String.class.getName());
        op1.setServiceContract(outboundContract);

        OutboundInvocationChain outboundChain = createMock(OutboundInvocationChain.class);
        outboundChains.put(op1, outboundChain);
        expect(outboundWire.getInvocationChains()).andReturn(outboundChains);
        outboundChain.addInterceptor(EasyMock.anyInt(), (Interceptor)EasyMock.anyObject());

        Map<Operation<?>, InboundInvocationChain> inboundChains =
            new HashMap<Operation<?>, InboundInvocationChain>();
        DataType<Type> type2 = new DataType<Type>(Node.class, Node.class);
        List<DataType<Type>> types2 = new ArrayList<DataType<Type>>();
        types2.add(type2);
        DataType<List<DataType<Type>>> inputType2 =
            new DataType<List<DataType<Type>>>(Object[].class, types2);
        DataType<Type> outputType2 = new DataType<Type>(String.class, String.class);
        Operation<Type> op2 = new Operation<Type>("test", inputType2, outputType2, null);
        ServiceContract<Type> inboundContract = new JavaServiceContract(null);
        inboundContract.setDataBinding(Node.class.getName());
        op2.setServiceContract(inboundContract);

        InboundInvocationChain inboundChain = createMock(InboundInvocationChain.class);
        inboundChains.put(op2, inboundChain);
        expect(inboundWire.getInvocationChains()).andReturn(inboundChains);

        ServiceContract<Type> contract = new JavaServiceContract();
        Map<String, Operation<Type>> operations = Collections.emptyMap();
        contract.setCallbackOperations(operations);
        expect(outboundWire.getServiceContract()).andReturn(contract);
View Full Code Here

        processor.process(outboundWire, inboundWire);
    }

    public void testProcess2() {
        InboundWire inboundWire = createMock(InboundWire.class);
        OutboundWire outboundWire = createMock(OutboundWire.class);

        Reference reference = createMock(Reference.class);
        CompositeComponent composite = createMock(CompositeComponent.class);
        expect(reference.getParent()).andReturn(composite);
        expect(inboundWire.getContainer()).andReturn(reference).anyTimes();
        expect(outboundWire.getContainer()).andReturn(reference).anyTimes();

        Map<Operation<?>, OutboundInvocationChain> outboundChains =
            new HashMap<Operation<?>, OutboundInvocationChain>();
        DataType<Type> type1 = new DataType<Type>(String.class, String.class);
        List<DataType<Type>> types = new ArrayList<DataType<Type>>();
        types.add(type1);
        DataType<List<DataType<Type>>> inputType1 = new DataType<List<DataType<Type>>>(Object[].class, types);
        DataType<Type> outputType1 = new DataType<Type>(String.class, String.class);
        Operation<Type> op1 = new Operation<Type>("test", inputType1, outputType1, null);
        ServiceContract<Type> outboundContract = new JavaServiceContract(null);
        outboundContract.setDataBinding(String.class.getName());
        op1.setServiceContract(outboundContract);

        OutboundInvocationChain outboundChain = createMock(OutboundInvocationChain.class);
        outboundChains.put(op1, outboundChain);
        expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
        outboundChain.addInterceptor(EasyMock.anyInt(), (Interceptor)EasyMock.anyObject());

        Map<Operation<?>, InboundInvocationChain> inboundChains =
            new HashMap<Operation<?>, InboundInvocationChain>();
        DataType<Type> type2 = new DataType<Type>(Node.class, Node.class);
        List<DataType<Type>> types2 = new ArrayList<DataType<Type>>();
        types2.add(type2);
        DataType<List<DataType<Type>>> inputType2 =
            new DataType<List<DataType<Type>>>(Object[].class, types2);
        DataType<Type> outputType2 = new DataType<Type>(String.class, String.class);
        Operation<Type> op2 = new Operation<Type>("test", inputType2, outputType2, null);
        ServiceContract<Type> inboundContract = new JavaServiceContract(null);
        inboundContract.setDataBinding(Node.class.getName());
        op2.setServiceContract(inboundContract);

        InboundInvocationChain inboundChain = createMock(InboundInvocationChain.class);
        inboundChains.put(op2, inboundChain);
        expect(inboundWire.getInvocationChains()).andReturn(inboundChains).anyTimes();

        ServiceContract<Type> contract = new JavaServiceContract();
        Map<String, Operation<Type>> operations = Collections.emptyMap();
        contract.setCallbackOperations(operations);
        expect(inboundWire.getServiceContract()).andReturn(contract);
        expect(inboundChain.getTailInterceptor()).andReturn(null);

        EasyMock.replay(composite, reference, inboundWire, outboundWire, inboundChain, outboundChain);

        processor.process(inboundWire, outboundWire);
View Full Code Here

        processor.process(inboundWire, outboundWire);
    }

    public void testProcess3() {
        InboundWire inboundWire = createMock(InboundWire.class);
        OutboundWire outboundWire = createMock(OutboundWire.class);

        Service service = createMock(Service.class);
        CompositeComponent composite = createMock(CompositeComponent.class);
        expect(service.getParent()).andReturn(composite);
        expect(inboundWire.getContainer()).andReturn(service).anyTimes();
        expect(outboundWire.getContainer()).andReturn(service).anyTimes();

        Map<Operation<?>, OutboundInvocationChain> outboundChains =
            new HashMap<Operation<?>, OutboundInvocationChain>();
        DataType<Type> type1 = new DataType<Type>(String.class, String.class);
        List<DataType<Type>> types = new ArrayList<DataType<Type>>();
        types.add(type1);
        DataType<List<DataType<Type>>> inputType1 = new DataType<List<DataType<Type>>>(Object[].class, types);
        DataType<Type> outputType1 = new DataType<Type>(String.class, String.class);
        Operation<Type> op1 = new Operation<Type>("test", inputType1, outputType1, null);
        ServiceContract<Type> outboundContract = new JavaServiceContract(null);
        outboundContract.setDataBinding(String.class.getName());
        op1.setServiceContract(outboundContract);

        OutboundInvocationChain outboundChain = createMock(OutboundInvocationChain.class);
        outboundChains.put(op1, outboundChain);
        expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
        // outboundChain.addInterceptor(EasyMock.anyInt(), (Interceptor)
        // EasyMock.anyObject());

        Map<Operation<?>, InboundInvocationChain> inboundChains =
            new HashMap<Operation<?>, InboundInvocationChain>();
        DataType<Type> type2 = new DataType<Type>(Node.class, Node.class);
        List<DataType<Type>> types2 = new ArrayList<DataType<Type>>();
        types2.add(type2);
        DataType<List<DataType<Type>>> inputType2 =
            new DataType<List<DataType<Type>>>(Object[].class, types2);
        DataType<Type> outputType2 = new DataType<Type>(String.class, String.class);
        Operation<Type> op2 = new Operation<Type>("test", inputType2, outputType2, null);
        ServiceContract<Type> inboundContract = new JavaServiceContract(null);
        inboundContract.setDataBinding(Node.class.getName());
        op2.setServiceContract(inboundContract);

        InboundInvocationChain inboundChain = createMock(InboundInvocationChain.class);
        inboundChains.put(op2, inboundChain);
        expect(inboundWire.getInvocationChains()).andReturn(inboundChains).anyTimes();
        inboundChain.addInterceptor(EasyMock.anyInt(), (Interceptor)EasyMock.anyObject());

        ServiceContract<Type> contract = new JavaServiceContract();
        Map<String, Operation<Type>> operations = Collections.emptyMap();
        contract.setCallbackOperations(operations);
        expect(inboundWire.getServiceContract()).andReturn(contract);

        EasyMock.replay(composite, service, inboundWire, outboundWire, inboundChain, outboundChain);

        processor.process(inboundWire, outboundWire);
    }
View Full Code Here

        JavaScriptComponent context =
            new JavaScriptComponent("source", implClass2, new HashMap<String, Object>(), services, null, scope,
                ArtifactFactory.createWireService(), null);
        scope.register(context);

        InboundWire wire = ArtifactFactory.createInboundWire("Greeting", Greeting.class);
        ArtifactFactory.terminateWire(wire);
        for (InboundInvocationChain chain : wire.getInvocationChains().values()) {
            chain.setTargetInvoker(context.createTargetInvoker(null, chain.getOperation()));
        }
        context.addInboundWire(wire);
        Greeting greeting = (Greeting) context.getServiceInstance("Greeting");
        assertEquals("foo", greeting.greet("foo"));
View Full Code Here

        });
        replay(scheduler);
        WorkContext context = createMock(WorkContext.class);
        Method method = AsyncTarget.class.getMethod("invoke");
        method.setAccessible(true);
        InboundWire inboundWire = createMock(InboundWire.class);
        AsyncJavaTargetInvoker invoker =
            new AsyncJavaTargetInvoker(method, inboundWire, component, null, context);
        InboundWire wire = createServiceWire("foo", AsyncTarget.class, null);
        Map<Operation<?>, InboundInvocationChain> chains = wire.getInvocationChains();
        InboundInvocationChain chain = chains.get(wire.getServiceContract().getOperations().get("invoke"));
        chain.setTargetInvoker(invoker);
        chain.prepare();
        MessageImpl msg = new MessageImpl();
        msg.setTargetInvoker(invoker);
        chain.getHeadInterceptor().invoke(msg);
View Full Code Here

        throws Exception {

        JavaAtomicComponent targetContext =
            createJavaComponent(targetName, targetScope, targetClass);
        String serviceName = targetService.getName().substring(targetService.getName().lastIndexOf('.') + 1);
        InboundWire inboundWire = createServiceWire(serviceName, targetService, targetHeadInterceptor);
        targetContext.addInboundWire(inboundWire);

        PojoConfiguration configuration = new PojoConfiguration();
        configuration.setScopeContainer(sourceScope);
        configuration.setInstanceFactory(new PojoObjectFactory(sourceClass.getConstructor()));
View Full Code Here

TOP

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

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.