ERXThreadStorage Class Reference

Collaboration diagram for ERXThreadStorage:

Collaboration graph
[legend]

List of all members.

Classes

class  ERXThreadStorageCloneableThreadLocal

Static Public Member Functions

static Map map ()
static Set< StringproblematicKeys ()
static Set< Class<?> > problematicTypes ()
static Object removeValueForKey (String key)
static void reset ()
static void setProblematicKeys (Set< String > problematicKeys)
static void setProblematicTypes (NSSet< Class<?>> problematicTypes)
static void takeValueForKey (Object object, String key)
static Object valueForKey (EOEditingContext ec, String key)
static Object valueForKey (String key)
static Object valueForKeyPath (String keyPath)
static boolean wasInheritedFromParentThread ()

Static Public Attributes

static final String KEYS_ADDED_IN_CURRENT_THREAD_KEY = "ERXThreadStorage.keysAddedInCurrentThread"
static final String WAS_CLONED_MARKER = "ERXThreadStorage.wasCloned"

Static Package Functions

 [static initializer]

Static Private Member Functions

static boolean logUsageOfProblematicInheritedValues ()
static void markKeyAddedInCurrentThread (String key)
static Map storageMap (boolean create)
static boolean useInheritableThreadLocal ()
static boolean wasKeyAddedInCurrentThread (String key)

Static Private Attributes

static Boolean _logUsageOfProblematicInheritedValues
static Set< String_problematicKeys
static Set< Class<?> > _problematicTypes
static Boolean _useInheritableThreadLocal
static int DefaultHashMapSize = 10
static final Logger log = Logger.getLogger(ERXThreadStorage.class)
static ThreadLocal threadMap


Detailed Description

ERXThreadStorage provides a way to store objects for a particular thread. This can be especially handy for storing objects like the current actor or the current form name within the scope of a thread handling a particular request.
The system property er.extensions.ERXThreadStorage.useInheritableThreadLocal defines if the thread storage can be either inherited by client threads (default) or get used only by the current thread. The usage of some types of objects inherited from the parent thread can cause problems. The system property er.extensions.ERXThreadStorage.logUsageOfProblematicInheritedValues defines, if potential problems should be logged. This defaults to true when running in development mode and to false when running a deployed app.

Member Function Documentation

[static initializer] (  )  [static, package]

static boolean logUsageOfProblematicInheritedValues (  )  [static, private]

Checks the system property er.extensions.ERXThreadStorage.logUsageOfProblematicInheritedValues to decide whether to log potential problems when using certain values inherited by the parent thread. Only applies if using inheritable thread variables.

Returns:
true if set (default)

static Map map (  )  [static]

Gets the storage map from the current thread. At the moment this Map is syncronized for thread safety. This might not be necessary in which case users of this method would need to make sure that they take the appropriate precautions.

Returns:
Map object associated with this particular thread.

static void markKeyAddedInCurrentThread ( String  key  )  [static, private]

Registers that a key was added in the current thread. Only applies if the storageMap was inherited from the parent thread.

Parameters:
key to bless

static Set<String> problematicKeys (  )  [static]

Retrieve the Set of keys for which a warning is issued when the storageMap was inherited from another Thread and the key is accessed. Defaults to a set containing ERXWOContext.CONTEXT_DICTIONARY_KEY

Returns:
the set of keys to check

static Set<Class<?> > problematicTypes (  )  [static]

Retrieve the Set of classes for which a warning is issued when the storageMap was inherited from another Thread and the object retrieved from the map is a subclass of one of the classes in the set. Defaults to a Set containing WOSession.class, WOContext.class, EOEnterpriseObject.class and EOEditingContext.class

Returns:
the set of classes to check

static Object removeValueForKey ( String  key  )  [static]

Removes the value in the map for a given key.

Parameters:
key key to be removed from the map.
Returns:
the object corresponding to the key that was removed, null if nothing is found.

static void reset (  )  [static]

Removes all of the keys from the current Map.

static void setProblematicKeys ( Set< String problematicKeys  )  [static]

Set the Set of keys for which a warning is issued when the storageMap was inherited from another Thread and the key is accessed.

Parameters:
problematicKeys a set of keys to check

static void setProblematicTypes ( NSSet< Class<?>>  problematicTypes  )  [static]

Set the Set of classes for which a warning is issued when the storageMap was inherited from another Thread and the object retrieved from the map is a subclass of one of the classes in the set.

Parameters:
problematicTypes a set of classes to check

static Map storageMap ( boolean  create  )  [static, private]

Gets the Map from the thread map. Has the option to to create the map if it hasn't been created yet for this thread. Only used internally.

Parameters:
create should create the map storage if it isn't found.
Returns:
the map for the current thread or null

static void takeValueForKey ( Object  object,
String  key 
) [static]

Sets a value for a particular key for a particular thread.

Parameters:
object value
key key

static boolean useInheritableThreadLocal (  )  [static, private]

Checks the system property er.extensions.ERXThreadStorage.useInheritableThreadLocal to decide whether to use inheritable thread variables or not.

Returns:
true if set (default)

static Object valueForKey ( EOEditingContext  ec,
String  key 
) [static]

Gets the object associated with the key in the storage map off of the current thread in the given editing context. Throws a ClassCastException when the value is not an EO.

Parameters:
ec editing context to retrieve the value into
key key to be used to retrieve value from map.
Returns:
the value stored in the map for the given key.

static Object valueForKey ( String  key  )  [static]

Gets the object associated with the key in the storage map off of the current thread.

Parameters:
key key to be used to retrieve value from map.
Returns:
the value stored in the map for the given key.

static Object valueForKeyPath ( String  keyPath  )  [static]

Gets the object associated with the keypath in the storage map off of the current thread.

Parameters:
keyPath key path to be used to retrieve value from map.
Returns:
the value stored in the map for the given key.

static boolean wasInheritedFromParentThread (  )  [static]

Checks if the storageMap was inherited from the parent thread.

Returns:
boolean indicating if the storageMap was inherited from another thread

static boolean wasKeyAddedInCurrentThread ( String  key  )  [static, private]

Checks if a key was added in the current thread. Only applies if the storageMap was inherited from the parent thread.

Parameters:
key to check
Returns:
boolean indicating if the key was added in the current thread


Member Data Documentation

Boolean _logUsageOfProblematicInheritedValues [static, private]

Set<String> _problematicKeys [static, private]

Set<Class<?> > _problematicTypes [static, private]

Boolean _useInheritableThreadLocal [static, private]

int DefaultHashMapSize = 10 [static, private]

Holds the default initialization value of the hash map.

final String KEYS_ADDED_IN_CURRENT_THREAD_KEY = "ERXThreadStorage.keysAddedInCurrentThread" [static]

final Logger log = Logger.getLogger(ERXThreadStorage.class) [static, private]

ThreadLocal threadMap [static, private]

Holds the single instance of the thread map.

final String WAS_CLONED_MARKER = "ERXThreadStorage.wasCloned" [static]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:15 2012 for Project Wonder by  doxygen 1.5.8