• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems using instance variables EJB

 
Yuri Morais
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34656
366
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yuri,
You could use a singleton - an object that only has one copy in a given JVM.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic