Examples of onEvent()


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

        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));
        assertEquals(0,source.getNumberInstantiated());
        scope.stop();
    }

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

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

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

        // end request
        scope.onEvent(new RequestEnd(this, new Object()));
        Assert.assertTrue(initDestroy.isDestroyed());
        Assert.assertTrue(destroyOnly.isDestroyed());

        scope.stop();
    }
View Full Code Here

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

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

        // end request
        scope.onEvent(new RequestEnd(this, new Object()));

        Assert.assertEquals(0, one.getNumberInstantiated());
        scope.stop();
    }
View Full Code Here

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

        // first request
        RequestScopeComponentImpl comp1 = (RequestScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
        Assert.assertNotNull(comp1);
        Object id = new Object();
        scope.onEvent(new RequestEnd(this,id));

        // second request
        RequestScopeComponentImpl comp2 = (RequestScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
        Assert.assertNotNull(comp2);
        Assert.assertNotSame(comp1, comp2);
View Full Code Here

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

        // second request
        RequestScopeComponentImpl comp2 = (RequestScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
        Assert.assertNotNull(comp2);
        Assert.assertNotSame(comp1, comp2);
        Object id2 = new Object();
        scope.onEvent(new RequestEnd(this,id2));

        scope.stop();
    }

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

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

        RequestScopeComponent comp1 = (RequestScopeComponent) scope.getContext("TestService1").getInstance(null);
        Assert.assertNotNull(comp1);
        RequestScopeComponent comp2 = (RequestScopeComponent) scope.getContext("NewTestService").getInstance(null);
        Assert.assertNotNull(comp2);
        Object id = new Object();
        scope.onEvent(new RequestEnd(this,id));
        scope.stop();
    }

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

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

        Assert.assertNotNull(comp1);
        scope.registerFactory(createConfiguration("NewTestService"));
        RequestScopeComponent comp2 = (RequestScopeComponent) scope.getContext("NewTestService").getInstance(null);
        Assert.assertNotNull(comp2);
        Object id = new Object();
        scope.onEvent(new RequestEnd(this,id));
        scope.stop();
    }

    /**
     * Tests setting no components in the scope
View Full Code Here

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

        scope.start();

        RequestScopeComponentImpl comp1 = (RequestScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
        Assert.assertNotNull(comp1);
        Object id = new Object();
        scope.onEvent(new RequestEnd(this,id));

        // second request
        // should be null since the other context (thread) expired w/ onEvent(..)
        Assert.assertNull(scope.getContextByKey("TestService1", Thread.currentThread()));
        // Note should test better using concurrent threads to pull the instance
View Full Code Here

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

        EventContext ctx = new EventContextImpl();
        RequestScopeContext scope = new RequestScopeContext(ctx);
        scope.registerFactories(MockContextFactory.createWiredContexts(Scope.REQUEST,scope));
        scope.start();
        Object request =  new Object();
        scope.onEvent(new RequestStart(this,request));
        OrderedDependentPojo source = (OrderedDependentPojo) scope.getContext("source").getInstance(null);
        assertNotNull(source.getPojo());
        // expire module
        assertEquals(2,source.getNumberInstantiated());
        scope.onEvent(new RequestEnd(this,request));
View Full Code Here

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

        scope.onEvent(new RequestStart(this,request));
        OrderedDependentPojo source = (OrderedDependentPojo) scope.getContext("source").getInstance(null);
        assertNotNull(source.getPojo());
        // expire module
        assertEquals(2,source.getNumberInstantiated());
        scope.onEvent(new RequestEnd(this,request));
        assertEquals(0,source.getNumberInstantiated());
        scope.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.