> I am using the constructor in my entity beans to carry out tasks that are > relevant to the setup of how the entity will interact with its > environment; things like looking up the DataSource, finding the home > interfaces for dependant entities, and such. Plumbing work, really. > There are probably other places to put these things, as well. Suggestions > welcome.
These things should go in the appropriate lifecycle method - such as ejbCreate() for a SLSB. > You should not put specific tasks that are part of the lifecycle of an > entity in its constructor, as there is no guarantee that the constructor > will be called at any time other than its instanciation (because of > instace pooling, you don't know if you're getting a new bean or a > previously used one). So I have to agree with Dmitri, see if its really a > entity task or bean management task and determine from there. more importantly, there is no guarentee that the resources which you are trying to locate are available at the time the contructor is called. I would _strongly_ recommend that all resource location take place in defined lifecycle methods. I may have sounded like I supported the use of constructors in EJB - I do not. I think they should not even exist in the EJB. cheers dim > > Louis > > > On Fri, 15 Mar 2002, Dmitri Colebatch wrote: > > > you might be able to, depending on the resources you have in mind. > > what you should (tm) be doing, is say in a stateless session bean, put > > the "constructor code" in ejbCreate() instead. > > > > hth > > dim > > ----- Original Message ----- > > From: Suhel Ahmed > > Subject: How can we exploit constructors in E-Beans > > > > > > So guys ,can i use beans default constructor to initialize my bean > > with some data or resources. in this case what are the limitations i > > have to keep in mind by which every thin will go smooth,. any comments > > or suggestions > -Suhel > =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
