Except that a stateful session bean belongs to the client that instantiated
it, and cannot be shared between clients (or at least that behaviour is not
portable)...
Jeff 8-)
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of [EMAIL PROTECTED]
Sent: Wednesday, April 26, 2000 1:22 PM
To: Jim Archer
Cc: EJBoss
Subject: Re: creating a resource that sticks around in the server?
Singleton means that you only have one instance in your application of a
particular class. In this case the Stateful Session bean is the singleton
because you only want one instance, right? So to get a reference to the
bean, you call SingletonManager.getInstance() instead of calling
BeanHome.create().
public class BeanManager {
static Bean theBean = null;
static public Bean getInstance() {
if (theBean==null) {
// lookup BeanHome
// beanhome = .....
theBean = beanhome.create();
}
return theBean;
}
}
Every client that calls getInstance() gets the same session bean
reference.
On Wed, 26 Apr 2000, Jim Archer wrote:
> Hi Greg...
>
> This is about what I want to do, but I guess I have to admit that I don't
> know what a singleton bean is.
>
> Is that an EJB term or a Java term? Other than EJB beans, I am only
> familliar with Beans that plug into a visual building environment, so I'm
a
> bit confused...
>
> Thanks!
>
> Jim
>
>
>
> --On Wednesday, April 26, 2000 3:27 PM -0400 [EMAIL PROTECTED] wrote:
>
> > I may be smoking crack, but would it be possible to create a statefull
> > session bean and make the reference or handle a singleton? This way all
> > clients share the same reference. This would work in a cluster also
> > because each node could get the reference from the same place.
> >
> > Greg
> >
> > On Wed, 26 Apr 2000, Jim Archer wrote:
> >
> >>
> >> Hi All...
> >>
> >> I have a design problem I hope someone woulden't mind helping me
with...
> >>
> >> I need to create a data structure inside an EJB server that will hang
> >> around and be used by other beans, but dosent belong to any particular
> >> client and dosen't persist to a database...
> >>
> >> I can't use a stateless session bean, since they come and go. I can't
> >> use a statefull session bean, since thats an extension of a particular
> >> client, and I'm not sure if this can be done with an entity bean,
since
> >> there really is no data to persist. I'm not sure if its an entity bean
> >> how other beans would get a reference to a particular instance of it
(I
> >> only want there to ever be one instance).
> >>
> >> We have discussed having it live outside the server, but then beans
> >> inside the server have to use RMI to call it and JNDI to locate it and
> >> that just seems like a poor solution to me...
> >>
> >> I would greatly appreciate any suggestions or ststements as to why I
> >> don't know what I'm talking about <Grin>
> >>
> >> Thanks!
> >>
> >> Jim
> >>
> >>
> >>
> >>
> >> --
> >> --------------------------------------------------------------
> >> To subscribe: [EMAIL PROTECTED]
> >> To unsubscribe: [EMAIL PROTECTED]
> >> Problems?: [EMAIL PROTECTED]
> >>
> >>
> >
> >
> >
> > --
> > --------------------------------------------------------------
> > To subscribe: [EMAIL PROTECTED]
> > To unsubscribe: [EMAIL PROTECTED]
> > Problems?: [EMAIL PROTECTED]
>
>
>
>
>
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]