This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hello, I had read somewhere that static variables are frowned upon in an EJB but static final is ok. Could someone explain this to me. I am using log4j and using static final Category category in my EJB and all seems fine.But I do not know why Trevor
I'll try to answer to your question. The value of a static variable is maintained within the current JVM. But an EJB can be accessed by a different JVM for each client. So a static variable in an EJB is not really shared. If an EJB modify the value of the variable, only EJBs within the same JVM will see the change. So the code is not safe. Actually, I don't think the EJB spec prevent you from using STATIC variables. I've never perform the test. It just advises not to use them.
/ JeanLouis<br /><i>"software development has been, is, and will remain fundamentally hard" (Grady Booch)</i><br /> <br />Take a look at <a href="http://www.epfwiki.net/wikis/openup/" target="_blank" rel="nofollow">Agile OpenUP</a> in the Eclipse community
static final variables are those whose values are completely fixed at compile time. Therefore, no matter which JVM (in a cluster) you are using, you'll always get an equivalent value for the variable. Kyle ------------------ Kyle Brown, Author of Enterprise Java (tm) Programming with IBM Websphere See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.