The following section describes the runtime flow of the startup beans upon
several occasions.
As shown in the diagram above, an application startup with the startup
beans consists of the following steps:
- The startup service of WebSphere® Application Server loads the application's
EAR file.
- The startup service then searches for all the startup beans according
to the home interface.
- The application server checks the wasStartupPriority of each
startup bean. If the startup bean does not have a defined wasStartupPriority,
the value of the priority is set to 0, which represents the lowest priority.
If the startup bean has a defined wasStartupPriority of a
wrong type, the startup service cancels the application startup.
- The startup service sorts the startup beans according to their priority
defined in wasStartupPriority and takes the bean of the highest
priority from the queue.
- The startup service checks the startup bean's transactional properties
on start() and stop() methods. If the start() method and stop() method do
not contain a TX_MANDATORY attribute, the startup continues; otherwise
the startup service cancels the application startup.
- The startup service finds the actual startup bean using JNDI and runs
its start() method. If the startup service finds the bean correctly and the
start() method of the bean returns true, the startup service stores the bean
handle and proceeds to the next startup bean in the ordered queue.
- After the startup service loads all the startup beans successfully, the
application server starts the application and its JMS, IIOP, and HTTP listeners.
The startup service does not start the application until the start() method
of all startup beans are successfully executed. If a startup bean's
start() method triggers a demanding task, the startup of the application may
take a long time. On these occasions you can use asynchronous beans to finish
the start() methods of the startup beans as soon as possible. For information
about asynchronous beans, see the product documentation of WebSphere Application
Server or WebSphere Process
Server.
An application stop consists of the following steps:
- The EJB container stops serving the requests.
- The startup service loads the startup beans in the opposite order of the
application startup.
- The startup service runs the stop() method of the startup bean. Any exception
thrown at this stage is logged but ignored.
- The startup service continues with the next startup bean in the queue
until all the beans are loaded.
- After the startup service loads all the startup beans, it shuts down the
application and the listeners.