You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by MG...@escholar.com on 2010/04/30 18:07:22 UTC

servlet filter and the Configuration

Okay,

        So I think I've made some progress since my question yesterday.  I 
have a bean in Spring that is a ConfigurationFactory.  It returns a 
singleton and the dataSource can be obtained from that.  Now I just need 
to get that configuration loaded on web startup.  I guess I need to write 
a filter because all the filters (the one in cayenne and the click 
project) create a new shared configuration on init with ServletUtil.  I 
guess I want to override those init()'s and get a reference to my bean and 
call initialize() on it directly.  Is that correct?  When I do this will 
that Configuration become the shared configuration?  If not how do I make 
it the shared configuration? Any other gotchas I should be aware of when 
doing this by hand?

Thanks.
-Mike


Re: servlet filter and the Configuration

Posted by Andrus Adamchik <an...@objectstyle.org>.
On May 1, 2010, at 12:07 AM, MGargano@escholar.com wrote:

> Okay,
>
>        So I think I've made some progress since my question  
> yesterday.  I
> have a bean in Spring that is a ConfigurationFactory.  It returns a
> singleton and the dataSource can be obtained from that.  Now I just  
> need
> to get that configuration loaded on web startup.  I guess I need to  
> write
> a filter because all the filters (the one in cayenne and the click
> project) create a new shared configuration on init with  
> ServletUtil.  I
> guess I want to override those init()'s and get a reference to my  
> bean and
> call initialize() on it directly.  Is that correct?

Sounds about right.

> When I do this will that Configuration become the shared  
> configuration?  If not how do I make
> it the shared configuration?

It does as long as either of the following is called either in your  
Filter or your Spring factory for Configuration:

Configuration.initializeSharedConfiguration(conf);

or

ServletUtil.initializeSharedConfiguration(context);

Andrus