Package org.apache.tuscany.core.context

Examples of org.apache.tuscany.core.context.SystemCompositeContext


        ContextFactoryBuilderRegistry builderRegistry = BootstrapHelper.bootstrapContextFactoryBuilders(monitorFactory);
        DefaultWireBuilder wireBuilder = new DefaultWireBuilder();
        RuntimeContext runtime = new RuntimeContextImpl(monitorFactory, builderRegistry, wireBuilder);
        runtime.start();
        runtime.getSystemContext().registerModelObject(createSystemCompositeComponent(SYSTEM_CHILD));
        SystemCompositeContext ctx = (SystemCompositeContext) runtime.getSystemContext().getContext(SYSTEM_CHILD);
        Component comp = systemFactory.createSystemComponent(POLICY_BUILDER_REGISTRY, PolicyBuilderRegistry.class, DefaultPolicyBuilderRegistry.class, Scope.MODULE);
        comp.getImplementation().setComponentType(getIntrospector().introspect(DefaultPolicyBuilderRegistry.class));
        ctx.registerModelObject(comp);
        comp = systemFactory.createSystemComponent(MESSAGE_FACTORY, MessageFactory.class, MessageFactoryImpl.class, Scope.MODULE);
        comp.getImplementation().setComponentType(getIntrospector().introspect(MessageFactoryImpl.class));
        ctx.registerModelObject(comp);
        comp = systemFactory.createSystemComponent(PROXY_FACTORY_FACTORY, WireFactoryFactory.class, JDKWireFactoryFactory.class, Scope.MODULE);
        comp.getImplementation().setComponentType(getIntrospector().introspect(JDKWireFactoryFactory.class));
        ctx.registerModelObject(comp);
        comp = systemFactory.createSystemComponent(WIRE_FACTORY_SERVICE, org.apache.tuscany.core.wire.service.WireFactoryService.class, DefaultWireFactoryService.class, Scope.MODULE);
        comp.getImplementation().setComponentType(getIntrospector().introspect(DefaultWireFactoryService.class));
        ctx.registerModelObject(comp);
        comp = systemFactory.createSystemComponent(JAVA_BUILDER, ContextFactoryBuilder.class, JavaContextFactoryBuilder.class, Scope.MODULE);
        comp.getImplementation().setComponentType(getIntrospector().introspect(JavaContextFactoryBuilder.class));
        ctx.registerModelObject(comp);
        comp = systemFactory.createSystemComponent(JAVA_WIRE_BUILDER, WireBuilder.class, JavaTargetWireBuilder.class, Scope.MODULE);
        comp.getImplementation().setComponentType(getIntrospector().introspect(JavaTargetWireBuilder.class));
        ctx.registerModelObject(comp);
        ctx.publish(new ModuleStart(new Object()));
        return runtime;
    }
View Full Code Here


* @version $Rev$ $Date$
*/
public class IntraCompositeWireTestCase extends TestCase {

    public void testModuleToModuleScope() throws Exception {
        SystemCompositeContext context = createContext();
        context.start();
        context.registerModelObject(MockFactory.createSystemModuleWithWiredComponents("system.module",Scope.MODULE, Scope.MODULE));
        context.publish(new ModuleStart(this));
        Source source = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
        Assert.assertNotNull(source);
        Target targetRef = source.getTarget();
        Assert.assertNotNull(targetRef);
        Target target = (Target) ((AtomicContext) context.getContext("target")).getTargetInstance();
        Assert.assertSame(target, targetRef);
        Assert.assertSame(target, source.getTarget());
        context.publish(new ModuleStop(this));
        context.stop();
    }
View Full Code Here

        context.publish(new ModuleStop(this));
        context.stop();
    }

    public void testStatelessToModuleScope() throws Exception {
        SystemCompositeContext context = createContext();
        context.start();
        context.registerModelObject(MockFactory.createSystemModuleWithWiredComponents("system.module",Scope.INSTANCE, Scope.MODULE));
        context.publish(new ModuleStart(this));
        Source source = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
        Assert.assertNotNull(source);
        Target targetRef = source.getTarget();
        Assert.assertNotNull(targetRef);
        source = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
        Target target = (Target) ((AtomicContext) context.getContext("target")).getTargetInstance();
        Assert.assertSame(target, targetRef);
        Assert.assertSame(target, source.getTarget());
        context.publish(new ModuleStop(this));
        context.stop();
    }
View Full Code Here

        context.publish(new ModuleStop(this));
        context.stop();
    }

    public void testModuleToStatelessScope() throws Exception {
        SystemCompositeContext context = createContext();
        context.start();
        context.registerModelObject(MockFactory.createSystemModuleWithWiredComponents("system.module",Scope.MODULE, Scope.INSTANCE));
        context.publish(new ModuleStart(this));
        Source source = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
        Assert.assertNotNull(source);
        Target targetRef = source.getTarget();
        Assert.assertNotNull(targetRef);
        Target target = (Target) ((AtomicContext) context.getContext("target")).getTargetInstance();
        Assert.assertNotSame(target, targetRef);
        Source source2 = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
        // should be the same since the module scope component was alreadyy created and the stateless
        // component will be "attached" to it
        Assert.assertSame(source.getTarget(), source2.getTarget());
        context.publish(new ModuleStop(this));
        context.stop();
    }
