• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB and Singleton  RSS feed

 
chao cai
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we call a Singleton instance in the EJB method, also the singleton instance is synchronized?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can, so long as the singleton is read only, i.e. it provides a cache of static data for your ejbs.
[ August 23, 2006: Message edited by: Paul Sturrock ]
 
chao cai
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I wanna use it as the read/write cache,so the singleton instance will synchronize the get/set method.
Can we do it?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.

You can use an RMI service to create a read/write cache for EJBs (it has to be a service to allow it to be clusterable). Not simple. See here for a discussion.

The other approach is to consider if you can live without the cache. Using a read only data base table, rather than cache might be tolerable performance wise, and is a great deal easier.
 
chao cai
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The clustable is not the matter to me,so can I use the singleton as the cache,if not why?
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
never say it's not an issue.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!