File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts2: Best way to execute application init process ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2: Best way to execute application init process ?" Watch "Struts2: Best way to execute application init process ?" New topic

Struts2: Best way to execute application init process ?

Aaron Wilt
Ranch Hand

Joined: Sep 26, 2001
Posts: 49
Hi, Does anyone have any thoughts on what the best way to ensure an application initialization process starts off when the application loads or is first accessed?

I have the need to create a simple global cache and thread for persisting the cache and I need it to be readily available as early as possible.

The only way I could think to accomplish this would be to implement an interceptor to put in the interceptor stack of every action, and then put a check in there to see if my init process has run, prior to any actions being executed.

This solution seemed inherently crappy. haha... Anyone have a better way of doing this so I don't have to intercept every single action for the life of the app when I only need to run the process the first time?

partha chaudhuri

Joined: Sep 21, 2004
Posts: 27
You can use struts plug-in in struts 1, which load the neccessary file when server starts up.

But i don't know how to load some cache in struts2 while server starts up, as in struts2 plug-in class has been removed.
Can anybody help me.
Thanks in advanced.
I agree. Here's the link:
subject: Struts2: Best way to execute application init process ?
Similar Threads
Interceptors in Struts 2
where and who should create site-global stuff like navigatonal menu?
Query rgd interceptor invocation order
Struts 2 - Interceptor V/S Action for checking login...
Need Help about Interceptors in Struts2