Project Wonder 2.0

er.extensions
Class ERXObjectStoreCoordinatorPool

java.lang.Object
  extended byer.extensions.ERXObjectStoreCoordinatorPool

public class ERXObjectStoreCoordinatorPool
extends Object

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

Nested Class Summary
static class ERXObjectStoreCoordinatorPool.MultiOSCFactory
          This class uses different EOF stack when creating new EOEditingContexts.
 
Field Summary
protected static ERXObjectStoreCoordinatorPool _pool
           
 
Method Summary
 EOObjectStore currentRootObjectStore()
          returns the session related EOObjectStoreCoordinator.
static void initialize()
          Creates the singleton and registers the multi factory.
 EOObjectStore nextObjectStore()
          Lazy initialises the objectStores and then returns the next one, this is 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.
 void sessionDidTimeout(NSNotification n)
          Removes the timed out session from the internal array.
protected  String sessionID()
           
 EOSharedEditingContext sharedEditingContextForObjectStore(EOObjectStore os)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_pool

protected static ERXObjectStoreCoordinatorPool _pool
Method Detail

initialize

public static void initialize()
Creates the singleton and registers the multi factory.


sessionDidCreate

public 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

sessionDidTimeout

public void sessionDidTimeout(NSNotification n)
Removes the timed out session from the internal array. session.

Parameters:
n - WOSession.SessionDidTimeOutNotification

sessionID

protected String sessionID()
Returns:
the sessionID from the session stored in ERXThreadStorage.

currentRootObjectStore

public 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

nextObjectStore

public 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

sharedEditingContextForObjectStore

public EOSharedEditingContext sharedEditingContextForObjectStore(EOObjectStore os)

Last updated: Do, Dez 9, 2004 • 12:46 PM CET

Copyright © 2002 – 2004 Project Wonder.