Package org.apache.tuscany.spi.component

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


        // create and start the core runtime
        runtime = bootstrapper.createRuntime();
        runtime.start(); // REVIEW: is this redundant w/ the composite.start() call below?

        // initialize the runtime info
        CompositeComponent parent = runtime.getSystemComponent();
        RuntimeInfo runtimeInfo = new LauncherRuntimeInfo(getInstallDirectory(), getApplicationRootDirectory(), true);
        parent.registerJavaObject("RuntimeInfo", RuntimeInfo.class, runtimeInfo);

        // registory the monitor factory
        parent.registerJavaObject("MonitorFactory", MonitorFactory.class, monitor);

        // create a ComponentDefinition to represent the component we are going to deploy
        SystemCompositeImplementation moduleImplementation = new SystemCompositeImplementation();
        moduleImplementation.setScdlLocation(systemScdl);
        moduleImplementation.setClassLoader(systemClassLoader);
View Full Code Here


        impl.setClassLoader(applicationLoader);
        ComponentDefinition<CompositeImplementation> moduleDefinition =
            new ComponentDefinition<CompositeImplementation>(name, impl);

        // deploy the component into the runtime under the system parent
        CompositeComponent parent = runtime.getRootComponent();
        // FIXME andyp -- this seems bogus when running inside an appserver
        ClassLoader ccl = Thread.currentThread().getContextClassLoader();

        try {
View Full Code Here

            e.addContextName(componentDefinition.getName());
            throw e;
        }
        Component component = (Component) build(parent, componentDefinition, deploymentContext);
        if (component instanceof CompositeComponent) {
            CompositeComponent composite = (CompositeComponent) component;
            composite.setScopeContainer(moduleScope);
        }
        component.prepare();
        parent.register(component);
        return component;
    }
View Full Code Here

    }

    public SystemReference build(CompositeComponent parent,
                                 BoundReferenceDefinition<SystemBinding> boundReferenceDefinition,
                                 DeploymentContext deploymentContext) {
        CompositeComponent autowireComponent = parent.getParent();
        Class<?> interfaze = boundReferenceDefinition.getServiceContract().getInterfaceClass();
        String name = boundReferenceDefinition.getName();
        SystemReferenceImpl reference = new SystemReferenceImpl(name, interfaze, parent);
        SystemInboundWire inboundWire = new SystemInboundWireImpl(name, interfaze);
        String refName = boundReferenceDefinition.getName();
View Full Code Here

        }
        EasyMock.verify(service);
    }

    public void testSystemGetService() throws NoSuchMethodException {
        CompositeComponent parent = new CompositeComponentImpl("foo", null, null, null);
        parent.start();
        Service service = EasyMock.createMock(Service.class);
        EasyMock.expect(service.getName()).andReturn("source").atLeastOnce();
        EasyMock.expect(service.isSystem()).andReturn(true).atLeastOnce();
        service.getInterface();
        EasyMock.expectLastCall().andReturn(Source.class);
        EasyMock.replay(service);
        parent.register(service);
        assertNotNull(parent.getSystemService("source"));
        try {
            parent.getService("source");
            fail();
        } catch (ComponentNotFoundException e) {
            // expected
        }
        EasyMock.verify(service);
View Full Code Here

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

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

        EasyMock.expect(outbound.getServiceContract()).andReturn(new JavaServiceContract(Foo.class)).atLeastOnce();
        List<OutboundWire> wires = new ArrayList<OutboundWire>();
        wires.add(outbound);
        Map<String, List<OutboundWire>> wireMap = new HashMap<String, List<OutboundWire>>();
        wireMap.put("ref", wires);
        CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, new ConnectorImpl(), null);
        SystemAtomicComponent source = EasyMock.createMock(SystemAtomicComponent.class);
        EasyMock.expect(source.getScope()).andReturn(Scope.MODULE).atLeastOnce();
        EasyMock.expect(source.getName()).andReturn("source").atLeastOnce();
        EasyMock.expect(source.getServiceInterfaces()).andReturn(services);
        EasyMock.expect(source.getOutboundWires()).andReturn(wireMap);
        source.getInboundWires();
        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
        EasyMock.expect(source.isSystem()).andReturn(true).atLeastOnce();
        EasyMock.expect(source.getParent()).andReturn(parent).atLeastOnce();

        source.prepare();
        EasyMock.replay(source);

        EasyMock.expect(outbound.getContainer()).andReturn(source);
        EasyMock.replay(outbound);

        parent.register(source);

        SystemAtomicComponent target = EasyMock.createMock(SystemAtomicComponent.class);
        EasyMock.expect(target.getName()).andReturn("target").atLeastOnce();
        EasyMock.expect(target.getServiceInterfaces()).andReturn(services);
        EasyMock.expect(target.getInboundWire("bar")).andReturn(inbound).atLeastOnce();
        EasyMock.expect(target.getScope()).andReturn(Scope.MODULE).atLeastOnce();
        EasyMock.expect(target.getParent()).andReturn(parent).atLeastOnce();
        target.getInboundWires();
        EasyMock.expectLastCall().andReturn(Collections.emptyMap());

        target.prepare();
        target.getOutboundWires();
        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
        EasyMock.expect(target.isSystem()).andReturn(true).atLeastOnce();
        EasyMock.replay(target);

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

        parent.register(target);
        parent.prepare();
        EasyMock.verify(source);
        EasyMock.verify(target);
        EasyMock.verify(inbound);
        EasyMock.verify(outbound);
    }
View Full Code Here

        List<OutboundWire> wires = new ArrayList<OutboundWire>();
        wires.add(outbound);
        Map<String, List<OutboundWire>> wireMap = new HashMap<String, List<OutboundWire>>();
        wireMap.put("ref", wires);
        CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, new ConnectorImpl(), null);
        SystemAtomicComponent source = EasyMock.createMock(SystemAtomicComponent.class);
        EasyMock.expect(source.getName()).andReturn("source").atLeastOnce();
        EasyMock.expect(source.getServiceInterfaces()).andReturn(services);
        EasyMock.expect(source.getOutboundWires()).andReturn(wireMap);
        EasyMock.expect(source.isSystem()).andReturn(true).atLeastOnce();
        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();
            fail();
        } catch (BuilderConfigException e) {
            //expected
        }
        EasyMock.verify(source);
View Full Code Here

* @version $Rev: 451895 $ $Date: 2006-10-01 23:58:18 -0700 (Sun, 01 Oct 2006) $
*/
public class CompositeComponentImplBasicTestCase extends TestCase {

    public void testGetScope() {
        CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
        Assert.assertEquals(Scope.COMPOSITE, composite.getScope());
    }
View Full Code Here

TOP

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

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.