Re: accessing cayenne sessions

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Apr 05 2006 - 04:03:36 EDT

  • Next message: Andrea Borgogelli Avveduti: "Re: It's a long night.."

    In this case listener and filter do essentially the same thing, only
    using different hooks provided by servlet container. In fact we are
    planning to cut down on this redundancy, keeping the filter and
    deprecating the listener:

    http://objectstyle.org/cayenne/lists/cayenne-devel/2006/04/0001.html

    Andrus

    On Apr 5, 2006, at 2:41 AM, Cypher ! wrote:
    > Or is this a better method, using the Listener in Servlet 2.4
    > rather than the filter in Servlet 2.3
    >
    > <listener>
    > <listener-
    > class>org.objectstyle.cayenne.conf.WebApplicationContextProvider</
    > listener-class>
    > </listener>
    >
    > 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" <cypher6..otmail.com>
    > Reply-To: cayenne-use..ncubator.apache.org
    > To: cayenne-use..ncubator.apache.org
    > Subject: RE: accessing cayenne sessions
    > Date: Tue, 04 Apr 2006 22:36:53 +0000
    >
    > Hi
    >
    > 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
    >
    > <filter>
    > <filter-name>CayenneFilter</filter-name>
    > <filter-
    > class>org.objectstyle.cayenne.conf.WebApplicationContextFilter</
    > filter-class>
    > </filter>
    > ...
    > <filter-mapping>
    > <filter-name>CayenneFilter</filter-name>
    > <url-pattern>/*</url-pattern>
    > </filter-mapping>
    >
    > 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.
    >
    > Lawrence
    >
    >
    > From: "Gentry, Michael (Contractor)" <michael_gentr..anniemae.com>
    > Reply-To: cayenne-use..ncubator.apache.org
    > To: <cayenne-use..ncubator.apache.org>
    > 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*.
    >
    > /dev/mrg
    >
    >
    > -----Original Message-----
    > From: Mike Kienenberger [mailto:mkienen..mail.com]
    > Sent: Tuesday, April 04, 2006 10:26 AM
    > To: cayenne-use..ncubator.apache.org
    > Subject: Re: accessing cayenne sessions
    >
    >
    > On 4/4/06, Cyp her <cypher6..otmail.com> 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.
    >
    > http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/http/
    > Http
    > Session.html
    >
    > _________________________________________________________________
    > Be the first to hear what's new at MSN - sign up to our free
    > newsletters! http://www.msn.co.uk/newsletters
    >
    > _________________________________________________________________
    > The new MSN Search Toolbar now includes Desktop search! http://
    > join.msn.com/toolbar/overview
    >
    >



    This archive was generated by hypermail 2.0.0 : Wed Apr 05 2006 - 04:04:10 EDT