Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

static fields in EJB

 
Ranch Hand
Posts: 644
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can the EJB have static fields declared in the code?? Also the static blocks?? are they allowed in EJBs??

thanks
trupti
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by trupti nigam:
Can the EJB have static fields declared in the code?? Also the static blocks?? are they allowed in EJBs??

thanks
trupti



EJB 2.0 Spec. Page 494. 24.1.2 Programming restrictions

"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."

So you can use static as a mean of declaring constants but not use it as a field which value can be updated by multiple bean instances. Therefore, static block would be illegal.

Vitaliy
 
Let nothing stop you! Not even this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic