Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Invoking Service during application start up  RSS feed

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

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

Your help is much appreciated.
 
Bartender
Posts: 9559
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
No holds barred. And no bars holed. Except this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!