You don't--but if you don't, the compiler will insert one for you. There
must always be at least one constructor, of any form, defined on a given
class. The compiler synthesizes the default constructor if you don't specify
one.
Ted Neward
{.NET || Java} Course Author & Instructor, DevelopMentor
(http://www.develop.com)
http://www.javageeks.com/tneward
http://www.clrgeeks.com/tneward
----- Original Message -----
From: "Louis Florit" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, March 16, 2002 9:15 AM
Subject: Re: [EJB-INT] How can we exploit constructors in E-Beans
> I checked the spec after this and an email from Sven. What I am doing is
> NOT allowed by the EJB spec, so please disregard my comments.
>
> Another case of 'it worked in this instance' vs. what you're supposed to
> be doing. If i had taken my code to another app server there was no
> guarantees it would have worked.
>
> That said, why do we even have to declare an empty constructor at all?
>
> Thanks for the comments.
> Louis
>
>
> On Sat, 16 Mar 2002, Dmitri Colebatch wrote:
>
> > > 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".
>
===========================================================================
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".