-
1. Re: Is there something like a InitEJB ?
raja05 Apr 15, 2003 12:38 PM (in response to mafentakis)You can call a Singleton from your EJB Constructor or setContext. This way, your init is called before EJBs are processed.
We use this in our MDB code when a set of external properties have to be loaded before the MDBs start picking messages.
-Raj -
2. Re: Is there something like a InitEJB ?
frito Apr 16, 2003 4:07 AM (in response to mafentakis)AFAIK, you can't predict when the constructor of an EJB is called wheter the context it is running in (e.g. transactional). And again, a singleton is not a singleton in such an environment.
The proper way to do something like this could be a MBean doing the work and the EJB accessing data from it.
Greetings,
Frito -
3. Re: Is there something like a InitEJB ?
raja05 Apr 16, 2003 9:46 AM (in response to mafentakis)Hi Frito
Im not sure what you mean by saying "you cannot predict when constructor is called".
Doesnt the Constructor get called before its moved to the Pooled state?
SEction 10.5.1 of EJB Spec requires that a newInstance and setContext be called before moving it from "Does not Exist" state to "Pooled" state/
Thanks
Raj -
4. Re: Is there something like a InitEJB ?
mafentakis Apr 16, 2003 10:09 AM (in response to mafentakis)Hi,
the method setXXSessionContext is called before EJB invokation, but I want to execute a method everytime the ear-application is redeployed ...
I'm trying the MBEAN way...
anyway thanks...
Manolis -
5. Re: Is there something like a InitEJB ?
frito Apr 17, 2003 3:01 AM (in response to mafentakis)Hi raja,
this is true for entity beans. But what are you going to do, when there is a time consuming job to be done before calling a SLSB? ejbCreate() is not called when create is invoked on the home interface. Instead Class.newInstance(), setSessionContext() and ejbCreate() is called when the first method is called on the remote interface.
I think you can configure the jboss pools for your bean, so at least a minimum number of beans is ready and waiting for some action. But this is JBoss configuration done by the deployer.
Greetings,
Frito