Examples of AtomicComponent


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

    }

    public void connect(SCAObject source) {
        CompositeComponent parent = source.getParent();
        if (source instanceof AtomicComponent) {
            AtomicComponent sourceComponent = (AtomicComponent) source;
            // connect outbound wires for component references to their targets
            for (List<OutboundWire> referenceWires : sourceComponent.getOutboundWires().values()) {
                for (OutboundWire outboundWire : referenceWires) {
                    if (outboundWire instanceof OutboundAutowire) {
                        continue;
                    }
                    try {
                        SCAObject target;
                        if (sourceComponent.isSystem()) {
                            target = parent.getSystemChild(outboundWire.getTargetName().getPartName());
                        } else {
                            target = parent.getChild(outboundWire.getTargetName().getPartName());
                        }
                        connect(sourceComponent, outboundWire, target);
                    } catch (BuilderConfigException e) {
                        e.addContextName(source.getName());
                        e.addContextName(parent.getName());
                        throw e;
                    }
                }
            }
            // connect inbound wires
            for (InboundWire inboundWire : sourceComponent.getInboundWires().values()) {
                for (InboundInvocationChain chain : inboundWire.getInvocationChains().values()) {
                    Operation<?> operation = chain.getOperation();
                    String serviceName = inboundWire.getServiceName();
                    TargetInvoker invoker = sourceComponent.createTargetInvoker(serviceName, operation);
                    chain.setTargetInvoker(invoker);
                    chain.prepare();
                }
            }
        } else if (source instanceof Reference) {
View Full Code Here

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

    private void connect(SCAObject source, OutboundWire sourceWire, SCAObject target) throws BuilderConfigException {
        assert sourceWire.getTargetName() != null : "Wire target name was null";
        QualifiedName targetName = sourceWire.getTargetName();

        if (target instanceof AtomicComponent) {
            AtomicComponent targetComponent = (AtomicComponent) target;
            InboundWire targetWire = targetComponent.getInboundWire(targetName.getPortName());
            if (targetWire == null) {
                String refName = sourceWire.getReferenceName();
                BuilderConfigException e = new BuilderConfigException("No target service for reference " + refName);
                e.setIdentifier(targetName.getPortName());
                throw e;
View Full Code Here

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

        EasyMock.expect(targetWire.getInvocationChains()).andReturn(inboundChains);
        targetWire.getSourceCallbackInvocationChains("source");
        EasyMock.expectLastCall().andReturn(Collections.emptyMap());

        // create the target
        AtomicComponent target = EasyMock.createMock(AtomicComponent.class);
        EasyMock.expect(target.getScope()).andReturn(Scope.MODULE);
        target.getInboundWire(EasyMock.eq("FooService"));
        EasyMock.expectLastCall().andReturn(targetWire);
        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 outbound wire and chain from the source component
        OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
        EasyMock.expect(outboundChain.getOperation()).andReturn(operation).atLeastOnce();
        outboundChain.setTargetInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
        outboundChain.setTargetInvoker(null);
        outboundChain.prepare();
        EasyMock.replay(outboundChain);
        Map<Operation<?>, OutboundInvocationChain> outboundChains =
            new HashMap<Operation<?>, OutboundInvocationChain>();
        outboundChains.put(operation, outboundChain);
        OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
        EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes();
        EasyMock.expect(outboundWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
        EasyMock.expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
        outboundWire.getTargetCallbackInvocationChains();
        EasyMock.expectLastCall().andReturn(Collections.emptyMap());

        Map<String, List<OutboundWire>> outboundWires = new HashMap<String, List<OutboundWire>>();
        List<OutboundWire> list = new ArrayList<OutboundWire>();
        list.add(outboundWire);
        outboundWires.put("fooService", list);

        // create the source
        AtomicComponent source = EasyMock.createMock(AtomicComponent.class);
        EasyMock.expect(source.isSystem()).andReturn(false).atLeastOnce();
        EasyMock.expect(source.getScope()).andReturn(Scope.MODULE);
        EasyMock.expect(source.getParent()).andReturn(parent).atLeastOnce();
        EasyMock.expect(source.getOutboundWires()).andReturn(outboundWires);
        EasyMock.expect(source.getName()).andReturn("source");
        source.getInboundWires();
        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
        EasyMock.replay(source);

        EasyMock.expect(outboundWire.getContainer()).andReturn(source);
        EasyMock.replay(outboundWire);
View Full Code Here

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

        EasyMock.replay(wire);

        Map<String, InboundWire> wires = new HashMap<String, InboundWire>();
        wires.put("FooService", wire);

        AtomicComponent source = EasyMock.createMock(AtomicComponent.class);
        EasyMock.expect(source.getParent()).andReturn(null);
        source.getOutboundWires();
        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
        source.getInboundWires();
        EasyMock.expectLastCall().andReturn(wires);
        source.createTargetInvoker(EasyMock.eq("FooService"), EasyMock.eq(operation));
        EasyMock.expectLastCall().andReturn(null);
        EasyMock.replay(source);

        connector.connect(source);
View Full Code Here

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

        connector.connect(inboundChain, outboundChain);
        EasyMock.verify(inboundChain);
    }

    public void testOutboundWireToInboundReferenceTarget() {
        AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
        EasyMock.expect(component.getName()).andReturn("foo");
        EasyMock.replay(component);
        // 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);
View Full Code Here

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

                members,
                "target",
                OtherTarget.class,
                OtherTargetImpl.class,
                scope);
        AtomicComponent sourceComponent = contexts.get("source");
        Source source = (Source) sourceComponent.getServiceInstance();
        Target target = source.getTarget();
        assertTrue(Proxy.isProxyClass(target.getClass()));
        assertNotNull(target);
        scope.stop();
        EasyMock.verify(scope);
View Full Code Here

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

        ScopeContainer scope = createMock();
        scope.start();
        Map<String, AtomicComponent> contexts =
            MockFactory.createWiredMultiplicity("source", SourceImpl.class, Target.class, scope,
                "target", OtherTarget.class, OtherTargetImpl.class, members, scope);
        AtomicComponent sourceComponent = contexts.get("source");
        Source source = (Source) sourceComponent.getServiceInstance();
        List<Target> targets = source.getTargets();
        assertEquals(1, targets.size());
        Target target = targets.get(0);
        target.setString("foo");
        assertEquals("foo", target.getString());
View Full Code Here

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

        scope.getInstance(EasyMock.isA(AtomicComponent.class));
        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
            private Map<AtomicComponent, Object> cache = new HashMap<AtomicComponent, Object>();

            public Object answer() throws Throwable {
                AtomicComponent component = (AtomicComponent) EasyMock.getCurrentArguments()[0];
                Object instance = cache.get(component);
                if (instance == null) {
                    instance = component.createInstance();
                    cache.put(component, instance);
                }
                return instance;
            }
        }).anyTimes();
View Full Code Here

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

        EasyMock.expect(source.getParent()).andReturn(parent).atLeastOnce();
        EasyMock.replay(source);

        parent.register(source);

        AtomicComponent target = EasyMock.createMock(AtomicComponent.class);
        EasyMock.expect(target.getName()).andReturn("target").atLeastOnce();
        EasyMock.expect(target.getServiceInterfaces()).andReturn(services);
        EasyMock.expect(target.isSystem()).andReturn(false).atLeastOnce();
        EasyMock.replay(target);

        parent.register(target);
        try {
            parent.prepare();
View Full Code Here

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

        ScopeContainer scope = new ModuleScopeContainer(null);
        scope.start();
        Map<String, AtomicComponent> contexts =
            MockFactory.createWiredComponents("source", SourceImpl.class, scope,
                members, "target", Target.class, TargetImpl.class, scope);
        AtomicComponent sourceComponent = contexts.get("source");
        Source source = (Source) sourceComponent.getServiceInstance();
        Target target = source.getTarget();
        assertTrue(Proxy.isProxyClass(target.getClass()));

        assertNotNull(target);
        scope.stop();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.