Package org.apache.tuscany.spi.component

Examples of org.apache.tuscany.spi.component.Reference


                    services.add(service);
                }
            }
            registerAutowire(service);
        } else if (child instanceof Reference) {
            Reference reference = (Reference) child;
            synchronized (references) {
                if (reference.isSystem()) {
                    systemReferences.add(reference);
                } else {
                    references.add(reference);
                }
            }
View Full Code Here


            }
            component.register(service);
        }
        for (BoundReferenceDefinition<?> referenceDefinition : componentType.getReferences().values()) {
            // call back into builder registry to handle building of references
            Reference reference = (Reference) builderRegistry.build(parent, referenceDefinition, deploymentContext);
            connector.connect(reference);
            component.register(reference);
        }
        return component;
    }
View Full Code Here

                    chain.setTargetInvoker(invoker);
                    chain.prepare();
                }
            }
        } else if (source instanceof Reference) {
            Reference reference = (Reference) source;
            InboundWire inboundWire = reference.getInboundWire();
            Map<Operation<?>, InboundInvocationChain> inboundChains = inboundWire.getInvocationChains();
            for (InboundInvocationChain chain : inboundChains.values()) {
                //TODO handle async
                // add target invoker on inbound side
                ServiceContract contract = inboundWire.getServiceContract();
                Operation operation = chain.getOperation();
                TargetInvoker invoker = reference.createTargetInvoker(contract, operation);
                chain.setTargetInvoker(invoker);
                chain.prepare();
            }
            OutboundWire outboundWire = reference.getOutboundWire();
            // connect the reference's inbound and outbound wires
            connect(inboundWire, outboundWire, true);
           
            if (reference instanceof CompositeReference) {
                // For a composite reference only, since its outbound wire comes
View Full Code Here

                } 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());
            }
View Full Code Here

        EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes();
        EasyMock.expect(outboundWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
        EasyMock.expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
        EasyMock.replay(outboundWire);

        Reference reference = EasyMock.createMock(Reference.class);
        EasyMock.expect(reference.getParent()).andReturn(null);
        EasyMock.expect(reference.createTargetInvoker(contract, operation)).andReturn(null);
        EasyMock.expect(reference.getInboundWire()).andReturn(inboundWire);
        EasyMock.expect(reference.getOutboundWire()).andReturn(outboundWire);
        EasyMock.replay(reference);

        connector.connect(reference);

        EasyMock.verify(reference);
View Full Code Here

        InboundWire targetWire = EasyMock.createMock(InboundWire.class);
        EasyMock.expect(targetWire.getServiceContract()).andReturn(contract).anyTimes();
        EasyMock.expect(targetWire.getInvocationChains()).andReturn(inboundChains);
        targetWire.getSourceCallbackInvocationChains("foo");
        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
        Reference target = EasyMock.createMock(Reference.class);
        EasyMock.expect(target.createTargetInvoker(EasyMock.isA(ServiceContract.class), EasyMock.isA(Operation.class)))
            .andReturn(null);
        EasyMock.replay(target);

        EasyMock.expect(targetWire.getContainer()).andReturn(target);
        EasyMock.replay(targetWire);
View Full Code Here

            if (componentType instanceof CompositeComponentType<?, ?, ?>) {
                // If this is the case, then it means that component has already been returned
                // by CompositeBuilder and thus its children, in particular composite references,
                // have been registered
                CompositeComponent compositeComponent = (CompositeComponent) component;
                Reference reference = (Reference) compositeComponent.getChild(referenceTarget.getReferenceName());
                assert reference != null;
                if (reference instanceof CompositeReference) {
                    reference.setOutboundWire(wire);
                    // Notice that now the more immediate container of the wire is the composite reference
                    wire.setContainer(reference);
                }
            }
        }
View Full Code Here

    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>();
View Full Code Here

    public void testInvocation() throws Exception {
        AbstractApplicationContext ctx = createSpringContext();
        SpringCompositeComponent parent = new SpringCompositeComponent("spring", ctx, null, null, null);
        parent.start();
        TestBean referenceTarget = new TestBeanImpl();
        Reference reference = createMock(Reference.class);
        expect(reference.getName()).andReturn("bar").anyTimes();
        expect(reference.isSystem()).andReturn(false).atLeastOnce();
        expect(reference.getInterface()).andStubReturn(TestBean.class);
        expect(reference.getServiceInstance()).andStubReturn(referenceTarget);
        replay(reference);
        parent.register(reference);
        ctx.getBean("foo");
    }
View Full Code Here

     */
    public void testReferenceAutowire() throws Exception {
        CompositeComponent parent = new CompositeComponentImpl("parent", null, null, null);
        parent.start();
        Source refSource = new SourceImpl();
        Reference reference = EasyMock.createMock(Reference.class);
        EasyMock.expect(reference.getName()).andReturn("service").atLeastOnce();
        EasyMock.expect(reference.getServiceInstance()).andReturn(refSource);
        EasyMock.expect(reference.isSystem()).andReturn(false).atLeastOnce();
        reference.getInterface();
        EasyMock.expectLastCall().andReturn(Source.class);
        EasyMock.replay(reference);
        parent.register(reference);

        Source source = parent.resolveInstance(Source.class);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.spi.component.Reference

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.