• Post Reply Bookmark Topic Watch Topic
  • New Topic

New to EJB - question about static

 
verduka fox
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm very new to EJB, and recently read that no EJB may have static variables. Does this include static final variables (i.e. constants)? I have a web application that I am converting into EJB for the purpose of portlets. The main class that interacts with the database has several constant ints and Strings. Is it ok to put these in a stateless session bean?
Thanks for your help.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, "static final" constants are ok. I believe the restriction is there mostly because keeping non-final static variables in synch within a cluster would be difficult for the appserver vendors to implement.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, static final variables are allowed. Only statics that are not final are not allowed.
Kyle
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!