[SOLVED] Re: Static in WO (was: Refresh)
[SOLVED] Re: Static in WO (was: Refresh)
- Subject: [SOLVED] Re: Static in WO (was: Refresh)
- From: Florijan Stamenkovic <email@hidden>
- Date: Fri, 2 Mar 2007 19:37:07 +0100
Hi Mike,
Yup, that was my perception of the implications of static variables,
just never crossed my mind that each instance runs in a separate VM.
So yes, my heart is broken... Database procedures it is.
Terrracotta and class sharing don't seem like the right way to do this.
Thanks all,
Florijan
In Java, static variables are unique per-class-per-class-loader.
That is, if you have the same class loaded in two separate class
loaders, they will have independent static variables. Likewise,
obviously, if you run two JVM's, the static variables will not be
shared. WO instances each run in their own JVM's, completely
unshared (well, as far as you're concerned at the level you're
writing code). You can NOT count on static variables sharing
across instances. You can only count on static variables being
available in a SINGLE instance, and even then only in a SINGLE
class loader (though it just so happens that your entire app is
loaded in a single class loader, so that part isn't going to get
you). If you're counting on two instances of WO sharing a static
variable, you better start preparing yourself now, because you're
about to have your heart broken. If you need unique IDs across
instances, there are several techniques, but the least pain is to
just use sequence generators from your database and let the
database handle the concurrency and synchronization.
On Feb 28, 2007, at 9:32 PM, Florijan Stamenkovic wrote:
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden