• Post Reply Bookmark Topic Watch Topic
  • New Topic

using static with EJB?  RSS feed

 
Jane Somerfield
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should or should not use static member, method,
or variable with EJB?
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only static final variables are allowed by the EJB Specification.
From EJB 2.0 Specification:
An enterprise Bean must not use read/write static fields. Using read-only static fields is allowed. Therefore, it is recommended that all static fields in the enterprise bean class be declared as final

Static methods do not make sense in the context of EJB because they are not polymorphic and therefore cannot be defined for an interface.
 
Jane Somerfield
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What if the EJB is running in a non-clustering
environment?
How to do something like this:
Thread.currentThread.sleep(1000000)
with EJB? It compiles OK. Whould it
generates runtime errors?
How to use Singleton with EJB? It seems
OK as long as the EJB is running in a
single server.
Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!