This week's book giveaway is in the NodeJS forum. We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line! See this thread for details.
In my current application, I'm calling a remote stored proc to get data that is stored in servlet context. My requirement is to call a WS instead of a stored proc to get the same data and store in the context. However, this call is happening during application start up. The service is ssl protected and the certificates are available only after JVM load. With my current design the call fails as the certs are not available.
Currently I'm calling the init class as a plugin in the struts-config. If I want to make the application initialization after JVM load, how to do that in struts? FYI.. the app is using struts 1.0
Are your application and web service deployed in the same container? Perhaps it is time to reconsider your deployment strategy. A web service should "always" be available (at least in the eyes of its dependencies).
I don't think Struts has any features that one could use to implement the desired function. However, Struts is built on top of the Java Servlet Specification, so one could use the functionality found in that API. It provides classes to listen for servlet lifecycle events, but unfortunately, the ServletContextListener will only get called when a servlet context initialization begins. There is no way that I can see to be informed when the initialization process is complete.
One could use a ServletContextListener to create an executor to schedule a task to read from the web service. This is not an ideal solution because you would need to figure out a reasonable delay for the web service to come up, but your delay cannot be so long that a user would be able to access the application before it is initialized.
Another way one could use servlet lifecycle events is to create a HttpSessionListener which would be activated when someone logs in. Of course, you'd only want to know about the first login to initialize the application.
Another option would be to use lazy initialization. The first time someone accesses a feature in your application that requires the data from the web service, it would be fetched from the web service and cached.