fc.util
Class ThreadLocalObject

java.lang.Object
  extended by fc.util.ThreadLocalObject

public final class ThreadLocalObject
extends Object

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
ThreadLocalObject()
           
 
Method Summary
 Object get()
           
 boolean isNull()
           
static void main(String[] args)
           
 void set(Object cal)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadLocalObject

public ThreadLocalObject()
Method Detail

get

public Object get()

set

public void set(Object cal)

isNull

public boolean isNull()

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception