cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <mgen...@masslight.net>
Subject Re: Servlet Filters
Date Thu, 20 Aug 2009 14:40:09 GMT
The main reason I looked at it is I was starting to write a lot of
helper methods in the DataObject subclasses which would create their
own DataContext and do a search and return a result.  Of course, these
live in their own DataContext and I didn't want to have localObject()
calls to set relationships/etc, so I thought putting them in a shared
DataContext would simplify that sharing process.  The easiest thing
for me might be to turn off the "Use Shared Cache" in CM.  This will
be a low-volume application, but it is important to always check the
DB for fresh data in case the configuration changes.

Thanks,

mrg


On Thu, Aug 20, 2009 at 10:27 AM, Andrus Adamchik<andrus@objectstyle.org> wrote:
> My current view of the WebApplicationContextFilter is that it is just an
> example for users on how to bootstrap Cayenne, not *the* only way of doing
> it. Maybe we need to reflect that in the docs.
>
> Modern JEE environment is rather diverse as far as configuration approaches,
> and this is multiplied by the number of Cayenne context creation strategies.
> Some apps would use Spring, some Guice, or web.xml, yet some would want
> sessions scoped contexts vs. request or other scope. So my recommendation is
> to use WebApplicationContextFilter as an template to write your own
> filter/service/whatever, as appropriate.
>
> Andrus
>
>
> On Aug 20, 2009, at 4:52 PM, Michael Gentry wrote:
>
>> I'm starting to use the servlet filter setup
>> (http://cayenne.apache.org/doc/web-applications.html) and got it
>> working, but I'm wondering if there is a way to customize the DC
>> creation that I'm missing.
>>
>> The WebApplicationContextFilter class calls
>> ServletUtil.getSessionContext(session).
>> ServletUtil.getSessionContext() checks for an existing DC with:
>>
>>            if (ctxt == null) {
>>               ctxt = DataContext.createDataContext();
>>
>> Prior to switching to the servlet filter, I was creating my DC using
>> DataContext.createDataContext(false) because I was having caching
>> issues with not getting the freshest data from the DB.  Is there an
>> easy way to get the DC's created with the false parameter as the
>> default?  (Without having a custom build of Cayenne.)
>>
>> Thanks,
>>
>> mrg
>>
>
>

Mime
View raw message