[jboss-user] [JBoss Seam] - how best to workaround lack of ServletContext at Startup

charles.crouch@jboss.com do-not-reply at jboss.com
Mon Mar 19 18:58:50 EDT 2007


So I just wanted to get suggestions for how I can workaround not having access to the ServletContext during the phase when components tagged with @Startup and @Application get created.

Here's my use case:
I've got a component,which needs some one-off, time consuming initialization to be run before it can be used. The component is currently a static singleton. 
In order to initialize the component I need to grab a resource using ServletContext.getResource(..). This resource is not available on the classpath. 

I'm currently using a servlet to do the initialization and making sure it runs early by putting <load-on-startup>1</load-on-startup> in the web.xml

This all works however I would like to move away from using the static singleton approach and have the singleton component injected into my other Seam components which need it.

The approach I've seen discussed before of just removing the @Startup annotation and have the component created lazily won't work here, since I don't want the first request being held up by the time consuming initialization that the component requires.

Any other ideas?

Cheers


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4029540#4029540

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4029540



More information about the jboss-user mailing list