Package org.apache.tuscany.spi.wire

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


        inboundWire.setContainer(reference);
        for (Operation<?> operation : contract.getOperations().values()) {
            InboundInvocationChain chain = createInboundChain(operation);
            inboundWire.addInvocationChain(operation, chain);
        }
        OutboundWire outboundWire = new OutboundWireImpl();

        // [rfeng] Check if the Reference has the binding contract
        ServiceContract<?> bindingContract = reference.getBindingServiceContract();
        if (bindingContract == null) {
            bindingContract = contract;
        }
        outboundWire.setServiceContract(bindingContract);
        outboundWire.setContainer(reference);
        for (Operation<?> operation : bindingContract.getOperations().values()) {
            OutboundInvocationChain chain = createOutboundChain(operation);
            chain.addInterceptor(new InvokerInterceptor());
            outboundWire.addInvocationChain(operation, chain);
        }

        // Notice that we skip inboundWire.setCallbackReferenceName
        // First, an inbound inboundWire's callbackReferenceName is only retrieved by JavaAtomicComponent
        // to create a callback injector based on the callback reference member; a composite reference
View Full Code Here


        //TODO multiplicity
        if (reference.getTargets().size() != 1) {
            throw new UnsupportedOperationException();
        }
        ServiceContract<?> contract = def.getServiceContract();
        OutboundWire wire = new OutboundWireImpl();
        QualifiedName qName = new QualifiedName(reference.getTargets().get(0).toString());
        wire.setTargetName(qName);
        wire.setServiceContract(contract);
        wire.setReferenceName(reference.getReferenceName());
        for (Operation<?> operation : contract.getOperations().values()) {
            //TODO handle policy
            OutboundInvocationChain chain = createOutboundChain(operation);
            wire.addInvocationChain(operation, chain);

        }
        if (contract.getCallbackName() != null) {
            wire.setCallbackInterface(contract.getCallbackClass());
            for (Operation<?> operation : contract.getCallbackOperations().values()) {
                InboundInvocationChain callbackTargetChain = createInboundChain(operation);
                // TODO handle policy
                //TODO statement below could be cleaner
                callbackTargetChain.addInterceptor(new InvokerInterceptor());
                wire.addTargetCallbackInvocationChain(operation, callbackTargetChain);
            }
        }
        return wire;
    }
View Full Code Here

        for (Operation<?> operation : bindingContract.getOperations().values()) {
            InboundInvocationChain inboundChain = createInboundChain(operation);
            inboundWire.addInvocationChain(operation, inboundChain);
        }

        OutboundWire outboundWire = new OutboundWireImpl();
        outboundWire.setServiceContract(contract);
        outboundWire.setTargetName(new QualifiedName(targetName));
        outboundWire.setContainer(service);

        for (Operation<?> operation : contract.getOperations().values()) {
            OutboundInvocationChain outboundChain = createOutboundChain(operation);
            outboundWire.addInvocationChain(operation, outboundChain);
        }

        // Add target callback chain to outbound wire, applicable to both bound and bindless services
        if (contract.getCallbackName() != null) {
            outboundWire.setCallbackInterface(contract.getCallbackClass());
            for (Operation<?> operation : contract.getCallbackOperations().values()) {
                InboundInvocationChain callbackTargetChain = createInboundChain(operation);
// TODO handle policy
//TODO statement below could be cleaner
                callbackTargetChain.addInterceptor(new InvokerInterceptor());
                outboundWire.addTargetCallbackInvocationChain(operation, callbackTargetChain);
            }
        }

        // Not clear in any case why this is done here and at the parent composite level as well
        // But for a composite service, make sure that the inbound wire comes from the parent
View Full Code Here

        if (callback) {
            contract.setCallbackName("");
        }
        EasyMock.replay(inboundWire);

        OutboundWire outboundWire = EasyMock.createNiceMock(OutboundWire.class);
        Map<Operation<?>, OutboundInvocationChain> map = new HashMap<Operation<?>, OutboundInvocationChain>();
        EasyMock.expect(outboundWire.getInvocationChains()).andReturn(map).once();
        EasyMock.replay(outboundWire);

        TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
        ConfigurationContext configurationContext = tuscanyAxisConfigurator.getConfigurationContext();
        WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
View Full Code Here

    public void foo() {
    }

    public void testSourceWireInterceptorOptimization() throws Exception {
        OutboundWire wire = new OutboundWireImpl();
        OutboundInvocationChain chain = new OutboundInvocationChainImpl(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 testSourceWireNonInterceptorOptimization() throws Exception {
        OutboundWire wire = new OutboundWireImpl();
        OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation);
        chain.addInterceptor(new NonOptimizableInterceptor());
        wire.addInvocationChain(operation, chain);
        assertFalse(wire.isOptimizable());
    }
View Full Code Here

        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);

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

        processor.process(outboundWire, inboundWire);
    }
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);
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>();
View Full Code Here

        configuration.setWireService(WIRE_SERVICE);
        for (Map.Entry<String, Member> entry : members.entrySet()) {
            configuration.addReferenceSite(entry.getKey(), entry.getValue());
        }
        JavaAtomicComponent sourceContext = new JavaAtomicComponent(sourceName, configuration, null);
        OutboundWire outboundWire = createReferenceWire(targetName, sourceReferenceClass, sourceHeadInterceptor);
        sourceContext.addOutboundWire(outboundWire);
        targetScope.register(targetContext);
        sourceScope.register(sourceContext);
        connect(outboundWire, inboundWire, targetContext, false);
        Map<String, AtomicComponent> contexts = new HashMap<String, AtomicComponent>();
View Full Code Here

TOP

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

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.