Examples of onEvent()


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

        scopeContainer.onEvent(new ModuleStart(this));
        Object session = new Object();
        Object id = new Object();
        //ctx.setIdentifier(EventContext.SESSION,session);
        scopeContainer.onEvent(new RequestStart(this,id));
        scopeContainer.onEvent(new HttpSessionBound(this,session));
        CompositeContext componentCtx = (CompositeContext) scopeContainer.getContext("CompositeComponent");
        GenericComponent testService1 = (GenericComponent) componentCtx.getContext("TestService1").getInstance(null);
        GenericComponent testService2 = (GenericComponent) componentCtx.getContext("TestService2").getInstance(null);
        GenericComponent testService3 = (GenericComponent) componentCtx.getContext("TestService3").getInstance(null);
        Assert.assertNotNull(testService1);
View Full Code Here

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

        GenericComponent testService2 = (GenericComponent) componentCtx.getContext("TestService2").getInstance(null);
        GenericComponent testService3 = (GenericComponent) componentCtx.getContext("TestService3").getInstance(null);
        Assert.assertNotNull(testService1);
        Assert.assertNotNull(testService2);
        Assert.assertNotNull(testService3);
        scopeContainer.onEvent(new RequestEnd(this,id));
        scopeContainer.onEvent(new RequestStart(this,id));
        scopeContainer.onEvent(new HttpSessionBound(this,session));

        GenericComponent testService2a = (GenericComponent) componentCtx.getContext("TestService2").getInstance(null);
        Assert.assertNotNull(testService2a);
View Full Code Here

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

    public void testInitDestroy() throws Exception {
        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);
View Full Code Here

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

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

    public void testEagerInit() throws Exception {
        EventContext ctx = new EventContextImpl();
        ModuleScopeContext scope = new ModuleScopeContext(ctx);
        scope.registerFactories(createEagerInitComponents());
        scope.start();
        scope.onEvent(new ModuleStart(this));
        ModuleScopeEagerInitDestroyComponent initDestroy = (ModuleScopeEagerInitDestroyComponent) scope.getContext(
                "TestServiceEagerInitDestroy").getInstance(null);
        Assert.assertNotNull(initDestroy);
        ModuleScopeEagerInitComponent initOnly = (ModuleScopeEagerInitComponent) scope
                .getContext("TestServiceEagerInit").getInstance(null);
View Full Code Here

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

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

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

        Assert.assertTrue(initDestroy.isDestroyed());

        scope.stop();
View Full Code Here

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

    public void testDestroyOrder() throws Exception {
        EventContext ctx = new EventContextImpl();
        ModuleScopeContext scope = new ModuleScopeContext(ctx);
        scope.registerFactories(createOrderedInitComponents());
        scope.start();
        scope.onEvent(new ModuleStart(this));
        OrderedInitPojo one = (OrderedInitPojo) scope.getContext("one").getInstance(null);
        Assert.assertNotNull(one);
        Assert.assertEquals(1, one.getNumberInstantiated());
        Assert.assertEquals(1, one.getInitOrder());
View Full Code Here

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

        Assert.assertNotNull(three);
        Assert.assertEquals(3, three.getNumberInstantiated());
        Assert.assertEquals(3, three.getInitOrder());

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

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

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

        wireBuilder.addWireBuilder(javaWireBuilder);
        Module module = MockFactory.createModule();
        EventContext eCtx = new EventContextImpl();
        ScopeContext scopeContext = new ModuleScopeContext(eCtx);
        scopeContext.start();
        scopeContext.onEvent(new ModuleStart(this));
        List<Component> components = module.getComponents();
        Map<String, Component> compMap = new HashMap<String, Component>(components.size());

        for (Component component : components) {
            compMap.put(component.getName(), component);
View Full Code Here

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

    public void testEagerInitDestroyOrder() throws Exception {
        EventContext ctx = new EventContextImpl();
        ModuleScopeContext scope = new ModuleScopeContext(ctx);
        scope.registerFactories(createOrderedEagerInitComponents());
        scope.start();
        scope.onEvent(new ModuleStart(this));
        OrderedEagerInitPojo one = (OrderedEagerInitPojo) scope.getContext("one").getInstance(null);
        Assert.assertNotNull(one);

        OrderedEagerInitPojo two = (OrderedEagerInitPojo) scope.getContext("two").getInstance(null);
        Assert.assertNotNull(two);
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.