ERXObjectStoreCoordinatorPool Class Reference

Collaboration diagram for ERXObjectStoreCoordinatorPool:

Collaboration graph
[legend]

List of all members.

Classes

class  MultiOSCFactory

Public Member Functions

EOObjectStore currentRootObjectStore ()
EOObjectStore nextObjectStore ()
void sessionDidCreate (NSNotification n)
void sessionDidTimeout (NSNotification n)
EOSharedEditingContext sharedEditingContextForObjectStore (EOObjectStore os)

Static Public Member Functions

static
ERXObjectStoreCoordinatorPool 
_pool ()
static void initialize ()
static void initializeIfNecessary ()

Protected Member Functions

EOObjectStore currentThreadObjectStore ()
String sessionID ()

Static Protected Attributes

static
ERXObjectStoreCoordinatorPool 
_pool

Private Member Functions

void _initObjectStores ()
 ERXObjectStoreCoordinatorPool ()

Private Attributes

int _currentObjectStoreIndex
Object _lock = new Object()
int _maxOS
List _objectStores
Observer _observer
Hashtable _oscForSession
List _sharedEditingContexts

Static Private Attributes

static final Logger log = Logger.getLogger(ERXObjectStoreCoordinatorPool.class)
static final String THREAD_OSC_KEY = "er.extensions.ERXObjectStoreCoordinatorPool.threadOSC"


Detailed Description

This class implements EOF stack pooling including EOF stack synchronizing. It provides a special ERXEC.Factory in order to work without any changes in existing applications. The number of EOObjectStoreCoordinators can be set with the system Property er.extensions.ERXObjectStoreCoordinatorPool.maxCoordinators. Each Session will become one EOObjectStoreCoordinator and the method newEditingContext will always return an EOEditingContext with the same EOObjectStoreCoordinator for the same WOSession. This first release uses round-robin pooling, future versions might use better algorithms to decide which EOObjectStoreCoordinator will be used for the next new WOSession.
The code is tested in a heavy multithreaded application and afawk no deadlock occures, neither in EOF nor directly in Java.

Author:
David Teran, Frank Caputo @ cluster9

Constructor & Destructor Documentation

ERXObjectStoreCoordinatorPool (  )  [private]

Creates a new ERXObjectStoreCoordinatorPool. This object is a singleton. This object is responsible to provide EOObjectStoreCoordinators based on the current Threads' session. It is used by MultiOSCFactory to get a rootObjectStore if the MultiOSCFactory is asked for a new EOEditingContext.


Member Function Documentation

void _initObjectStores (  )  [private]

static ERXObjectStoreCoordinatorPool _pool (  )  [static]

EOObjectStore currentRootObjectStore (  ) 

returns the session related EOObjectStoreCoordinator. If session is null then it returns the nextObjectStore. This method is used to create new EOEditingContexts with the MultiOSCFactory

Returns:
an EOEditingContext

EOObjectStore currentThreadObjectStore (  )  [protected]

Returns the object store for the current thread (or requests one and sets it if there isn't one).

Returns:
the object store for the current thread

static void initialize (  )  [static]

Creates the singleton and registers the multi factory.

static void initializeIfNecessary (  )  [static]

Calls initialize() if the required system properties exist.

EOObjectStore nextObjectStore (  ) 

Lazy initialises the objectStores and then returns the next one, this is based on round robin.

Returns:
the next EOObjectStore based on round robin

void sessionDidCreate ( NSNotification  n  ) 

checks if the new Session has already a EOObjectStoreCoordinator assigned, if not it assigns a EOObjectStoreCoordinator to the session.

Parameters:
n WOSession#SessionDidCreateNotification

void sessionDidTimeout ( NSNotification  n  ) 

Removes the timed out session from the internal array. session.

Parameters:
n WOSession#SessionDidTimeOutNotification

String sessionID (  )  [protected]

Returns:
the sessionID from the session stored in ERXThreadStorage.

EOSharedEditingContext sharedEditingContextForObjectStore ( EOObjectStore  os  ) 


Member Data Documentation

int _currentObjectStoreIndex [private]

Object _lock = new Object() [private]

int _maxOS [private]

List _objectStores [private]

Observer _observer [private]

Hashtable _oscForSession [private]

ERXObjectStoreCoordinatorPool _pool [static, protected]

List _sharedEditingContexts [private]

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

final String THREAD_OSC_KEY = "er.extensions.ERXObjectStoreCoordinatorPool.threadOSC" [static, private]


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

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