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

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


        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);
            //FIXME throw a better exception
View Full Code Here


            // Handle a request
            if (request instanceof HttpServletRequest) {
                if (((HttpServletRequest) request).getSession(false) != null) {

                    // A session is already active
                    moduleContext.publish(new HttpSessionBound(this, ((HttpServletRequest) request).getSession(true)));
                } else {
                    // Create a lazy wrapper since a session is not yet active
                    moduleContext.publish(new HttpSessionBound(this, new LazyHTTPSessionId((HttpServletRequest) request)));
                }
            } 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);
View Full Code Here

                Object requestId = new Object();

                HttpSession session = request.getSession(false);
                if (session != null) {
                    // A session is already active
                    moduleComponentContext .publish(new HttpSessionBound(this,session));
                } else {
                    // 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) {
View Full Code Here

        // 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);
        Assert.assertEquals(4, mockInterceptor.getCount());
        HelloWorldService service2 = (HelloWorldService) child.getContext("target").getInstance(null);
        Assert.assertEquals(2, service2.count());
        Assert.assertEquals(2, service1.count()); //ensure sessions not crossed
        child.publish(new RequestEnd(this, session2));
        child.publish(new HttpSessionBound(this, session2));

        child.publish(new ModuleStop(this));
        runtime.stop();
    }
View Full Code Here

       
        // 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()));
       
        Assert.assertTrue(!"foo".equals(source.getGenericComponent().getString()));
View Full Code Here

       
        // 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");
        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 source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
        Assert.assertNotNull(source2);
        GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);

        Assert.assertNotNull(target2);
View Full Code Here

       
        // 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");
        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 source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
        Assert.assertNotNull(source2);
        GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);

        Assert.assertNotNull(target2);
View Full Code Here

       
        // 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,session));

        //second session
        Object session2 = new Object();
        Object id2 = new Object();
        testCtx.publish(new RequestStart(this,id2));
        testCtx.publish(new HttpSessionBound(this,session2));
        GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
        Assert.assertNotNull(source);
        GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);

        Assert.assertNotNull(target2);
View Full Code Here

       
        // 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(null,target.getString());
        testCtx.publish(new RequestEnd(this,session));

        //second session
        Object session2 = new Object();
        Object id2 = new Object();
        testCtx.publish(new RequestStart(this,id2));
        testCtx.publish(new HttpSessionBound(this,session2));
        GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
        Assert.assertNotNull(source);
        GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);

        Assert.assertNotNull(target2);
View Full Code Here

       
        // 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,new Object()));

        //second request for session
        Object id2 = new Object();
        testCtx.publish(new RequestStart(this,id2));
        testCtx.publish(new HttpSessionBound(this,session));
        GenericComponent targetR2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
        Assert.assertEquals("foo",targetR2.getString());
        GenericComponent sourceR2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
        Assert.assertNotNull(sourceR2);
        Assert.assertEquals("foo",sourceR2.getGenericComponent().getString());
       
        testCtx.publish(new RequestEnd(this,new Object()));

        //second session
        Object session2 = new Object();
        Object id3 = new Object();
        testCtx.publish(new RequestStart(this,id3));
        testCtx.publish(new HttpSessionBound(this,session2));
        GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
        Assert.assertNotNull(source2);
        GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);

        Assert.assertNotNull(target2);
        Assert.assertEquals(null,target2.getString());
        Assert.assertEquals(null,source2.getGenericComponent().getString());
        source2.getGenericComponent().setString("baz");
        Assert.assertEquals("baz",source2.getGenericComponent().getString());
        Assert.assertEquals("baz",target2.getString());
       
        testCtx.publish(new RequestEnd(this,session2));
        Object id4 = new Object();
        testCtx.publish(new RequestStart(this,id4));
        testCtx.publish(new HttpSessionBound(this,session));
        testCtx.publish(new RequestEnd(this,session));

    }
View Full Code Here

TOP

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

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.