This might be more suited to the Threads forum, but we'll start here. It involves a context listener, a web service, and threads, so it qualifies for about 3 different forums.
I've been working on getting weather forecast feeds from the National Weather Service. I've created this context listener:
This is the WeatherFetcher class:
There is another class that populates the beans (ForecastProcessor) and a
jsp page, but those are unimportant for now. I don't know if I followed Best Practices for this app as it's my first ever attempt at using web services, but it works. Suggestions on a better design are welcome.
But the challenge I'm facing now is how to get this to update once an hour. I've been reading
Java Threads, chapter 11, but it's not helping. Unfortunately, this book is heavily geared toward Swing apps which doesn't translate well to
JEE. If I understand it correctly, to use the ScheduledThreadPoolExecutor class, I would need to make the WeatherFetcher class implement the Runnable interface, but that means the code has to be moved to the run() method where I can't get the Map that is currently returned.
What's the suggested way to set up something like this to run on a continuous timer loop? And if you tell me my architecture is all wrong and I need to rip the guts out of it and start over, that's okay. This is a learning experience. Just point me in the right direction, please.