Package org.apache.tuscany.core.context

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


     */
    public void testSystemContext() throws Exception {
        RuntimeContext runtime = MockFactory.createCoreRuntime();
        ModuleComponent child1 = createHierarchy();
        runtime.getSystemContext().registerModelObject(child1);
        CompositeContext child1Ctx = (CompositeContext) runtime.getSystemContext().getContext("child1");
        Assert.assertNotNull(child1Ctx);
        child1Ctx.publish(new ModuleStart(this));
        analyzeLeafComponents(child1Ctx);
        CompositeContext child2Ctx = (CompositeContext) child1Ctx.getContext("child2");
        Assert.assertNotNull(child2Ctx);
        child2Ctx.publish(new ModuleStart(this));
        analyzeLeafComponents(child2Ctx);
        CompositeContext child3Ctx = (CompositeContext) child2Ctx.getContext("child3");
        Assert.assertNotNull(child3Ctx);
        child3Ctx.publish(new ModuleStart(this));
        analyzeLeafComponents(child3Ctx);
       
        Assert.assertNull(child1Ctx.getContext("child3")); // sanity check
    }
View Full Code Here


     * @return the system context for the loader
     * @throws ConfigurationException
     */
    public static CompositeContext bootstrapStaxLoader(SystemCompositeContext parentContext, AssemblyContext modelContext) throws ConfigurationException {
        ModuleComponent loaderComponent = StAXUtil.bootstrapLoader(SYSTEM_LOADER_COMPONENT, modelContext);
        CompositeContext loaderContext = registerModule(parentContext, loaderComponent);
        loaderContext.publish(new ModuleStart(loaderComponent));
        return loaderContext;
    }
View Full Code Here

     */
    public void testRootContext() throws Exception {
        RuntimeContext runtime = MockFactory.createCoreRuntime();
        ModuleComponent child1 = createHierarchy();
        runtime.getRootContext().registerModelObject(child1);
        CompositeContext child1Ctx = (CompositeContext) runtime.getRootContext().getContext("child1");
        Assert.assertNotNull(child1Ctx);
        child1Ctx.publish(new ModuleStart(this));
        analyzeLeafComponents(child1Ctx);
        CompositeContext child2Ctx = (CompositeContext) child1Ctx.getContext("child2");
        Assert.assertNotNull(child2Ctx);
        child2Ctx.publish(new ModuleStart(this));
        analyzeLeafComponents(child2Ctx);
        CompositeContext child3Ctx = (CompositeContext) child2Ctx.getContext("child3");
        Assert.assertNotNull(child3Ctx);
        child3Ctx.publish(new ModuleStart(this));
        analyzeLeafComponents(child3Ctx);
       
        Assert.assertNull(child1Ctx.getContext("child3")); // sanity check
        child1Ctx.publish(new ModuleStop(this));
    }
View Full Code Here

    public void testChildLocate() throws Exception {
        system.start();
        Component compositeComponent = MockFactory.createCompositeComponent("system.child");
        system.registerModelObject(compositeComponent);
        CompositeContext childContext = (CompositeContext) system.getContext("system.child");
        Assert.assertNotNull(childContext);

        Component component = factory.createSystemComponent("TestService1", ModuleScopeSystemComponent.class, ModuleScopeSystemComponentImpl.class, Scope.MODULE);
        EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1", component);
        childContext.registerModelObject(component);
        childContext.registerModelObject(ep);
        childContext.publish(new ModuleStart(this));
        Assert.assertNotNull(system.getContext("system.child").getInstance(new QualifiedName("./TestService1EP")));
        childContext.publish(new ModuleStop(this));
    }
View Full Code Here

        // 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));

        // Load the SCDL configuration of the application module
        CompositeContext rootContext = runtime.getRootContext();
        ModuleComponent moduleComponent = loader.loadModuleComponent(name, uri);
        moduleContext = BootstrapHelper.registerModule(rootContext, moduleComponent);

        moduleContext.publish(new ModuleStart(this));
    }
View Full Code Here

     * exposed on an entry point in tuscany.system. The entry point is wired to an entry point on system1, which itself
     * 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));
        app1a.publish(new ModuleStop(this));
        app1.publish(new ModuleStop(this));
        Source source = (Source) app1a.getContext("source").getInstance(null);
        assertEquals(target, source.getTarget());
        source.getTarget().getString();
        runtime.stop();
    }
View Full Code Here

     * Covers the case where a component in app1a requests autowire, which is resolved to service exposed as an entry
     * point on app1b. The entry point is wired to a component in app1b.
     */
    public void testScenario2() throws Exception {
        RuntimeContext runtime = createScenario2Runtime();
        CompositeContext root = runtime.getRootContext();
        CompositeContext app1 = (CompositeContext) root.getContext("app1");
        app1.publish(new ModuleStart(this));
        CompositeContext app1b = (CompositeContext) app1.getContext("app1b");
        app1b.publish(new ModuleStart(this));
        CompositeContext app1a = (CompositeContext) app1.getContext("app1a");
        app1a.publish(new ModuleStart(this));
        Target target = (Target) app1b.getContext("target.ep").getInstance(null);
        assertNotNull(target);
        Source source = (Source) app1a.getContext("source").getInstance(null);
        assertEquals(target, source.getTarget());
        source.getTarget().getString();
        runtime.stop();
    }
View Full Code Here

     */
    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);
        assertEquals(target, source.getTarget());
        source.getTarget().getString();
        runtime.stop();
    }
View Full Code Here

     * system1.
     */
    public void testScenario4() throws Exception {
        RuntimeContext runtime = createScenario4Runtime();
        SystemCompositeContext system = runtime.getSystemContext();
        CompositeContext system1 = (CompositeContext) system.getContext("system1");
        system1.publish(new ModuleStart(this));
        Target target = (Target) system1.getContext("target").getInstance(null);
        assertNotNull(target);
        CompositeContext system1a = (CompositeContext) system1.getContext("system1a");
        system1a.publish(new ModuleStart(this));

        Source source = (Source) system1a.getContext("source").getInstance(null);
        assertEquals(target, source.getTarget());
        source.getTarget().getString();
        runtime.stop();
    }
View Full Code Here

     * its parent (grandparent), system.
     */
    public void testScenario5() throws Exception {
        RuntimeContext runtime = createScenario5Runtime();
        SystemCompositeContext system = runtime.getSystemContext();
        CompositeContext system1 = (CompositeContext) system.getContext("system1");
        system1.publish(new ModuleStart(this));
        Target target = (Target) system.getContext("target").getInstance(null);
        assertNotNull(target);
        CompositeContext system1a = (CompositeContext) system1.getContext("system1a");
        system1a.publish(new ModuleStart(this));

        Source source = (Source) system1a.getContext("source").getInstance(null);
        assertEquals(target, source.getTarget());
        source.getTarget().getString();
        runtime.stop();
    }
View Full Code Here

TOP

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

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.