openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Wilson" <>
Subject RE: session creation
Date Sat, 21 Feb 2009 16:03:07 GMT
Hi Gurkan,
Thanks for quick and helpful responses. It sounds great that you will look
into not forcing sessions - thanks! Hopefully it will not become too
complicated to set up the session context on demand once it is needed. I
pinged the JSR Expert Group about this as well, and it will be interesting
to see what/if they respond.
Regarding conversation context being tied to JSF; I had a quick look at the
spec and the conversation mechanism described there doesn't seem to
hard-wire against JSF. If I understand it correctly it goes roughly like


	if the current incoming request isn't specifying a conversation id,
a new temporary conversation context is created

	this temporary conversation context "dies" with the request if not
promoted to "long-running" (and thus in practive just acts like a parallel
request context)

	if Conversation.begin() is called the conversation is promoted to
long-running, and it is registered with an id on the session (this would
also be a place to forcibly create the session)

	the conversation id is transferred to the browser by f ex
redirecting to a url that contains it as a parameter so the browser will ask
for the same conversation on subsequent requests

Points (2) and (3) have no dependency to any specific web framework, and
point (1) and (4) has specification text that says they will be taken care
of automatically if using JSF, but should be possible to handle
programatically if using another web framework.

Ideally, this would mean that all bundled contexts could actually live in
"openwebbeans-core" (talking in modularization terms again) and only the
automagic stuff in point (1) and (4) would be implemented in
"openwebbeans-jsf" (and the same goes for other web framework-specific
Best regards


From: Gurkan Erdogdu [] 
Sent: den 21 februari 2009 16:15
Subject: Re: session creation

Hi Mike,

Thanks for commenting. In the specification there are some parts that are
hardly depend on the other specification, for example : Conversation Scope
--> JSF, EntityManagers --> JPA, Session Beans --> EJB. As Mark stated, we
have been thinking and  working on the code base to divide it into the
multi-modular structure, but  it takes time.

As coming to session question, actually I use the *initSessionContext*
method in *initRequestContext* method to reconstruct the thread local ve
session scope and application scope. I am going to refactor this not to use
request.getSession(), instead use request.getSession(false);

And we are always looking for the contributions :)

Thanks again;



From: Mike Wilson <>
Sent: Saturday, February 21, 2009 11:49:26 AM
Subject: RE: session creation

Hi Gurkan,
If I understand it correctly, WebBeans is supposed to be useful for other
web frameworks than JSF. Or are you saying that the default WB context
support is hard-wired to JSF, and other web frameworks should implement
their own support for this through lower-level APIs in WB?
It would certainly be useful if the ready-made contexts were built to allow
for as much reuse as possible. Always forcing session creation makes it
harder to reuse this code for stateless scenarios.
Just discussing hypothetically; is there anything in the WB model that
actually requires this "early" session creation, or could it in theory be
deferred to when a request is referring to a bean on session or conversation
Best regards


From: Gurkan Erdogdu [] 
Sent: den 20 februari 2009 16:03
Subject: Re: session creation


Actually this may not be a problem. Indeed, contexts is related with JSF
semantics and session is created everytime in JSF.




From: Mike Wilson <>
Sent: Thursday, February 19, 2009 7:21:56 PM
Subject: session creation

I got things running with Jetty 6.1.15rc4 and now I have a question
about session creation:

Will OpenWebBeans always force a session to be created? In the 
current codebase (see below) this seems to be the case. If 
possible, it would be nice if sessions only were created on-demand
when a component needs session (or conversation) storage.
Doing it this way would make it possible to have stateless requests
that avoid the overhead of session creation when possible.

    public static void initRequestContext(HttpServletRequest request)
        requestContext.set(new RequestContext());// set thread local

        if (request != null)
            HttpSession session = request.getSession();


Best regards
Mike Wilson

View raw message