>-----Original Message-----
>From: Charlie Alfred [mailto:[EMAIL PROTECTED]]
>Sent: February 13, 2000 3:03
>To: [EMAIL PROTECTED]
>Subject: Re: Singleton EJB's?


>Since you're trying to manage in-memory state without the help
>of a DBMS, I don't think you can use EJB's directly to maintain
>this state.  You'd have to find some way to preserve your state
>when the server passivated your bean, and reactivated it later.
>
>Here's the approach I'd be inclined to try:
>
>   1.  Implement your singleton as a vanilla Java class with a static
>        accessor function that returns a reference to the singleton
>        instance, constructing it if necessary.

This approach would fail if the singleton contained mutable data/objects in
a multi JVM (clustered)
environment. Oh course this would not be an issue if the singleton was
immutable.

An alternative to  considered is implementing a singleton as a thread safe
object
and store it in a JNDI space, this would then cover you when accessing the
object
in a distributed environment.


Regards

Rob Masters

>
>   2.  Implement the public API to the singleton using a Stateless
>         Session bean.  At the start of each method implementation, call
>         the static accessor to get a reference to the singleton, then
>         delegate the call to the appropriate method of that object.
> -----Original Message-----
> From: Robert Claeson [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 11, 2000 7:26 PM
> Subject: Singleton EJB's?
>
>
> I've yet to come up with a good solution on this one myself, so I'm
turning
> it over to you now: what would be the best approach to implement the
> equivialent of a singleton EJB - i.e. one that contains shared data for
all
> sessions WITHOUT going through a database. I'm looking for something like
a
> singleton stateful session bean. A typical example would be a community
web
> site with two or more web servers working against an application server,
> where it would be beneficial to keep shared data in memory on the app
> server, i.e. things like the current number of users and the like.
>
> --
> ?
>

===========================================================================
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