This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes static final object defined in stateless bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "static final object defined in stateless bean" Watch "static final object defined in stateless bean" New topic
Author

static final object defined in stateless bean

sanjay r tiwari
Greenhorn

Joined: Jun 05, 2002
Posts: 1
if we define static final bean class instance in
a stateless session bean than wether we are going
to have its one copy or not to all the client
Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1846
Sanjay could you please rephrase your question I am not able to understand what you are asking.
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
Are you asking whether all clients would (effectively) have access to the same static variable?
Well, because of issues around class loaders, server clustering and so on, you might in fact have more than one copy of the static variable alive at any one point in time. This is why it is not advisable to use statics for read-write variables.
Therefore, all clients might not have access to the same version.
Hope that answers your question.
Simon
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
if i assume that i w'd be deploying my application in only one applcn server, do you think i still can't depend on the static variable?
Do you expect more than 1 copy of the bean class file in the memory since we have multiple class loaders?
Actually I have a session bean which delegates some of the operations to another java class.
I'm holding on to the instance of the class inside
my session bean as a static final variable.
What is your opinion about this?
which takes me to my next question.
Is'nt there anway i can delegate tasks from a stateless session bean? I did'nt want my utility classes to be EJB/ APP server specific.
i mean, i want it to be a simple java class which can be called from anywhere.
OR
i was just wodnering, there's not much of initialization that i do inside my utility classes. if that's the case i really don't mind
certain things getting intialized twice.
thanks.
Originally posted by Simon Brown:
Are you asking whether all clients would (effectively) have access to the same static variable?
Well, because of issues around class loaders, server clustering and so on, you might in fact have more than one copy of the static variable alive at any one point in time. This is why it is not advisable to use statics for read-write variables.
Therefore, all clients might not have access to the same version.
Hope that answers your question.
Simon
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static final object defined in stateless bean
 
Similar Threads
Help??(Can we use wait method in Bean Class)
TransactionAttribute Question
Is the Bean Pool a model for our after life?
Using Static Variables in JAX-WS
final static variables in beans?