Examples of onEvent()


Examples of org.apache.tuscany.core.context.scope.ModuleScopeContext.onEvent()

        OrderedEagerInitPojo three = (OrderedEagerInitPojo) scope.getContext("three").getInstance(null);
        Assert.assertNotNull(three);

        // expire module
        scope.onEvent(new ModuleStop(this));
        Assert.assertEquals(0, one.getNumberInstantiated());
        scope.stop();
    }

View Full Code Here

Examples of org.apache.tuscany.core.context.scope.ModuleScopeContext.onEvent()

        EventContext ctx = new EventContextImpl();
        ModuleScopeContext scope = new ModuleScopeContext(ctx);
        scope.registerFactories(createConfigurations());
        scope.start();
        // first request
        scope.onEvent(new ModuleStart(this));
        ModuleScopeComponentImpl comp1 = (ModuleScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
        Assert.assertNotNull(comp1);
        // second request
        ModuleScopeComponentImpl comp2 = (ModuleScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
        Assert.assertNotNull(comp2);
View Full Code Here

Examples of org.apache.tuscany.core.context.scope.ModuleScopeContext.onEvent()

        Assert.assertNotNull(comp1);
        // second request
        ModuleScopeComponentImpl comp2 = (ModuleScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
        Assert.assertNotNull(comp2);
        Assert.assertSame(comp1, comp2);
        scope.onEvent(new ModuleStop(this));
        scope.stop();
    }

    public void testSetNullComponents() throws Exception {
        EventContext ctx = new EventContextImpl();
View Full Code Here

Examples of org.apache.tuscany.core.context.scope.ModuleScopeContext.onEvent()

    public void testSetNullComponents() throws Exception {
        EventContext ctx = new EventContextImpl();
        ModuleScopeContext scope = new ModuleScopeContext(ctx);
        scope.registerFactories(createConfigurations());
        scope.start();
        scope.onEvent(new ModuleStart(this));
        scope.onEvent(new ModuleStop(this));
        scope.stop();
    }

    public void testRegisterContextBeforeStart() throws Exception {
View Full Code Here

Examples of org.apache.tuscany.core.context.scope.ModuleScopeContext.onEvent()

        EventContext ctx = new EventContextImpl();
        ModuleScopeContext scope = new ModuleScopeContext(ctx);
        scope.registerFactories(createConfigurations());
        scope.start();
        scope.onEvent(new ModuleStart(this));
        scope.onEvent(new ModuleStop(this));
        scope.stop();
    }

    public void testRegisterContextBeforeStart() throws Exception {
        EventContext ctx = new EventContextImpl();
View Full Code Here

Examples of org.apache.tuscany.core.context.scope.ModuleScopeContext.onEvent()

        EventContext ctx = new EventContextImpl();
        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());
View Full Code Here

Examples of org.apache.tuscany.core.context.scope.ModuleScopeContext.onEvent()

        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();
    }

    public void testRegisterContextAfterStart() throws Exception {
View Full Code Here

Examples of org.apache.tuscany.core.context.scope.ModuleScopeContext.onEvent()

    public void testRegisterContextAfterStart() throws Exception {
        EventContext ctx = new EventContextImpl();
        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));
View Full Code Here

Examples of org.apache.tuscany.core.context.scope.ModuleScopeContext.onEvent()

        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.context.scope.ModuleScopeContext.onEvent()

    public void testInitDestroyOrderModuleScope() throws Exception {
        EventContext ctx = new EventContextImpl();
        ModuleScopeContext scope = new ModuleScopeContext(ctx);
        scope.registerFactories(MockContextFactory.createWiredContexts(Scope.MODULE,scope));
        scope.start();
        scope.onEvent(new ModuleStart(this));
        OrderedDependentPojo source = (OrderedDependentPojo) scope.getContext("source").getInstance(null);
        assertNotNull(source.getPojo());
        // expire module
        assertEquals(2,source.getNumberInstantiated());
        scope.onEvent(new ModuleStop(this));
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.