• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB static variables  RSS feed

 
aakash bhatt
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why in EJB static variables are discouraged?
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This rule is required to ensure consistent runtime semantics because while some EJB Containers may
use a single JVM to execute all enterprise bean�s instances, others may distribute the instances across
multiple JVMs.
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, static variables are not discouraged, they just have to be marked static final. As Pradeep said, this is to ensure proper behavior in clustered environments when multiple JVMs will be excuting ejb requests. Furthermore, allowing the use of static read-write variables could cause threading issues.
[ August 27, 2003: Message edited by: Chris Mathews ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!