users@jersey.java.net

[Jersey] Re: Caching config at startup time

From: Martin Matula <martin.matula_at_oracle.com>
Date: Wed, 09 Mar 2011 11:15:12 +0100

Another option is to create your own subclass of PackagesResourceConfig
(or some other subclass of DefaultResourceConfig depending on whether
you are using package scanning, classpath scanning or something else),
override the init() method to do your initialization and call
super.init(). Or do whatever you need in the constructor.
You need to register your custom ResourceConfig implementation e.g. by
setting the servlet init parameter named
com.sun.jersey.config.property.resourceConfigClass (or
javax.ws.rs.Application) to the fully qualified name of your
ResourceConfig implementation class.
Regards,
Martin


On 9.3.2011 10:07, Casper Bang wrote:
> Hi Arthur,
>
> You can implement a custom ServletContextListener and register it in
> your web.xml. I use the ServletContextListener to place a DataSource
> in a ServletContext, but I see no reason for why you couldn't use it
> to start pre-fetching some data:
>
> <listener>
> <listener-class>com.brunata.webmon.ws.db.DBPoolingListener</listener-class>
> </listener>
>
>
> /Casper
>
> On Tue, Mar 8, 2011 at 10:35 PM, Arthur Yeo <artyyeo_at_gmail.com
> <mailto:artyyeo_at_gmail.com>> wrote:
>
> All,
>
> Since RESTful services are event-driven (or request-driven),
> what's the best practices to cache a bunch of static data (mainly
> configs stuffs) from the Db when my GF webapp initially starts
> up? How do you kick off something with no external events driving it?
>
> --
> Arthur Y.
>
>