I have a non-EJB helper class that takes about 5-10 seconds to initialize and then lives until the container is shut down. It is only used from within EJB and is thus packaged in the ejb .jar.
Basically there are two questions:
1) is there a preferred way to model a Singleton object (exists only once per ejb .jar), which lives for the complete duration from container startup til shutdown?
2) My current approach is to create a POJO Singelton, and do all initialization in the constructor. How can I tell the container to load it on startup?
I have the same problem:
I want to initialize a connection to a DB at startup, and close it when the container shuts down.
I need to do it programmatically, thus I can't specify it in the xml descriptors.
How should I do this?