users@glassfish.java.net

Is there a way to automatically instantiate a bean at startup?

From: <glassfish_at_javadesktop.org>
Date: Sun, 08 Mar 2009 11:23:58 PDT

I've spent a number of hours searching this forum and google for an answer to this question (in the title), but so far while I've seen a lot of references to it I've not found a good answer.

It also seems that this is a popular question.

All I want to do is to create a bean that will periodically ping mysql to see if there are any new records in a mail table, and if those records exist to send some emails. I'm using Glassfish for the rest of my app and so it makes sense to me that I would want to use it for this function too. I don't want a web interface or anything like that.

I've looked at the ServletContextListener but from what I can see it requires a bean to be instantiated. So far I've not been able to figure out how to automatically instantiate a bean when Glassfish starts up.

Am I missing something obvious here?

Thanks,

Eric
[Message sent by forum member 'eric_marsh' (eric_marsh)]

http://forums.java.net/jive/thread.jspa?messageID=335746