It's a bad idea. The closest you might get is to build a cache with a
Stateful Session Bean. But for read/write data to be consistent at all
times, you'll need to have a single cache for the entire cluster,
because:

1) Otherwise two instances of the caches might execute concurrently.
2) Synchornization of the caches may prove to be even more expensive
than no cache at all.

Basically, to implement a cache with write capabilities efficiently(and
regards for data consistency), you must have guarantees that there's
only one party executing the writes, and that you control it. You can't
achieve this in a cluster in an efficient way.

It could be possible, however, to implement more efficient caches if
requirements on transaction isolation aren't high, but that implies the
possibility of data corruption.

My 2c,

Juan Pablo Lorandi
Chief Software Architect
Code Foundry Ltd.
[EMAIL PROTECTED]

Barberstown, Straffan, Co. Kildare, Ireland.
Tel: +353-1-6012050  Fax: +353-1-6012051
Mobile: +353-86-2157900
www.codefoundry.com


> -----Original Message-----
> From: A mailing list for Enterprise JavaBeans development
> [mailto:EJB-INTEREST@;JAVA.SUN.COM] On Behalf Of Mike Landy
> Sent: Monday, October 28, 2002 7:25 PM
> To: [EMAIL PROTECTED]
> Subject: Singleton accessing EntityBean working as cache
>
>
> Hello!
>
> I have a situation where a Singleton class should offer an
> interface to a read/write cache object. Singleton class will
> run in clustered environment so, I thing there would be as
> many Singletons as there are JVMs.
>
> Is it ok/possible to use EntityBean or EntityBean and it's
> collection class member as an read/write cache object?
>
> I have thougt about following functionality:
>
> 1. EntityBean reads data from Database to e.g. a collection
> class (which works as a cache).
>
> 2. A Singleton class is created and is working as an
> interface to WebApplication (client).
>
> 3. WebApplications can read and update data that is hold in
> EntityBean's collection class. Singleton class provides
> interface for read and write actions.
>
> 4. Web Container is clustered, so there will be as many
> singleton classes as JVMs.
>
> So, the need is to have consistent data in EntityBean's
> collection class.
>
> I'm not sure if this approach is good at all..., so I would
> like to get tips how build a better/working solution.
>
> If someone has build same kind of solution (or better one), I
> would be happy to get hints/tips.
>
> Thanks,
>
> Mike
>
> ==============================================================
> =============
> 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