| Is there some way in which initialization code can be executed when the container starts up--but before it starts serving clients? |
|
The motivation for wanting to do something like this is to call some initialization session bean manually or initializing a framework, etc. which needs to happen before clients start hitting the server. Unfortunately, there is no simple way to insert a framework into the Container between the time that the EJBs are initialized and the time that the first client request comes in. Basically, as soon as the JNDI name is registered, the beans are "public". You can insert code before the EJBs are initialized and you can insert code afterward, but you cannot guarantee that the insertion happens before a client request comes in. In summary, here are the points where you can insert your code:
main() {
// insert code here
"start the container and any services, but no beans"
// insert code here
"add a Jar file of EJBs"
// insert code here
"add another Jar file of EJBs"
// etc.
}
|