• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Stateless Session Bean variables static or non-static.

 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello ,

Should the variables in Stateless session beans be satic or non-static?

thanks,
mallika
 
Ranch Hand
Posts: 563
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If they are static, they cannot be final.
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mallika Shah,

The answer is in the EJB3 specs 21.1.2:

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.


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.

Hope this helps,

Beno�t
 
mallika shah
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Benoit.

You have cleared my doubt..read the point from specs which you mentioned..
Also the same thing is mentioned in Pro EJB 3 -

For Stateless Session beans,static fileds should not be used,primarily because of bean redeployment issues..

As written in EJB specs, does that mean-"FOR ALL THE KINDS OF BEANS WHETHER SESSION , MDB" that if the beans use static fields , they should be declared FINAL.?

thanks for the prompt reply ,
mallika
 
It is an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic