Ron,

I agree none of these really destroy every use of a singleton.  They just
ruin the good uses of one :)

For instance, yes you could use a singleton pattern to store static final
variables, but, why not then just place these in a super class?  Or in
another beans private members to be gotten over an interbean call.  These
are much more portable solutions.  If the member is really final, why does
it need to be then static.  Most ppl's uses of final static members are
although to the letter of the spec, they are not to the spirit of the spec.

For instance, I see this alot

public static final Map _cache;

Now, yes, the spec says you can use static final members, but, they didnt
intend for you to then add/remove objects from this member as you could with
a Map.   These limits are here to increase the likely hood your code will be
portable across many different app servers.  If this isnt an issue, knock
yourself out.  But then it begs the question why the heck yer writing ejb's
anyways.

Dave Wolf
Internet Applications Division
Sybase


> -----Original Message-----
> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED]]On Behalf Of Ron Yust
> Sent: Tuesday, September 26, 2000 2:28 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Using singleton from EJBs (not implementing singleton with
> EJB!)
>
>
> Irregardless, if a singleton by design can exist in its own
> "space" whether
> it's a container, JVM, or classloader, then what is the problem?
> A blanket
> statement that a singleton pattern can't be used at all seems overly
> simplistic and doesn't account for the myriad ways a singleton
> can be used.
>
> Why couldn't I have a singleton with only final static variables
> in it that
> I want to share with other Java objects in the same "space"?
>
> > >
> > > >
> > > > A singleton pattern will not be very portable.  Even if the
> > > static member
> > > > were portable which it is not, the use of custom
> ClassLoaders by most
> > > > containers will likely cause issues with your pattern.
> > > >
> > >
> > > It seems it would not be portable only if you want a singleton for all
> > > containers in cluster.  But a singleton seems very portable and
> > applicable
> > > in situations where you want a singleton object per container
> and do not
> > > need to share that singleton between multiple containers.
> >
> > Not necesarilly.  Its of course not a singleton across
> containers, but it
> > may not even be a singleton within the same container.
> >
> > 1) The container may use multiple VM's
> > 2) More common, the container may use a custom ClassLoader to load the
> > classes in order to support features like hot swapping.  If so, the
> > singleton will only be unqique across a ClassLoader.  Or, a more comman
> > issue would be as per the J2EE spec, each web app must have its own
> > ClassLoader.  Meaning the singleton is only truly a singleton within the
> > single web application.
> >
> > Dave Wolf
> > Internet Applications Division
> > Sybase
> >
> >
> >
> >
> > >
> > > ==================================================================
> > > =========
> > > 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".
> >
> >
>
> ==================================================================
> =========
> 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".

Reply via email to