Kevin, the more dangerous issue isn't when your static initializer fires,
but if it could fire more than once simultaneously--I wrote a paper on this
topic, "When is a static not a static?", at
http://www.javageeks.com/Papers/JavaStatics/index.html. The danger is that
if the server maintains logical separation of loaded classes (which almost
all servers support, to provide transparent versioning of EJBs without
taking the server down), then you could have multiple copies of your
Singleton running around simultaneously.
Ted Neward
{.NET||Java} Instructor, DevelopMentor (http://www.develop.com)
http://www.javageeks.com/~tneward/index.html
> -----Original Message-----
> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED]]On Behalf Of Kevin Mukhar
> Sent: Friday, June 08, 2001 12:38 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [EJB-INT] A question about singleton
>
>
> > Kov�cs P�ter wrote:
> >
> > I like your solution, but I am always uneasy about using
> > static initalizers
> > when my component sits on top of a more or less complex
> > system.
>
> After my previous reply, I did realize that there is one drawback
> to what I am
> doing. If my static initializer just initialized a variable to
> some literal
> value, there would be no problem. However, in my EJB, I am initializing a
> static variable based on the results of making a remote call to
> another server
> (an LDAP server). If the server is down, then my EJB is not properly
> initialized. My bean is a little more complex because it needs
> logic to deal
> with this situation. However, this is a conscious tradeoff that I chose to
> accept: I minimized the number of calls to the server for data that is
> essentially constant at the cost of a more complex EJB.
>
> ==================================================================
> =========
> 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".