Package org.apache.tuscany.core.context.event

Examples of org.apache.tuscany.core.context.event.RequestStart


        runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
        CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
        child.registerModelObject(MockFactory.createModuleWithEntryPointToExternalService());
        child.publish(new ModuleStart(this));
        Object id = new Object();
        child.publish(new RequestStart(this, id));
        HelloWorldService service1 = (HelloWorldService) child.getContext("target").getInstance(null);
        Assert.assertEquals("foo", service1.hello("foo"));

        child.publish(new RequestEnd(this, id));
        child.publish(new ModuleStop(this));
View Full Code Here


    public void start() {
        setModuleContext((ModuleContext) moduleContext);
        try {
            //moduleContext.start();
            moduleContext.publish(new ModuleStart(this));
            moduleContext.publish(new RequestStart(this, new Object()));
            moduleContext.publish(new HttpSessionBound(this, sessionKey));
            monitor.moduleStarted(moduleContext.getName());
        } catch (CoreRuntimeException e) {
            setModuleContext(null);
            monitor.moduleStartFailed(moduleContext.getName(), e);
View Full Code Here

                }
            } else {
                moduleContext.publish(new HttpSessionBound(this, request));
            }
            // Start processing the request
            moduleContext.publish(new RequestStart(this, request));
            // Dispatch to the next filter
            filterChain.doFilter(request, response);
        } catch (Exception e) {
            throw new ServletException(e);
View Full Code Here

                    // Create a lazy wrapper since a session is not yet active
                    moduleComponentContext.publish(new HttpSessionBound(this, new LazyHTTPSessionId(request)));
                }

                try {
                    moduleComponentContext.publish(new RequestStart(this, requestId));
                } catch (Exception e) {
                    throw new ServletException(e.getMessage(), e);
                }
                request.setNote(REQUEST_ID, requestId);
View Full Code Here

        runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
        CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
        child.registerModelObject(MockFactory.createModuleWithEntryPoint(Scope.MODULE));
        child.publish(new ModuleStart(this));
        Object id = new Object();
        child.publish(new RequestStart(this, id));
        EntryPointContext ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        InvocationHandler handler = (InvocationHandler) ctx.getHandler();
        Assert.assertEquals(0, mockInterceptor.getCount());
        Object response = handler.invoke(null, hello, new Object[]{"foo"});
        Assert.assertEquals("Hello foo", response);
        Assert.assertEquals(1, mockInterceptor.getCount());
        Object id2 = new Object();
        child.publish(new RequestStart(this, id2));

        // second request
        Object id3 = new Object();
        child.publish(new RequestStart(this, id3));
        ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        handler = (InvocationHandler) ctx.getHandler();
        Assert.assertEquals(1, mockInterceptor.getCount());
        response = handler.invoke(null, hello, new Object[]{"foo"});
View Full Code Here

        child.publish(new ModuleStart(this));

        // first session
        Object session = new Object();
        Object id = new Object();
        child.publish(new RequestStart(this, id));
        child.publish(new HttpSessionBound(this, session));

        EntryPointContext ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        InvocationHandler handler = (InvocationHandler) ctx.getHandler();
        Assert.assertEquals(0, mockInterceptor.getCount());
        Object response = handler.invoke(null, hello, new Object[]{"foo"});
        Assert.assertEquals("Hello foo", response);
        Assert.assertEquals(1, mockInterceptor.getCount());
        child.publish(new RequestEnd(this, id));

        Object id2 = new Object();
        child.publish(new RequestStart(this, id2));
        child.publish(new HttpSessionBound(this, session));
        EntryPointContext ctx2 = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx2);
        response = handler.invoke(null, hello, new Object[]{"foo"});
        Assert.assertEquals("Hello foo", response);
        Assert.assertEquals(2, mockInterceptor.getCount());
        HelloWorldService service1 = (HelloWorldService) child.getContext("target").getInstance(null);
        Assert.assertEquals(2, service1.count());
        child.publish(new RequestEnd(this, id2));
        child.publish(new HttpSessionEnd(this, session));

        // second session
        Object session2 = new Object();
        child.publish(new RequestStart(this, new Object()));
        child.publish(new HttpSessionBound(this, session2));

        ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        Assert.assertEquals(2, mockInterceptor.getCount());
        response = handler.invoke(null, hello, new Object[]{"foo"});
        Assert.assertEquals("Hello foo", response);
        Assert.assertEquals(3, mockInterceptor.getCount());
        child.publish(new HttpSessionBound(this, session2));

        Object id3 = new Object();
        child.publish(new RequestStart(this, id3));
        child.publish(new HttpSessionBound(this, session2));
        ctx2 = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx2);
        response = handler.invoke(null, hello, new Object[]{"foo"});
        Assert.assertEquals("Hello foo", response);
