|
Project Wonder 5.0.0.8654 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.webobjects.eocontrol.EOObjectStore
com.webobjects.eocontrol.EOEditingContext
er.extensions.eof.ERXEC
public class ERXEC
Subclass that has every public method overridden to support automatic
lock/unlock handling for you. This is very useful, as is is potentially very
dangerous to rely on EOFs automatic lock handling - it will invariably lead
into deadlocks. As you will need to use this class and its subclasses
exclusively as your ECs, it also contains a factory class to create editing
contexts. The Factory also sets a default delegate for you and is used
everywhere in ERExtensions and ERDirectToWeb. The Factory is actually and
interface and you would create a new EC by using:
ERXEC.newEditingContext() You can also install your own
Factory classes. It is recommended to subclass ERXEC.DefaultFactory and
override _createEditingContext()
| Nested Class Summary | |
|---|---|
static class |
ERXEC.DefaultFactory
Default implementation of the Factory interface. |
static interface |
ERXEC.Delegate
Extensions for the EOEditingContext.Delegate interface. |
static interface |
ERXEC.Factory
|
static class |
ERXEC.OpenEditingContextLockSignalHandler
OpenEditingContextLockSignalHandler provides a signal handler that prints out open editing context locks. |
| Nested classes/interfaces inherited from class com.webobjects.eocontrol.EOEditingContext |
|---|
EOEditingContext._EventLoggingEnabler, EOEditingContext.EditingContextEvent, EOEditingContext.Editor, EOEditingContext.MessageHandler |
| Nested classes/interfaces inherited from interface com.webobjects.eocontrol.EOKeyValueArchiving |
|---|
EOKeyValueArchiving._NullValueSupport, EOKeyValueArchiving._NumberSupport, EOKeyValueArchiving._TimestampSupport, EOKeyValueArchiving.Awaking, EOKeyValueArchiving.FinishInitialization, EOKeyValueArchiving.Support |
| Field Summary | |
|---|---|
static String |
EditingContextDidCreateNotification
Name of the notification that is posted after editing context is created. |
static String |
EditingContextDidRevertChanges
Name of the notification that is posted when an editing context is reverted. |
static String |
EditingContextFailedToSaveChanges
Name of the notification that is posted when an editing context has failed to save changes. |
static String |
EditingContextWillSaveChangesNotification
Name of the notification that is posted before an editing context is saved. |
protected static ERXEC.Factory |
factory
holds a reference to the factory used to create editing contexts |
static Logger |
lockLogger
logs a message when set to DEBUG, autoLocking is enabled and an EC is used without a lock. |
static Logger |
lockLoggerTrace
logs a message with a stack trace when set to DEBUG and an EC is locked/unlocked. |
static Logger |
lockTrace
Logs a message when set to DEBUG and an EC is locked/unlocked. |
static Logger |
log
general logging |
| Fields inherited from class com.webobjects.eocontrol.EOObjectStore |
|---|
_doAssertLock, _doAssertLockInitialized, _userInfo, _wasDisposed, DeletedKey, InsertedKey, InvalidatedAllObjectsInStoreNotification, InvalidatedKey, ObjectsChangedInStoreNotification, UpdatedKey |
| Fields inherited from interface com.webobjects.foundation.NSLocking |
|---|
OneCentury, OneDay, OneHour, OneMinute, OneSecond, OneWeek, OneYear |
| Constructor Summary | |
|---|---|
ERXEC()
default constructor |
|
ERXEC(EOObjectStore os)
alternative constructor |
|
| Method Summary | |
|---|---|
protected void |
_checkOpenLockTraces()
|
void |
_objectsChangedInStore(NSNotification nsnotification)
Overridden so add a bugfix from Lenny Marks |
protected void |
_saveChanges()
|
NSArray |
arrayFaultWithSourceGlobalID(EOGlobalID eoglobalid,
String s,
EOEditingContext eoeditingcontext)
Overriden to support autoLocking. |
protected boolean |
autoLock(String method)
Utility to actually emit the log messages and do the locking, based on the result of useAutoLock(). |
protected void |
autoUnlock(boolean wasAutoLocked)
Utility to unlock the EC is it was locked in the previous invocation. |
boolean |
coalesceAutoLocks()
If you just use autolocking, you will end up churning locks constantly. |
NSDictionary |
committedSnapshotForObject(EOEnterpriseObject eoenterpriseobject)
Overriden to support autoLocking. |
Exception |
creationTrace()
If traceOpenEditingContextLocks is true, returns the stack trace from when this EC was created |
NSDictionary |
currentEventSnapshotForObject(EOEnterpriseObject eoenterpriseobject)
Overriden to support autoLocking. |
static boolean |
defaultAutomaticLockUnlock()
|
static boolean |
defaultCoalesceAutoLocks()
|
NSArray |
deletedObjects()
Overriden to support autoLocking. |
void |
deleteObject(EOEnterpriseObject eo)
Overriden to support autoLocking and to call mightDelete() on subclasses of ERXEnterpriseObject. |
void |
deleteObjects(NSArray objects)
Utility to delete a bunch of objects. |
protected void |
didSaveChanges(NSArray insertedObjects,
NSArray updatedObjects,
NSArray deletedObjects)
|
void |
dispose()
|
void |
editingContextDidForgetObjectWithGlobalID(EOEditingContext eoeditingcontext,
EOGlobalID eoglobalid)
Overriden to support autoLocking. |
static ERXEC.Factory |
factory()
Gets the factory used to create editing contexts |
EOEnterpriseObject |
faultForGlobalID(EOGlobalID eoglobalid,
EOEditingContext eoeditingcontext)
Overriden to support autoLocking. |
void |
finalize()
Overriden to support automatic autoLocking. |
void |
forgetObject(EOEnterpriseObject eoenterpriseobject)
Overriden to support autoLocking. |
EOGlobalID |
globalIDForObject(EOEnterpriseObject eoenterpriseobject)
Overriden to support autoLocking. |
boolean |
hasChanges()
Overriden to support autoLocking. |
void |
initializeObject(EOEnterpriseObject eoenterpriseobject,
EOGlobalID eoglobalid,
EOEditingContext eoeditingcontext)
Overriden to support autoLocking. |
NSArray |
insertedObjects()
Overriden to support autoLocking. |
void |
insertObject(EOEnterpriseObject eoenterpriseobject)
Overriden to support autoLocking. |
void |
insertObjectWithGlobalID(EOEnterpriseObject eoenterpriseobject,
EOGlobalID eoglobalid)
Overriden to support autoLocking. |
void |
invalidateAllObjects()
Overriden to support autoLocking. |
void |
invalidateObjectsWithGlobalIDs(NSArray nsarray)
Overriden to support autoLocking. |
Object |
invokeRemoteMethod(EOEditingContext eoeditingcontext,
EOGlobalID eoglobalid,
String s,
Class[] aclass,
Object[] aobj)
Overriden to support autoLocking. |
boolean |
isAutoLocked()
Returns whether we did autolock this instance. |
void |
lock()
Overridden to emmit log messages and push this instance to the locked editing contexts in this thread. |
int |
lockCount()
Returns the number of outstanding locks. |
void |
lockObject(EOEnterpriseObject eoenterpriseobject)
Overriden to support autoLocking. |
static EOEditingContext |
newEditingContext()
Factory method to create a new editing context. |
static EOEditingContext |
newEditingContext(boolean validation)
Factory method to create a new editing context with validation disabled. |
static EOEditingContext |
newEditingContext(EOObjectStore objectStore)
Creates a new editing context with the specified object store as the parent object store. |
static EOEditingContext |
newEditingContext(EOObjectStore parent,
boolean validationEnabled)
Creates a new editing context with the specified object store as the parent object store and with validation turned on or off depending on the flag passed in. |
static EOEditingContext |
newTolerantEditingContext()
|
static EOEditingContext |
newTolerantEditingContext(EOObjectStore osc)
|
static EOEditingContext |
newTolerantEditingContext(EOObjectStore parent,
boolean retry,
boolean merge)
Factory method to create a new tolerant editing context. |
EOEnterpriseObject |
objectForGlobalID(EOGlobalID eoglobalid)
Overriden to support autoLocking. |
NSArray |
objectsForSourceGlobalID(EOGlobalID eoglobalid,
String s,
EOEditingContext eoeditingcontext)
Overriden to support autoLocking. |
NSArray |
objectsWithFetchSpecification(EOFetchSpecification eofetchspecification,
EOEditingContext eoeditingcontext)
Overriden to support autoLocking. |
void |
objectWillChange(Object obj)
Overriden to support autoLocking. |
NSArray |
openLockTraces()
If traceOpenEditingContextLocks is true, returns the stack trace from when this EC was locked |
static void |
popLockedContextForCurrentThread(EOEditingContext ec)
Pops the given EC from the array of contexts to unlock. |
void |
processRecentChanges()
Overriden to support autoLocking. |
static void |
pushLockedContextForCurrentThread(EOEditingContext ec)
Pushes the given EC to the array of locked ECs in the current thread. |
void |
recordObject(EOEnterpriseObject eoenterpriseobject,
EOGlobalID eoglobalid)
Overriden to support autoLocking. |
void |
redo()
Overriden to support autoLocking. |
void |
refaultAllObjects()
Overriden to support autoLocking. |
void |
refaultObject(EOEnterpriseObject eoenterpriseobject)
Overriden to support autoLocking. |
void |
refaultObject(EOEnterpriseObject eoenterpriseobject,
EOGlobalID eoglobalid,
EOEditingContext eoeditingcontext)
Overriden to support autoLocking and to flush the cache of all ERXEnterpriseObjects. |
void |
refreshObject(EOEnterpriseObject eoenterpriseobject)
Overriden to support autoLocking. |
NSArray |
registeredObjects()
Overriden to support autoLocking. |
static void |
registerOpenEditingContextLockSignalHandler()
Register the OpenEditingContextLockSignalHandler signal handle on the HUP signal. |
static void |
registerOpenEditingContextLockSignalHandler(String signalName)
Register the OpenEditingContextLockSignalHandler signal handle on the named signal. |
void |
reset()
Overriden to support automatic autoLocking. |
void |
revert()
Overriden to support autoLocking and will/did revert delegate methods. |
static boolean |
safeLocking()
Returns the value of the er.extensions.ERXEC.safeLocking property, which is the new catch-all setting that turns on all of the recommended locking settings. |
void |
saveChanges()
Smarter version of normal saveChanges() method. |
void |
saveChanges(Object obj)
Deprecated. |
void |
saveChangesInEditingContext(EOEditingContext eoeditingcontext)
Overriden to support autoLocking. |
void |
saveChangesTolerantly()
|
void |
saveChangesTolerantly(boolean doesRetry)
|
void |
saveChangesTolerantly(boolean doesRetry,
boolean mergesChanges)
Saves changes and tries to recover from optimistic locking exceptions by refaulting the object in question, optionally merging the changed values and optionally retrying the save. |
static void |
saveChangesTolerantly(EOEditingContext ec)
|
static void |
saveChangesTolerantly(EOEditingContext ec,
boolean doesRetry,
boolean mergesChanges)
|
void |
setCoalesceAutoLocks(boolean value)
Returns whether or not coalescing auto locks is enabled. |
void |
setDelegate(Object d)
Sets the delegate for this context. |
static void |
setFactory(ERXEC.Factory aFactory)
Sets the default editing context factory |
void |
setOptions(boolean recoversFromException,
boolean doesRetry,
boolean mergesChanges)
Set the options for the saveChanges() operation. |
void |
setSharedEditingContext(EOSharedEditingContext eosharededitingcontext)
Overriden to support autoLocking. |
static void |
setTraceOpenLocks(boolean value)
Sets whether or not open editing context lock tracing is enabled. |
void |
setUseAutoLock(boolean value)
Sets whether to use autoLocking on this EC. |
static void |
setUseUnlocker(boolean value)
|
static boolean |
traceOpenLocks()
|
void |
undo()
Overriden to support autoLocking. |
void |
unlock()
Overridden to emmit log messages and pull this instance from the locked editing contexts in this thread. |
static void |
unlockAllContextsForCurrentThread()
Unlocks all remaining locked contexts in the current thread. |
NSArray |
updatedObjects()
Overriden to support autoLocking. |
boolean |
useAutoLock()
Decides on a per-EC-level if autoLocking should be used. |
static boolean |
useUnlocker()
|
protected void |
willSaveChanges(NSArray insertedObjects,
NSArray updatedObjects,
NSArray deletedObjects)
|
| Methods inherited from class com.webobjects.eocontrol.EOObjectStore |
|---|
_checkAssertLock, _resetAssertLock, _suppressAssertLock, setUserInfo, setUserInfoForKey, userInfo, userInfoForKey |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Logger log
public static final Logger lockLogger
public static final Logger lockLoggerTrace
public static final Logger lockTrace
public static final String EditingContextDidCreateNotification
public static final String EditingContextWillSaveChangesNotification
public static final String EditingContextDidRevertChanges
public static final String EditingContextFailedToSaveChanges
protected static ERXEC.Factory factory
| Constructor Detail |
|---|
public ERXEC()
public ERXEC(EOObjectStore os)
| Method Detail |
|---|
public static boolean safeLocking()
public static boolean useUnlocker()
public static void setUseUnlocker(boolean value)
public static boolean traceOpenLocks()
public static void setTraceOpenLocks(boolean value)
public static void pushLockedContextForCurrentThread(EOEditingContext ec)
ec - locked EOEditingContextpublic static void popLockedContextForCurrentThread(EOEditingContext ec)
ec - unlocked EOEditingContextpublic static void unlockAllContextsForCurrentThread()
public static boolean defaultAutomaticLockUnlock()
public static boolean defaultCoalesceAutoLocks()
public void deleteObjects(NSArray objects)
public boolean useAutoLock()
public void setUseAutoLock(boolean value)
public boolean coalesceAutoLocks()
public void setCoalesceAutoLocks(boolean value)
public int lockCount()
public Exception creationTrace()
public NSArray openLockTraces()
public void lock()
lock in interface NSLockinglock in class EOEditingContextpublic void unlock()
unlock in interface NSLockingunlock in class EOEditingContextprotected boolean autoLock(String method)
useAutoLock().
method - method name which to prepend to log message
protected void autoUnlock(boolean wasAutoLocked)
wasAutoLocked - true if the EC was autolockedpublic boolean isAutoLocked()
protected void _checkOpenLockTraces()
public void dispose()
dispose in interface NSDisposabledispose in class EOEditingContext
public void finalize()
throws Throwable
finalize in class EOEditingContextThrowablepublic void reset()
reset in class EOEditingContext
public void recordObject(EOEnterpriseObject eoenterpriseobject,
EOGlobalID eoglobalid)
recordObject in class EOEditingContextpublic void forgetObject(EOEnterpriseObject eoenterpriseobject)
forgetObject in class EOEditingContextpublic void processRecentChanges()
processRecentChanges in class EOEditingContextpublic NSArray updatedObjects()
updatedObjects in class EOEditingContextpublic NSArray registeredObjects()
registeredObjects in class EOEditingContextpublic NSArray insertedObjects()
insertedObjects in class EOEditingContextpublic NSArray deletedObjects()
deletedObjects in class EOEditingContextpublic void setSharedEditingContext(