Package org.apache.tuscany.core.context.scope

Examples of org.apache.tuscany.core.context.scope.CompositeScopeContext


    public SystemScopeStrategy() {
    }

    public Map<Scope, ScopeContext> getScopeContexts(EventContext eventContext) {
        ScopeContext aggregrateScope = new CompositeScopeContext(eventContext);
        ScopeContext moduleScoper = new ModuleScopeContext(eventContext);
        ScopeContext statelessScope = new StatelessScopeContext(eventContext);
        Map<Scope, ScopeContext> scopes = new HashMap<Scope, ScopeContext>();
        scopes.put(Scope.AGGREGATE, aggregrateScope);
        scopes.put(Scope.MODULE, moduleScoper);
View Full Code Here


     */
    public void testRegisterContextAfterStart() throws Exception {
        EventContext ctx = new EventContextImpl();
        CompositeContext moduleComponentCtx = new CompositeContextImpl();
        moduleComponentCtx.setName("testMC");
        CompositeScopeContext scopeContainer = new CompositeScopeContext(ctx);
        scopeContainer.start();

        scopeContainer.onEvent(new ModuleStart(this));
        scopeContainer.registerFactory(MockFactory.createCompositeConfiguration("CompositeComponent"));
        scopeContainer.getContext("CompositeComponent");
        scopeContainer.onEvent(new ModuleStop(this));
        scopeContainer.stop();
    }
View Full Code Here

    public RuntimeScopeStrategy() {
    }

    public Map<Scope, ScopeContext> getScopeContexts(EventContext eventContext) {
        ScopeContext aggregrateScope = new CompositeScopeContext(eventContext);
        Map<Scope, ScopeContext> scopes = new HashMap<Scope, ScopeContext>();
        scopes.put(Scope.AGGREGATE, aggregrateScope);
        return scopes;
    }
View Full Code Here

    public void testCompositeScopePropagation() throws Exception {
        EventContext ctx = new EventContextImpl();
        CompositeContext moduleComponentCtx = new CompositeContextImpl();
        moduleComponentCtx.setName("testMC");
        moduleComponentCtx.start();
        CompositeScopeContext scopeContainer = new CompositeScopeContext(ctx);
        scopeContainer.registerFactory(MockFactory.createCompositeConfiguration("CompositeComponent"));
        scopeContainer.start();
        CompositeContext child = (CompositeContext) scopeContainer.getContext("CompositeComponent");
        List<Extensible> models = createAssembly();
        for (Extensible model : models) {
            child.registerModelObject(model);
        }

        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);
        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);
        GenericComponent testService3a = (GenericComponent) componentCtx.getContext("TestService3").getInstance(null);
        Assert.assertNotNull(testService3a);
        Assert.assertEquals(testService2, testService2a);
        Assert.assertNotSame(testService3, testService3a);
        scopeContainer.onEvent(new RequestEnd(this,id));
        scopeContainer.onEvent(new HttpSessionEnd(this,session));

        Object session2 = new Object();
        Object id2 = new Object();
        scopeContainer.onEvent(new RequestStart(this,id2));
        scopeContainer.onEvent(new HttpSessionBound(this,session2));
        GenericComponent testService2b = (GenericComponent) componentCtx.getContext("TestService2").getInstance(null);
        Assert.assertNotNull(testService2b);
        Assert.assertNotSame(testService2, testService2b);

        scopeContainer.onEvent(new RequestEnd(this,id2));
        scopeContainer.onEvent(new HttpSessionEnd(this,session2));

    }
View Full Code Here

     */
    public void testCompositeNoEntryPoint() throws Exception {
        EventContext ctx = new EventContextImpl();
        CompositeContext moduleComponentCtx = new CompositeContextImpl();
        moduleComponentCtx.setName("testMC");
        CompositeScopeContext scopeContainer = new CompositeScopeContext(ctx);
        scopeContainer.registerFactory(MockFactory.createCompositeConfiguration("CompositeComponent"));
        scopeContainer.start();
        CompositeContext child = (CompositeContext) scopeContainer.getContext("CompositeComponent");
        List<Extensible> parts = createAssembly();
        for (Extensible part : parts) {
            child.registerModelObject(part);
        }
        scopeContainer.onEvent(new ModuleStart(this));
        scopeContainer.getContext("CompositeComponent");
    }
View Full Code Here

     */
    public void testRegisterContextBeforeStart() throws Exception {
        EventContext ctx = new EventContextImpl();
        CompositeContext moduleComponentCtx = new CompositeContextImpl();
        moduleComponentCtx.setName("testMC");
        CompositeScopeContext scopeContainer = new CompositeScopeContext(ctx);
        scopeContainer.registerFactory(MockFactory.createCompositeConfiguration("CompositeComponent"));
        scopeContainer.start();
        scopeContainer.onEvent(new ModuleStart(this));
        scopeContainer.getContext("CompositeComponent");
        scopeContainer.onEvent(new ModuleStop(this));
        scopeContainer.stop();
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.core.context.scope.CompositeScopeContext

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.