View Full Code Here

        runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
        CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
        child.registerModelObject(MockFactory.createModuleWithEntryPoint(Scope.INSTANCE));
        child.publish(new ModuleStart(this));
        Object id = new Object();
        child.publish(new RequestStart(this, id));
        EntryPointContext ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        InvocationHandler handler = (InvocationHandler) ctx.getHandler();
        Assert.assertEquals(0, mockInterceptor.getCount());
        Object response = handler.invoke(null, hello, new Object[]{"foo"});
        Assert.assertEquals("Hello foo", response);
        Assert.assertEquals(1, mockInterceptor.getCount());
        child.publish(new RequestEnd(this, id));

        // second request
        Object id2 = new Object();
        child.publish(new RequestStart(this, id2));
        ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        handler = (InvocationHandler) ctx.getHandler();
        Assert.assertEquals(1, mockInterceptor.getCount());
        response = handler.invoke(null, hello, new Object[]{"foo"});
View Full Code Here

        runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
        CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
        child.registerModelObject(MockFactory.createModuleWithEntryPoint(Scope.REQUEST));
        child.publish(new ModuleStart(this));
        Object id = new Object();
        child.publish(new RequestStart(this, id));
        EntryPointContext ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        InvocationHandler handler = (InvocationHandler) ctx.getHandler();
        Assert.assertEquals(0, mockInterceptor.getCount());
        Object response = handler.invoke(null, hello, new Object[]{"foo"});
        Assert.assertEquals("Hello foo", response);
        Assert.assertEquals(1, mockInterceptor.getCount());

        ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        handler = (InvocationHandler) ctx.getHandler();
        response = handler.invoke(null, hello, new Object[]{"foo"});
        HelloWorldService service1 = (HelloWorldService) child.getContext("target").getInstance(null);
        Assert.assertEquals(2, service1.count());

        child.publish(new RequestEnd(this, id));

        // second request
        Object id2 = new Object();
        child.publish(new RequestStart(this, id2));
        ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        handler = (InvocationHandler) ctx.getHandler();
        Assert.assertEquals(2, mockInterceptor.getCount());
        response = handler.invoke(null, hello, new Object[]{"foo"});
View Full Code Here

        testCtx.publish(new ModuleStart(this));
       
        // first session
        Object session = new Object();
        Object id = new Object();
        testCtx.publish(new RequestStart(this,id));
        testCtx.publish(new HttpSessionBound(this,session));
        GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
        Assert.assertNotNull(source);
        GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
        Assert.assertNotNull(target);
        source.getGenericComponent().setString("foo");
        Assert.assertEquals("foo",target.getString());
        testCtx.publish(new RequestEnd(this,id));
       
        //second session
        Object session2 = new Object();
        Object id2 = new Object();
        testCtx.publish(new RequestStart(this,id2));
        testCtx.publish(new HttpSessionBound(this,session2));
        GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
        Assert.assertNotNull(target2);
        Assert.assertTrue(!"foo".equals(target2.getString()));
       
View Full Code Here

        testCtx.registerModelObject(MockFactory.createModule(Scope.MODULE,Scope.REQUEST));
        testCtx.publish(new ModuleStart(this));
       
        // first request
        Object id = new Object();
        testCtx.publish(new RequestStart(this,id));
        GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
        Assert.assertNotNull(source);
        GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
        Assert.assertNotNull(target);
        source.getGenericComponent().setString("foo");
        Assert.assertEquals("foo",target.getString());
        testCtx.publish(new RequestEnd(this,id));
       
        //second request
        Object id2 = new Object();
        testCtx.publish(new RequestStart(this,id2));
        GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
        Assert.assertNotNull(target2);
        Assert.assertTrue(!"foo".equals(target2.getString()));
       
        Assert.assertTrue(!"foo".equals(source.getGenericComponent().getString()));
View Full Code Here

TOP

Related Classes of org.apache.tuscany.core.context.event.RequestStart

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.