Examples of ModuleScopeInitDestroyComponent


Examples of org.apache.tuscany.container.java.mock.components.ModuleScopeInitDestroyComponent

        EventContext ctx = new EventContextImpl();
        ModuleScopeContext scope = new ModuleScopeContext(ctx);
        scope.registerFactories(createComponents());
        scope.start();
        scope.onEvent(new ModuleStart(this));
        ModuleScopeInitDestroyComponent initDestroy = (ModuleScopeInitDestroyComponent) scope.getContext(
                "TestServiceInitDestroy").getInstance(null);
        Assert.assertNotNull(initDestroy);
        ModuleScopeInitOnlyComponent initOnly = (ModuleScopeInitOnlyComponent) scope.getContext("TestServiceInitOnly")
                .getInstance(null);
        Assert.assertNotNull(initOnly);
        ModuleScopeDestroyOnlyComponent destroyOnly = (ModuleScopeDestroyOnlyComponent) scope.getContext(
                "TestServiceDestroyOnly").getInstance(null);
        Assert.assertNotNull(destroyOnly);

        Assert.assertTrue(initDestroy.isInitialized());
        Assert.assertTrue(initOnly.isInitialized());
        Assert.assertFalse(initDestroy.isDestroyed());
        Assert.assertFalse(destroyOnly.isDestroyed());

        // expire module
        scope.onEvent(new ModuleStop(this));

        Assert.assertTrue(initDestroy.isDestroyed());
        Assert.assertTrue(destroyOnly.isDestroyed());

        scope.stop();
    }
View Full Code Here

Examples of org.apache.tuscany.container.java.mock.components.ModuleScopeInitDestroyComponent

        ModuleScopeContext scope = new ModuleScopeContext(ctx);
        scope.registerFactories(createConfigurations());
        scope.start();
        scope.registerFactory(createConfiguration("NewTestService"));
        scope.onEvent(new ModuleStart(this));
        ModuleScopeInitDestroyComponent comp2 = (ModuleScopeInitDestroyComponent) scope.getContext("NewTestService").getInstance(null);
        Assert.assertNotNull(comp2);
        Assert.assertTrue(comp2.isInitialized());
        scope.onEvent(new ModuleStop(this));
        Assert.assertTrue(comp2.isDestroyed());
        scope.stop();
    }
View Full Code Here

Examples of org.apache.tuscany.container.java.mock.components.ModuleScopeInitDestroyComponent

        ModuleScopeContext scope = new ModuleScopeContext(ctx);
        scope.start();
        scope.registerFactory(createConfiguration("NewTestService"));
        scope.onEvent(new ModuleStart(this));
        scope.registerFactories(createConfigurations());
        ModuleScopeInitDestroyComponent comp2 = (ModuleScopeInitDestroyComponent) scope.getContext("NewTestService").getInstance(null);
        Assert.assertNotNull(comp2);
        Assert.assertTrue(comp2.isInitialized());
        scope.onEvent(new ModuleStop(this));
        Assert.assertTrue(comp2.isDestroyed());
        scope.stop();
    }
View Full Code Here

Examples of org.apache.tuscany.core.mock.component.ModuleScopeInitDestroyComponent

            scope,
            ModuleScopeDestroyOnlyComponent.class);
        destroyOnlyContext.start();

        scope.onEvent(new CompositeStart(this, null));
        ModuleScopeInitDestroyComponent initDestroy =
            (ModuleScopeInitDestroyComponent) scope.getInstance(initDestroyContext);
        Assert.assertNotNull(initDestroy);

        ModuleScopeInitOnlyComponent initOnly = (ModuleScopeInitOnlyComponent) scope.getInstance(initOnlyContext);
        Assert.assertNotNull(initOnly);

        ModuleScopeDestroyOnlyComponent destroyOnly =
            (ModuleScopeDestroyOnlyComponent) scope.getInstance(destroyOnlyContext);
        Assert.assertNotNull(destroyOnly);

        Assert.assertTrue(initDestroy.isInitialized());
        Assert.assertTrue(initOnly.isInitialized());
        Assert.assertFalse(initDestroy.isDestroyed());
        Assert.assertFalse(destroyOnly.isDestroyed());

        // expire module
        scope.onEvent(new CompositeStop(this, null));

        Assert.assertTrue(initDestroy.isDestroyed());
        Assert.assertTrue(destroyOnly.isDestroyed());

        scope.stop();
    }
View Full Code Here

Examples of org.apache.tuscany.core.mock.component.ModuleScopeInitDestroyComponent

        WorkContext workContext = new WorkContextImpl();
        ModuleScopeContainer scopeContext = new ModuleScopeContainer(workContext);
        scopeContext.start();
        SystemAtomicComponent atomicContext = createContext(scopeContext);
        // start the request
        ModuleScopeInitDestroyComponent o1 =
            (ModuleScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
        assertTrue(o1.isInitialized());
        assertFalse(o1.isDestroyed());
        ModuleScopeInitDestroyComponent o2 =
            (ModuleScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
        assertEquals(o1, o2);
        scopeContext.onEvent(new CompositeStop(this, null));
        assertTrue(o1.isDestroyed());
        scopeContext.stop();
View Full Code Here

Examples of org.apache.tuscany.core.mock.component.ModuleScopeInitDestroyComponent

        ModuleScopeContainer scopeContext = new ModuleScopeContainer(workContext);
        scopeContext.start();

        SystemAtomicComponent atomicContext = createContext(scopeContext);

        ModuleScopeInitDestroyComponent o1 =
            (ModuleScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
        assertTrue(o1.isInitialized());
        assertFalse(o1.isDestroyed());

        ModuleScopeInitDestroyComponent o2 =
            (ModuleScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
        assertSame(o1, o2);
        scopeContext.onEvent(new CompositeStop(this, null));
        assertTrue(o1.isDestroyed());
        scopeContext.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.