Class ThreadLocalObject
java.lang.Object
fc.util.ThreadLocalObject
Useful to store thread-local instances of any object. This class is intended
for servlets/molly pages. Instead of static get/set methods, this class
must be instantiated and the instance methods used to get/set the objom
object. This allows multiple instances of this class in the webapp, with
each instance being able to get/set a separate object.
Each thread must remember to individually create a separate object instance and store it via the set method. The usage idiom is:
//WebApp has a map of ThreadLocalObjects
ThreadLocalObject tl_obj = WebApp.getThreadLocalObject("foo");
if (tl_obj.isNull()) {
tl_obj.set(new obj());
}
Object obj = tl_obj.get();
Note, the lines in red are always needed anywhere/anytime this class is used.-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ThreadLocalObject
public ThreadLocalObject()
-
-
Method Details
-
get
-
set
-
isNull
-
main
-