Some business applications require to automatically instantiate and execute business logic during the initialization of the container. Almost all leading J2EE containers (Weblogic, OC4J, Websphere, JBoss) provide facilities for Application Code (Java classes) to be executed when J2EE container starts up or shuts down and these are popularly known as Startup/Shutdown classes. In the startup class you can initialize environment constants, services, and make calls to other classes.
The greatest problem is that all these vendors implement this feature their own way and there is no standard. Customers attempting to migrate their applications that depend upon startup/shutdown functionality may have to modify their application to use vendor specific APIs.
BEA Calls these as Startup/Shutdown classes. Oracle also refers these as Startup/Shutdown classes. IBM calls these as Custom Service. JBoss also calls this as Startup classes. But looking at these examples it is apparent that if someone uses this feature in his application source code change is obvious during migration to another container and that defeats the sole spirit of Java/J2EE "Write once, run any where!"
One of our partners showed their displeasure for not having a standard when they migrated their applications to OC4J. Another ISV showed their discomfort for having to maintain separate code for the J2EE containers they support.
This raises the big question "Why startup/shutdown classes are not part of standard?" if this is really useful for J2EE customers. In my opinion the J2EE 1.5 expert committee should look at this requirement and try to standardize this as a part of J2EE for enabling organizations to give them real application portability.
Vinny Carpenter provided a J2EE standard way as documented in his blog. I forgot to mention that we suggested this types of approaches to our customers to use that's portable e.g. using as an application client that executes automatically, using ServletContextListener. But this does not some satisfy requirements for some customers and ISVs and they want this code to be executed prior to startup of any applications.