Package org.apache.tuscany.core.implementation.composite

Examples of org.apache.tuscany.core.implementation.composite.CompositeComponentImpl


        }
        */

        // create the composite component
        String name = componentDefinition.getName();
        CompositeComponent component = new CompositeComponentImpl(name, parent, connector, null);
        for (ComponentDefinition<? extends Implementation> childComponentDefinition : allComponents) {
            component.register(builderRegistry.build(component, childComponentDefinition, deploymentContext));
        }

        for (BoundServiceDefinition<? extends Binding> serviceDefinition : allBoundServices) {
            component.register(builderRegistry.build(component, serviceDefinition, deploymentContext));
        }
        return component;
    }
View Full Code Here


        scope.start();

        Connector connector = new ConnectorImpl();
        SystemComponentBuilder builder = new SystemComponentBuilder();

        CompositeComponent parent = new CompositeComponentImpl(null, null, connector, null);

        ComponentDefinition<SystemImplementation> targetComponentDefinition = MockComponentFactory.createTarget();
        ComponentDefinition<SystemImplementation> sourceComponentDefinition =
            MockComponentFactory.createSourceWithTargetReference();

        AtomicComponent sourceComponent = builder.build(parent, sourceComponentDefinition, deploymentContext);
        AtomicComponent targetComponent = builder.build(parent, targetComponentDefinition, deploymentContext);

        parent.register(sourceComponent);
        parent.register(targetComponent);
        parent.prepare();
        parent.start();
        scope.onEvent(new CompositeStart(this, parent));
        Source source = (Source) parent.getSystemChild("source").getServiceInstance();
        assertNotNull(source);
        Target target = (Target) parent.getSystemChild("target").getServiceInstance();
        assertNotNull(target);
        assertSame(target, source.getTarget());
        scope.onEvent(new CompositeStop(this, parent));
        parent.stop();
        scope.stop();
    }
View Full Code Here

        Connector connector = new ConnectorImpl();
        SystemComponentBuilder builder = new SystemComponentBuilder();
        SystemBindingBuilder bindingBuilder = new SystemBindingBuilder();

        CompositeComponent grandParent = new CompositeComponentImpl("grandparent", null, null, null);
        CompositeComponent parent = new CompositeComponentImpl("parent", grandParent, null, null);

        // create a context in the grandparent that the reference will be autowired to
        ComponentDefinition<SystemImplementation> targetComponentDefinition = MockComponentFactory.createTarget();
        AtomicComponent targetComponentComponent = builder.build(parent, targetComponentDefinition, deploymentContext);
        grandParent.register(targetComponentComponent);

        BoundReferenceDefinition<SystemBinding> targetReferenceDefinition = MockComponentFactory.createBoundReference();
        ComponentDefinition<SystemImplementation> sourceComponentDefinition =
            MockComponentFactory.createSourceWithTargetReference();

        AtomicComponent sourceComponent = builder.build(parent, sourceComponentDefinition, deploymentContext);
        Reference reference = bindingBuilder.build(parent, targetReferenceDefinition, deploymentContext);

        parent.register(sourceComponent);
        parent.register(reference);
        connector.connect(reference.getInboundWire(), reference.getOutboundWire(), true);
        connector.connect(sourceComponent);
        grandParent.register(parent);
        grandParent.start();
        scope.onEvent(new CompositeStart(this, parent));
        Source source = (Source) parent.getSystemChild("source").getServiceInstance();
        assertNotNull(source);
        Target target = (Target) parent.getSystemChild("target").getServiceInstance();
        assertNotNull(target);
        assertSame(target, source.getTarget());
        scope.onEvent(new CompositeStop(this, parent));
        grandParent.stop();
        scope.stop();
View Full Code Here

        ConnectorImpl connector = new ConnectorImpl();
        SystemComponentBuilder builder = new SystemComponentBuilder();
        SystemBindingBuilder bindingBuilder = new SystemBindingBuilder();

        CompositeComponent parent = new CompositeComponentImpl(null, null, null, null);

        BoundServiceDefinition<SystemBinding> serviceDefinition = MockComponentFactory.createBoundService();
        ComponentDefinition<SystemImplementation> componentDefinition = MockComponentFactory.createTarget();

        AtomicComponent sourceComponent = builder.build(parent, componentDefinition, deploymentContext);
        parent.register(sourceComponent);

        Service service = bindingBuilder.build(parent, serviceDefinition, deploymentContext);
        parent.register(service);

        connector.connect(sourceComponent);
        connector.connect(service);

        parent.start();
        scope.onEvent(new CompositeStart(this, parent));
        Target target = (Target) parent.getSystemChild("serviceDefinition").getServiceInstance();
        assertNotNull(target);
        Target target2 = (Target) parent.getSystemChild("target").getServiceInstance();
        assertNotNull(target);
        assertSame(target, target2);
        scope.onEvent(new CompositeStop(this, parent));
        parent.stop();
        scope.stop();

    }
View Full Code Here

*/
public class JavaComponentBuilderTestCase extends TestCase {
    private DeploymentContext deploymentContext;

    public void testBuild() throws Exception {
        CompositeComponent parent = new CompositeComponentImpl(null, null, null, null);

        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> sourceType =
            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
        sourceType.setImplementationScope(Scope.MODULE);
        JavaMappedReference reference = new JavaMappedReference();
View Full Code Here

     * @return a newly created root for the component tree
     */
    public RuntimeComponent createRuntime() {
        DefaultRuntime runtime = new DefaultRuntime();
        CompositeComponent systemComponent =
            new CompositeComponentImpl(ComponentNames.TUSCANY_SYSTEM, runtime, null, null);
        runtime.setSystemComponent(systemComponent);
        CompositeComponent rootComponent =
            new CompositeComponentImpl(ComponentNames.TUSCANY_ROOT, runtime, null, null);
        runtime.setRootComponent(rootComponent);
        return runtime;
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.core.implementation.composite.CompositeComponentImpl

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.