cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cypher !" <>
Subject RE: accessing cayenne sessions
Date Tue, 04 Apr 2006 22:41:43 GMT
Or is this a better method, using the Listener in Servlet 2.4 rather than 
the filter in Servlet 2.3


Sample DataContext retrieval code:

import org.objectstyle.cayenne.access.DataContext;
// get session DataContext bound to the current request thread
DataContext context = DataContext.getThreadDataContext();

What are the advantages.

From: "Cypher her" <>
Subject: RE: accessing cayenne sessions
Date: Tue, 04 Apr 2006 22:36:53 +0000


I am using Tapestry 4, Java 1.5, JBoss 4 and Cayenne 1.2.

So if I undrstand you correctly I can create a subclass of BasePage which 
will have a getSession() method. But in that page, to get the session I 
would need to use the WebApplicationContextFilter and do something like

add his to my web.xml


and create a class like this

import org.objectstyle.cayenne.access.DataContext;

public class MyBasePage extends BasePage

    public DataContext getDataContext()
        return DataContext.getThreadDataContext();

and all of  my pages should subclass MyBasePage. And I am assuming Tapestry 
and the servlet container will take care of making sure the Session is 
consistent throughout the workflow i.e. each user gets a unique DataContext 
and they maintain the same DataContext from page to page until the session 
times out..

Thanks again for your help.


From: "Gentry, Michael (Contractor)" <>
To: <>
Subject: RE: accessing cayenne sessions
Date: Tue, 4 Apr 2006 10:45:29 -0400

Yes, but using Tapestry you can have a common superclass for your pages
that provides a getSession() method and it works transparently.  You
don't need to think about Http*.


-----Original Message-----
From: Mike Kienenberger []
Sent: Tuesday, April 04, 2006 10:26 AM
Subject: Re: accessing cayenne sessions

On 4/4/06, Cyp her <> wrote:
 > * Are there any convenient methods for accessing the Session like in
 > WebObjects where there is a session class in the application?

In servlets, there's an HttpSession object that you can pull out of
the HttpServletRequest.   Instead of being a subclassable object, it
instead holds references to a Map (think NSDictionary) where you can
store objects the entire session.  How you get a reference to your
HttpSession object depends on the framework.

Be the first to hear what's new at MSN - sign up to our free newsletters!

The new MSN Search Toolbar now includes Desktop search!

View raw message