View Full Code Here

        context.publish(new ModuleStop(this));
        context.stop();
    }

    public void testMultiplicity() throws Exception {
        SystemCompositeContext context = createContext();
        context.start();
        context.registerModelObject(MockFactory.createSystemModuleWithWiredComponents("system.module",Scope.MODULE, Scope.MODULE));
        context.publish(new ModuleStart(this));
        Source source = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
        Assert.assertNotNull(source);
        Target target = (Target) ((AtomicContext) context.getContext("target")).getTargetInstance();
        Assert.assertNotNull(target);
        // test setter injection
        List<Target> targets = source.getTargets();
        Assert.assertEquals(1,targets.size());
        assertSame(target,targets.get(0));
View Full Code Here

        ContextFactoryBuilderRegistry builderRegistry = BootstrapHelper.bootstrapContextFactoryBuilders(monitorFactory);
        runtime = new RuntimeContextImpl(monitorFactory, builderRegistry, new DefaultWireBuilder());
        runtime.start();

        // Load and start the system configuration
        SystemCompositeContext systemContext = runtime.getSystemContext();
        BootstrapHelper.bootstrapStaxLoader(systemContext, modelContext);
        ModuleComponentConfigurationLoader loader = BootstrapHelper.getConfigurationLoader(systemContext, modelContext);
        ModuleComponent systemModuleComponent = loader.loadSystemModuleComponent(SYSTEM_MODULE_COMPONENT, SYSTEM_MODULE_COMPONENT);
        CompositeContext context = BootstrapHelper.registerModule(systemContext, systemModuleComponent);
        context.publish(new ModuleStart(this));
View Full Code Here

    }

    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        moduleContext.publish(new ModuleStop(this));
        moduleContext.stop();
        SystemCompositeContext systemContext = runtime.getSystemContext();
        systemContext.publish(new ModuleStop(this));
        systemContext.stop();
        runtime.stop();
        servletContextEvent.getServletContext().removeAttribute(MODULE_COMPONENT_NAME);
        servletContextEvent.getServletContext().removeAttribute(TUSCANY_RUNTIME_NAME);
    }
View Full Code Here

        ContextFactoryBuilderRegistry builderRegistry = BootstrapHelper.bootstrapContextFactoryBuilders(monitorFactory);
        runtime = new RuntimeContextImpl(monitorFactory, builderRegistry, new DefaultWireBuilder());
        runtime.start();

        // Load and start the system configuration
        SystemCompositeContext systemContext = runtime.getSystemContext();
        BootstrapHelper.bootstrapStaxLoader(systemContext, modelContext);
        ModuleComponentConfigurationLoader loader = BootstrapHelper.getConfigurationLoader(systemContext, modelContext);
        ModuleComponent systemModuleComponent = loader.loadSystemModuleComponent(SYSTEM_MODULE_COMPONENT, SYSTEM_MODULE_COMPONENT);
        CompositeContext context = BootstrapHelper.registerModule(systemContext, systemModuleComponent);
        context.publish(new ModuleStart(this));
View Full Code Here

     * is wired to a component in system1
     */
    public void testScenario1() throws Exception {
        RuntimeContext runtime = createScenario1Runtime();
        CompositeContext root = runtime.getRootContext();
        SystemCompositeContext system = runtime.getSystemContext();
        CompositeContext system1 = (CompositeContext) system.getContext("system1");
        system1.publish(new ModuleStart(this));
        Target target = (Target) system.getContext("target.system.ep").getInstance(null);
        assertNotNull(target);
        CompositeContext app1 = (CompositeContext) root.getContext("app1");
        app1.publish(new ModuleStart(this));
        CompositeContext app1a = (CompositeContext) app1.getContext("app1a");
        app1a.publish(new ModuleStart(this));
View Full Code Here

     * Covers the case where a component in system1a requests autowire, which is resolved to an entry point exposed on
     * system2. The entry point is wired to a component in system2.
     */
    public void testScenario3() throws Exception {
        RuntimeContext runtime = createScenario3Runtime();
        SystemCompositeContext system = runtime.getSystemContext();

        CompositeContext system2 = (CompositeContext) system.getContext("system2");
        system2.publish(new ModuleStart(this));
        Target target = (Target) system2.getContext("target.ep").getInstance(null);
        assertNotNull(target);

        CompositeContext system1 = (CompositeContext) system.getContext("system1");
        system1.publish(new ModuleStart(this));
        CompositeContext system1a = (CompositeContext) system1.getContext("system1a");
        system1a.publish(new ModuleStart(this));

        Source source = (Source) system1a.getContext("source").getInstance(null);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.core.context.SystemCompositeContext

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.