File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Problems using instance variables EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Problems using instance variables EJB" Watch "Problems using instance variables EJB" New topic
Author

Problems using instance variables EJB

Yuri Morais
Greenhorn

Joined: Jul 10, 2006
Posts: 8
How'd I maintain some instance variables in memory (without persist) in a way that all the clients can acess and modify them?
I tried to use Stateless bean, but they are pooled, and because of that the attributes of one instance would be different of another.
Stateful beans would be good, but my attributes have to be shared between clients.

Does anyone know a solution??
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

Yuri,
You could use a singleton - an object that only has one copy in a given JVM.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

In a given JVM is a pretty big caveat.

This is correct, but if you cluster your application, you're in trouble.

I've seen alot of well thought out applications that fail miserably when they get clustered.

Many applications use a centralized database. Think about the implications of clustering, and a centralized database is a good idea. That's how many servers implement HttpSessions.

Cheers!

-Cameron McKenzie
Yuri Morais
Greenhorn

Joined: Jul 10, 2006
Posts: 8
Kameron,
That's a good solution, but I am using these data in memory in order to avoid the access to database, these data also include cache.
 
 
subject: Problems using instance variables EJB
 
Similar Threads
EL doubt
Query from Single Thread Model
Which attribute scopes are thread-safe ?
SingleThreadModel Mock Question
which attribute scopes are thread-safe