Project Wonder 5.0

er.extensions.eof
Class ERXEC

java.lang.Object
  extended by com.webobjects.eocontrol.EOObjectStore
      extended by com.webobjects.eocontrol.EOEditingContext
          extended by er.extensions.eof.ERXEC
All Implemented Interfaces:
com.webobjects.eocontrol.EOKeyValueArchiving, com.webobjects.eocontrol.EOObserving, com.webobjects.foundation.NSDisposable, com.webobjects.foundation.NSLocking, java.io.Serializable

public class ERXEC
extends com.webobjects.eocontrol.EOEditingContext

Subclass of EOEditingContext that has every public method overridden to support automatic lock/unlock handling for you. This is very useful, as it 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 instances. The Factory also sets a default delegate for you and is used everywhere in ERExtensions and ERDirectToWeb. The Factory is actually an 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()

See Also:
Serialized Form

Nested Class Summary
static class ERXEC._DenyMergeDelegate
          Temp EC delegate that prevents merging of changes to objects that already have changes.
static class ERXEC.DefaultFactory
          Default implementation of the Factory interface.
static interface ERXEC.Delegate
          Extensions for the EOEditingContext.Delegate interface.
static class ERXEC.DumpLocksSignalHandler
          OpenEditingContextLockSignalHandler provides a signal handler that prints out open editing context locks.
static interface ERXEC.Factory
           
 
Nested classes/interfaces inherited from class com.webobjects.eocontrol.EOEditingContext
com.webobjects.eocontrol.EOEditingContext._EventLoggingEnabler, com.webobjects.eocontrol.EOEditingContext.EditingContextEvent, com.webobjects.eocontrol.EOEditingContext.Editor, com.webobjects.eocontrol.EOEditingContext.MessageHandler
 
Nested classes/interfaces inherited from interface com.webobjects.eocontrol.EOKeyValueArchiving
com.webobjects.eocontrol.EOKeyValueArchiving._NullValueSupport, com.webobjects.eocontrol.EOKeyValueArchiving._NumberSupport, com.webobjects.eocontrol.EOKeyValueArchiving._TimestampSupport, com.webobjects.eocontrol.EOKeyValueArchiving.Awaking, com.webobjects.eocontrol.EOKeyValueArchiving.FinishInitialization, com.webobjects.eocontrol.EOKeyValueArchiving.Support
 
Field Summary
static boolean _shouldLockOnLockObjectStore
          Technically, the OSC is public API and as such should also get auto-locked.
protected static java.util.Map<ERXEC,java.lang.String> activeEditingContexts
           
static java.lang.String EditingContextDidCreateNotification
          Name of the notification that is posted after editing context is created.
static java.lang.String EditingContextDidRevertChanges
          Name of the notification that is posted when an editing context is reverted.
static java.lang.String EditingContextFailedToSaveChanges
          Name of the notification that is posted when an editing context has failed to save changes.
static java.lang.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 org.apache.log4j.Logger lockLogger
          Logs a message when set to DEBUG and an EC is locked/unlocked.
static org.apache.log4j.Logger lockTrace
          Logs a message with trace when set to DEBUG if autoLocking is enabled and an EC is used without a lock.
static org.apache.log4j.Logger log
          general logging
 
Fields inherited from class com.webobjects.eocontrol.EOEditingContext
_CLASS, _EditingContextDidChangeSharedEditingContextNotification, _EditingContextEditorHasChangesNotification, _IsEventLoggingEnabled, EditingContextDidSaveChangesNotification, EditingContextFlushChangesRunLoopOrdering, ObjectsChangedInEditingContextNotification
 
Fields inherited from class com.webobjects.eocontrol.EOObjectStore
_doAssertLock, _doAssertLockInitialized, _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()
           
ERXEC(com.webobjects.eocontrol.EOObjectStore os)
           
 
Method Summary
protected  void _checkOpenLockTraces()
           
protected  void _initWithParentObjectStore(com.webobjects.eocontrol.EOObjectStore parent)
           
 void _objectsChangedInStore(com.webobjects.foundation.NSNotification nsnotification)
          Overridden so add a bugfix from Lenny Marks
 void _processObjectStoreChanges(com.webobjects.foundation.NSDictionary info)
          Quick and experimental hack to hook into the merge-changes system.
protected  void _saveChanges()
           
 com.webobjects.foundation.NSArray arrayFaultWithSourceGlobalID(com.webobjects.eocontrol.EOGlobalID eoglobalid, java.lang.String s, com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
           
protected  boolean autoLock(java.lang.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.
 com.webobjects.foundation.NSDictionary committedSnapshotForObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
           
 java.lang.Exception creationTrace()
          If traceOpenEditingContextLocks is true, returns the stack trace from when this EC was created
 com.webobjects.foundation.NSDictionary currentEventSnapshotForObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
           
static boolean defaultAutomaticLockUnlock()
          Returns the value of the er.extensions.ERXEC.defaultAutomaticLockUnlock property, which turns on auto-locking by default.
static boolean defaultCoalesceAutoLocks()
          Returns the value of the er.extensions.ERXEC.defaultCoalesceAutoLocks property, which turns on coalescing auto-locks, meaning that the EC gets locked once and unlocked at the end of the RR loop.
 com.webobjects.foundation.NSArray deletedObjects()
           
 void deleteObject(com.webobjects.eocontrol.EOEnterpriseObject eo)
          Overridden to support autoLocking and to call mightDelete() on subclasses of ERXEnterpriseObject.
 void deleteObjects(com.webobjects.foundation.NSArray objects)
          Utility to delete a bunch of objects.
protected  void didSaveChanges(com.webobjects.foundation.NSArray insertedObjects, com.webobjects.foundation.NSArray updatedObjects, com.webobjects.foundation.NSArray deletedObjects)
           
 void dispose()
           
 void editingContextDidForgetObjectWithGlobalID(com.webobjects.eocontrol.EOEditingContext eoeditingcontext, com.webobjects.eocontrol.EOGlobalID eoglobalid)
           
static ERXEC.Factory factory()
          Gets the factory used to create editing contexts
 com.webobjects.eocontrol.EOEnterpriseObject faultForGlobalID(com.webobjects.eocontrol.EOGlobalID eoglobalid, com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
           
 void finalize()
           
 void forgetObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
           
 com.webobjects.eocontrol.EOGlobalID globalIDForObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
           
 boolean hasChanges()
           
 void initializeObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject, com.webobjects.eocontrol.EOGlobalID eoglobalid, com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
           
 com.webobjects.foundation.NSArray insertedObjects()
           
 void insertObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
           
 void insertObjectWithGlobalID(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject, com.webobjects.eocontrol.EOGlobalID eoglobalid)
           
 void invalidateAllObjects()
           
 void invalidateObjectsWithGlobalIDs(com.webobjects.foundation.NSArray nsarray)
           
 java.lang.Object invokeRemoteMethod(com.webobjects.eocontrol.EOEditingContext eoeditingcontext, com.webobjects.eocontrol.EOGlobalID eoglobalid, java.lang.String s, java.lang.Class[] aclass, java.lang.Object[] aobj)
           
 boolean isAutoLocked()
          Returns whether we did autolock this instance.
 void lock()
          Overridden to emit log messages and push this instance to the locked editing contexts in this thread.
 void lockObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
           
 void lockObjectStore()
           
static boolean markOpenLocks()
          Returns the value of the er.extensions.ERXEC.markOpenLocks property, which turns on marking of locks.
static com.webobjects.eocontrol.EOEditingContext newEditingContext()
          Factory method to create a new editing context.
static com.webobjects.eocontrol.EOEditingContext newEditingContext(boolean validation)
          Factory method to create a new editing context with validation disabled.
static com.webobjects.eocontrol.EOEditingContext newEditingContext(com.webobjects.eocontrol.EOObjectStore objectStore)
          Creates a new editing context with the specified object store as the parent object store.
static com.webobjects.eocontrol.EOEditingContext newEditingContext(com.webobjects.eocontrol.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 com.webobjects.eocontrol.EOEditingContext newTolerantEditingContext()
           
static com.webobjects.eocontrol.EOEditingContext newTolerantEditingContext(com.webobjects.eocontrol.EOObjectStore osc)
           
static com.webobjects.eocontrol.EOEditingContext newTolerantEditingContext(com.webobjects.eocontrol.EOObjectStore parent, boolean retry, boolean merge)
          Factory method to create a new tolerant editing context.
 com.webobjects.eocontrol.EOEnterpriseObject objectForGlobalID(com.webobjects.eocontrol.EOGlobalID eoglobalid)
           
 com.webobjects.foundation.NSArray objectsForSourceGlobalID(com.webobjects.eocontrol.EOGlobalID eoglobalid, java.lang.String s, com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
           
 com.webobjects.foundation.NSArray objectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification fs, com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
           
 void objectWillChange(java.lang.Object obj)
           
 com.webobjects.foundation.NSDictionary<java.lang.Thread,com.webobjects.foundation.NSMutableArray<java.lang.Exception>> openLockTraces()
          If traceOpenEditingContextLocks is true, returns the stack trace from when this EC was locked
static java.lang.String outstandingLockDescription()
          Returns a string describing outstanding locks for the created ECs
static void popLockedContextForCurrentThread(com.webobjects.eocontrol.EOEditingContext ec)
          Pops the given EC from the array of contexts to unlock.
 void processRecentChanges()
           
static void pushLockedContextForCurrentThread(com.webobjects.eocontrol.EOEditingContext ec)
          Pushes the given EC to the array of locked ECs in the current thread.
 void recordObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject, com.webobjects.eocontrol.EOGlobalID eoglobalid)
           
 void redo()
           
 void refaultAllObjects()
           
 void refaultObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
           
 void refaultObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject, com.webobjects.eocontrol.EOGlobalID eoglobalid, com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
          Overridden to support autoLocking and to flush the cache of all ERXEnterpriseObjects.
 void refreshObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
           
 com.webobjects.foundation.NSArray registeredObjects()
           
static void registerOpenEditingContextLockSignalHandler()
          Register the OpenEditingContextLockSignalHandler signal handle on the HUP signal.
static void registerOpenEditingContextLockSignalHandler(java.lang.String signalName)
          Register the OpenEditingContextLockSignalHandler signal handle on the named signal.
 void reset()
           
 void revert()
          Overridden 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(java.lang.Object obj)
          Deprecated.  
 void saveChangesInEditingContext(com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
           
 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(com.webobjects.eocontrol.EOEditingContext ec)
           
static void saveChangesTolerantly(com.webobjects.eocontrol.EOEditingContext ec, boolean doesRetry, boolean mergesChanges)
           
 void setCoalesceAutoLocks(boolean value)
          Sets whether or not coalescing auto locks should be enabled.
 void setDelegate(java.lang.Object d)
          Sets the delegate for this context.
static void setFactory(ERXEC.Factory aFactory)
          Sets the default editing context factory
static void setMarkOpenLocks(boolean value)
          Sets whether or not open editing context lock marking is enabled.
 void setOptions(boolean recoversFromException, boolean doesRetry, boolean mergesChanges)
          Set the options for the saveChanges() operation.
 void setSharedEditingContext(com.webobjects.eocontrol.EOSharedEditingContext eosharededitingcontext)
           
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()
          Returns the value of the er.extensions.ERXEC.traceOpenLocks property, which turns on tracing of locks.
 void undo()
           
 void unlock()
          Overridden to emit 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.
 void unlockObjectStore()
           
 com.webobjects.foundation.NSArray updatedObjects()
           
 boolean useAutoLock()
          Decides on a per-EC-level if autoLocking should be used.
static boolean useUnlocker()
          Returns the value of the er.extensions.ERXEC.useUnlocker property, which turns on unlocking at the end of the RR loop.
protected  void willSaveChanges(com.webobjects.foundation.NSArray insertedObjects, com.webobjects.foundation.NSArray updatedObjects, com.webobjects.foundation.NSArray deletedObjects)
           
 
Methods inherited from class com.webobjects.eocontrol.EOEditingContext
_clearChangedThisTransaction, _clearOriginalSnapshotAndInitializeRec, _clearOriginalSnapshotForObject, _defaultEditingContextNowInitialized, _defaultSharedEditingContextWasInitialized, _editorHasChanges, _EOAssertSafeMultiThreadedAccess, _EOAssertSafeMultiThreadedAccess, _EOAssertSafeMultiThreadedReadAccess, _globalIDChanged, _globalIDsForObjects, _insertObjectWithGlobalID, _invalidatedAllObjectsInStore, _invalidateObjectsDuringSave, _noop, _objectBasedChangeInfoForGIDInfo, _objectsInitializedInSharedContext, _processEndOfEventNotification, _processGlobalIDChanges, _processInitializedObjectsInSharedContext, _processNotificationQueue, _processRecentChanges, _resetAllChanges, _resetAllChanges, _retainCountForObjectWithGlobalID, _undoDelete, _undoManagerCheckpoint, _undoUpdate, addEditor, decodeWithKeyValueUnarchiver, defaultFetchTimestampLag, defaultParentObjectStore, delegate, editors, editorsHaveChanges, encodeObjectWithCoder, encodeWithKeyValueArchiver, faultForRawRow, faultForRawRow, fetchTimestamp, initObjectWithCoder, instancesRetainRegisteredObjects, invalidatesObjectsWhenFinalized, isObjectLockedWithGlobalID, lockObjectWithGlobalID, locksObjectsBeforeFirstModification, messageHandler, objectsWithFetchSpecification, parentObjectStore, propagatesDeletesAtEndOfEvent, readResolve, refaultObjects, refetch, refreshAllObjects, removeEditor, retainsRegisteredObjects, rootObjectStore, setDefaultFetchTimestampLag, setDefaultParentObjectStore, setFetchTimestamp, setInstancesRetainRegisteredObjects, setInvalidatesObjectsWhenFinalized, setLocksObjectsBeforeFirstModification, setMessageHandler, setPropagatesDeletesAtEndOfEvent, setRetainsRegisteredObjects, setStopsValidationAfterFirstError, setSubstitutionEditingContext, setUndoManager, setUsesContextRelativeEncoding, sharedEditingContext, stopsValidationAfterFirstError, substitutionEditingContext, tryLock, tryToSaveChanges, undoManager, usesContextRelativeEncoding
 
Methods inherited from class com.webobjects.eocontrol.EOObjectStore
_checkAssertLock, _resetAssertLock, _suppressAssertLock
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final org.apache.log4j.Logger log
general logging


lockLogger

public static final org.apache.log4j.Logger lockLogger
Logs a message when set to DEBUG and an EC is locked/unlocked. Logs a message with trace if lockTrace is also set to DEBUG.


lockTrace

public static final org.apache.log4j.Logger lockTrace
Logs a message with trace when set to DEBUG if autoLocking is enabled and an EC is used without a lock. Adds traces to messages by lockLogger if it is also set to DEBUG.


EditingContextDidCreateNotification

public static final java.lang.String EditingContextDidCreateNotification
Name of the notification that is posted after editing context is created.

See Also:
Constant Field Values

EditingContextWillSaveChangesNotification

public static final java.lang.String EditingContextWillSaveChangesNotification
Name of the notification that is posted before an editing context is saved.

See Also:
Constant Field Values

EditingContextDidRevertChanges

public static final java.lang.String EditingContextDidRevertChanges
Name of the notification that is posted when an editing context is reverted.

See Also:
Constant Field Values

EditingContextFailedToSaveChanges

public static final java.lang.String EditingContextFailedToSaveChanges
Name of the notification that is posted when an editing context has failed to save changes.

See Also:
Constant Field Values

_shouldLockOnLockObjectStore

public static boolean _shouldLockOnLockObjectStore
Technically, the OSC is public API and as such should also get auto-locked. In practice, it's called too often to warrant it. If you want, you can turn it on on a case by case basis.


activeEditingContexts

protected static java.util.Map<ERXEC,java.lang.String> activeEditingContexts

factory

protected static ERXEC.Factory factory
holds a reference to the factory used to create editing contexts

Constructor Detail

ERXEC

public ERXEC()

ERXEC

public ERXEC(com.webobjects.eocontrol.EOObjectStore os)
Method Detail

safeLocking

public 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.


defaultAutomaticLockUnlock

public static boolean defaultAutomaticLockUnlock()
Returns the value of the er.extensions.ERXEC.defaultAutomaticLockUnlock property, which turns on auto-locking by default. Also returns true if safeLocking is true.


defaultCoalesceAutoLocks

public static boolean defaultCoalesceAutoLocks()
Returns the value of the er.extensions.ERXEC.defaultCoalesceAutoLocks property, which turns on coalescing auto-locks, meaning that the EC gets locked once and unlocked at the end of the RR loop. Also returns true if safeLocking is true.


useUnlocker

public static boolean useUnlocker()
Returns the value of the er.extensions.ERXEC.useUnlocker property, which turns on unlocking at the end of the RR loop. Also returns true if safeLocking is true.


setUseUnlocker

public static void setUseUnlocker(boolean value)

traceOpenLocks

public static boolean traceOpenLocks()
Returns the value of the er.extensions.ERXEC.traceOpenLocks property, which turns on tracing of locks. You can see the trace either by kill -HUP, by the ERXDirectAction/showOpenEditingContextLockTraces action or by setting your App's statistic store to ERXStatisticStore.


markOpenLocks

public static boolean markOpenLocks()
Returns the value of the er.extensions.ERXEC.markOpenLocks property, which turns on marking of locks. You can see the threads that hold the lock either by kill -HUP, by the ERXDirectAction/showOpenEditingContextLockTraces action or by setting your App's statistic store to ERXStatisticStore. Also returns true if traceOpenLocks is true.


setTraceOpenLocks

public static void setTraceOpenLocks(boolean value)
Sets whether or not open editing context lock tracing is enabled.


setMarkOpenLocks

public static void setMarkOpenLocks(boolean value)
Sets whether or not open editing context lock marking is enabled.


pushLockedContextForCurrentThread

public static void pushLockedContextForCurrentThread(com.webobjects.eocontrol.EOEditingContext ec)
Pushes the given EC to the array of locked ECs in the current thread. The ECs left over after the RR-loop will be automagically unlocked.

Parameters:
ec - locked EOEditingContext

popLockedContextForCurrentThread

public static void popLockedContextForCurrentThread(com.webobjects.eocontrol.EOEditingContext ec)
Pops the given EC from the array of contexts to unlock. The ECs left over after the RR-loop will be automagically unlocked.

Parameters:
ec - unlocked EOEditingContext

unlockAllContextsForCurrentThread

public static void unlockAllContextsForCurrentThread()
Unlocks all remaining locked contexts in the current thread. You shouldn't call this yourself, but let the Unlocker handle it for you.


_initWithParentObjectStore

protected void _initWithParentObjectStore(com.webobjects.eocontrol.EOObjectStore parent)
Overrides:
_initWithParentObjectStore in class com.webobjects.eocontrol.EOEditingContext

deleteObjects

public void deleteObjects(com.webobjects.foundation.NSArray objects)
Utility to delete a bunch of objects.


useAutoLock

public boolean useAutoLock()
Decides on a per-EC-level if autoLocking should be used.


setUseAutoLock

public void setUseAutoLock(boolean value)
Sets whether to use autoLocking on this EC.


coalesceAutoLocks

public boolean coalesceAutoLocks()
If you just use autolocking, you will end up churning locks constantly. Additionally, you can still end up with race conditions since you're not actually locking across your entire request. Coalescing auto locks attempts to solve this problem by leaving your auto lock open after the first use. This "hanging lock" will be cleaned up at the end of the RR loop by the unlocker.


setCoalesceAutoLocks

public void setCoalesceAutoLocks(boolean value)
Sets whether or not coalescing auto locks should be enabled.


creationTrace

public java.lang.Exception creationTrace()
If traceOpenEditingContextLocks is true, returns the stack trace from when this EC was created


openLockTraces

public com.webobjects.foundation.NSDictionary<java.lang.Thread,com.webobjects.foundation.NSMutableArray<java.lang.Exception>> openLockTraces()
If traceOpenEditingContextLocks is true, returns the stack trace from when this EC was locked


lock

public void lock()
Overridden to emit log messages and push this instance to the locked editing contexts in this thread.

Specified by:
lock in interface com.webobjects.foundation.NSLocking
Overrides:
lock in class com.webobjects.eocontrol.EOEditingContext

unlock

public void unlock()
Overridden to emit log messages and pull this instance from the locked editing contexts in this thread.

Specified by:
unlock in interface com.webobjects.foundation.NSLocking
Overrides:
unlock in class com.webobjects.eocontrol.EOEditingContext

autoLock

protected boolean autoLock(java.lang.String method)
Utility to actually emit the log messages and do the locking, based on the result of useAutoLock().

Parameters:
method - method name which to prepend to log message
Returns:
whether we did lock automatically

autoUnlock

protected void autoUnlock(boolean wasAutoLocked)
Utility to unlock the EC is it was locked in the previous invocation.

Parameters:
wasAutoLocked - true if the EC was autolocked

isAutoLocked

public boolean isAutoLocked()
Returns whether we did autolock this instance.

Returns:
true if we were autolocked.

_checkOpenLockTraces

protected void _checkOpenLockTraces()

dispose

public void dispose()
Specified by:
dispose in interface com.webobjects.foundation.NSDisposable
Overrides:
dispose in class com.webobjects.eocontrol.EOEditingContext

finalize

public void finalize()
              throws java.lang.Throwable
Overrides:
finalize in class com.webobjects.eocontrol.EOEditingContext
Throws:
java.lang.Throwable

lockObjectStore

public void lockObjectStore()
Overrides:
lockObjectStore in class com.webobjects.eocontrol.EOEditingContext

unlockObjectStore

public void unlockObjectStore()
Overrides:
unlockObjectStore in class com.webobjects.eocontrol.EOEditingContext

reset

public void reset()
Overrides:
reset in class com.webobjects.eocontrol.EOEditingContext

recordObject

public void recordObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject,
                         com.webobjects.eocontrol.EOGlobalID eoglobalid)
Overrides:
recordObject in class com.webobjects.eocontrol.EOEditingContext

forgetObject

public void forgetObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
Overrides:
forgetObject in class com.webobjects.eocontrol.EOEditingContext

processRecentChanges

public void processRecentChanges()
Overrides:
processRecentChanges in class com.webobjects.eocontrol.EOEditingContext

updatedObjects

public com.webobjects.foundation.NSArray updatedObjects()
Overrides:
updatedObjects in class com.webobjects.eocontrol.EOEditingContext

registeredObjects

public com.webobjects.foundation.NSArray registeredObjects()
Overrides:
registeredObjects in class com.webobjects.eocontrol.EOEditingContext

insertedObjects

public com.webobjects.foundation.NSArray insertedObjects()
Overrides:
insertedObjects in class com.webobjects.eocontrol.EOEditingContext

deletedObjects

public com.webobjects.foundation.NSArray deletedObjects()
Overrides:
deletedObjects in class com.webobjects.eocontrol.EOEditingContext

setSharedEditingContext

public void setSharedEditingContext(com.webobjects.eocontrol.EOSharedEditingContext eosharededitingcontext)
Overrides:
setSharedEditingContext in class com.webobjects.eocontrol.EOEditingContext

objectForGlobalID

public com.webobjects.eocontrol.EOEnterpriseObject objectForGlobalID(com.webobjects.eocontrol.EOGlobalID eoglobalid)
Overrides:
objectForGlobalID in class com.webobjects.eocontrol.EOEditingContext

globalIDForObject

public com.webobjects.eocontrol.EOGlobalID globalIDForObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
Overrides:
globalIDForObject in class com.webobjects.eocontrol.EOEditingContext

committedSnapshotForObject

public com.webobjects.foundation.NSDictionary committedSnapshotForObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
Overrides:
committedSnapshotForObject in class com.webobjects.eocontrol.EOEditingContext

currentEventSnapshotForObject

public com.webobjects.foundation.NSDictionary currentEventSnapshotForObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
Overrides:
currentEventSnapshotForObject in class com.webobjects.eocontrol.EOEditingContext

objectWillChange

public void objectWillChange(java.lang.Object obj)
Specified by:
objectWillChange in interface com.webobjects.eocontrol.EOObserving
Overrides:
objectWillChange in class com.webobjects.eocontrol.EOEditingContext

insertObjectWithGlobalID

public void insertObjectWithGlobalID(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject,
                                     com.webobjects.eocontrol.EOGlobalID eoglobalid)
Overrides:
insertObjectWithGlobalID in class com.webobjects.eocontrol.EOEditingContext

insertObject

public void insertObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
Overrides:
insertObject in class com.webobjects.eocontrol.EOEditingContext

deleteObject

public void deleteObject(com.webobjects.eocontrol.EOEnterpriseObject eo)
Overridden to support autoLocking and to call mightDelete() on subclasses of ERXEnterpriseObject.

Overrides:
deleteObject in class com.webobjects.eocontrol.EOEditingContext

hasChanges

public boolean hasChanges()
Overrides:
hasChanges in class com.webobjects.eocontrol.EOEditingContext

willSaveChanges

protected void willSaveChanges(com.webobjects.foundation.NSArray insertedObjects,
                               com.webobjects.foundation.NSArray updatedObjects,
                               com.webobjects.foundation.NSArray deletedObjects)

didSaveChanges

protected void didSaveChanges(com.webobjects.foundation.NSArray insertedObjects,
                              com.webobjects.foundation.NSArray updatedObjects,
                              com.webobjects.foundation.NSArray deletedObjects)

saveChanges

public void saveChanges()
Smarter version of normal saveChanges() method. Overridden to support autoLocking and a bugfix from Lenny Marks, calls up Will/Did methods on ERXEnterpriseObjects and corrects issues with flushCaches() needing to be called on objects in the parent context when committing the child context to the parent. If the editing context is a child of the object-store coordinator---that is, it's not a nested context---this method behaves exactly the same as EOEditingContext.saveChanges(). Otherwise, this method looks over the changed objects in ec (updatedObjects(), insertedObjects() and deletedObjects()). The changed objects lists are filtered for instances of ERXGenericRecord. The order of operations then becomes:
  1. Call processRecentChanges() on the child context to propagate changes.
  2. Lock the parent editing context.
  3. On the deleted objects list in the child editing context, call flushCaches() on each corresponding EO in the parent context.
  4. Unlock the parent editing context.
  5. Call saveChanges() on the child, committing the child changes to the parent editing context.
  6. Lock the parent editing context.
  7. On the objects that were updated or inserted in the child, call flushCaches() on each corresponding EO in the parent context.
  8. Unlock the parent editing context.

The order of operations is a bit peculiar: flush deletes, save, flush inserts and updates. This is done because deletes must be flushed because there may be dependent computed state that needs to be reset. But following the delete being committed, the relationships to other objects cannot be relied upon so it isn't reliable to call flushCaches after the commit. It's not entirely correct to flush the deletes like this, but it's the best we can do.

This works around an issue in EOF that we don't get a merge notification when a child EC saves to its parent. Because there's no merge notification, flushCaches() isn't called by the EC delegate and we're essentially screwed vis-a-vis resetting computed state.

This method assumes that the ec is locked before this method is invoked, but this method will take the lock on the parent editing context if the ec is a nested context before and after the save in order to get the objects and to flush caches on them.

Overrides:
saveChanges in class com.webobjects.eocontrol.EOEditingContext

saveChangesTolerantly

public 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.

Parameters:
doesRetry - when true, saves again after resolving. when false, throws the optimistic locking after resolving
mergesChanges -

saveChangesTolerantly

public void saveChangesTolerantly()

saveChangesTolerantly

public void saveChangesTolerantly(boolean doesRetry)

setOptions

public void setOptions(boolean recoversFromException,
                       boolean doesRetry,
                       boolean mergesChanges)
Set the options for the saveChanges() operation.

Parameters:
recoversFromException -
doesRetry -
mergesChanges -

_saveChanges

protected void _saveChanges()

faultForGlobalID

public com.webobjects.eocontrol.EOEnterpriseObject faultForGlobalID(com.webobjects.eocontrol.EOGlobalID eoglobalid,
                                                                    com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
Overrides:
faultForGlobalID in class com.webobjects.eocontrol.EOEditingContext

arrayFaultWithSourceGlobalID

public com.webobjects.foundation.NSArray arrayFaultWithSourceGlobalID(com.webobjects.eocontrol.EOGlobalID eoglobalid,
                                                                      java.lang.String s,
                                                                      com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
Overrides:
arrayFaultWithSourceGlobalID in class com.webobjects.eocontrol.EOEditingContext

initializeObject

public void initializeObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject,
                             com.webobjects.eocontrol.EOGlobalID eoglobalid,
                             com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
Overrides:
initializeObject in class com.webobjects.eocontrol.EOEditingContext

editingContextDidForgetObjectWithGlobalID

public void editingContextDidForgetObjectWithGlobalID(com.webobjects.eocontrol.EOEditingContext eoeditingcontext,
                                                      com.webobjects.eocontrol.EOGlobalID eoglobalid)
Overrides:
editingContextDidForgetObjectWithGlobalID in class com.webobjects.eocontrol.EOEditingContext

objectsForSourceGlobalID

public com.webobjects.foundation.NSArray objectsForSourceGlobalID(com.webobjects.eocontrol.EOGlobalID eoglobalid,
                                                                  java.lang.String s,
                                                                  com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
Overrides:
objectsForSourceGlobalID in class com.webobjects.eocontrol.EOEditingContext

refaultObject

public void refaultObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
Overrides:
refaultObject in class com.webobjects.eocontrol.EOEditingContext

refaultObject

public void refaultObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject,
                          com.webobjects.eocontrol.EOGlobalID eoglobalid,
                          com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
Overridden to support autoLocking and to flush the cache of all ERXEnterpriseObjects.

Overrides:
refaultObject in class com.webobjects.eocontrol.EOEditingContext

objectsWithFetchSpecification

public com.webobjects.foundation.NSArray objectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification fs,
                                                                       com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
Overrides:
objectsWithFetchSpecification in class com.webobjects.eocontrol.EOEditingContext

saveChangesInEditingContext

public void saveChangesInEditingContext(com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
Overrides:
saveChangesInEditingContext in class com.webobjects.eocontrol.EOEditingContext

refaultAllObjects

public void refaultAllObjects()
Overrides:
refaultAllObjects in class com.webobjects.eocontrol.EOEditingContext

invalidateObjectsWithGlobalIDs

public void invalidateObjectsWithGlobalIDs(com.webobjects.foundation.NSArray nsarray)
Overrides:
invalidateObjectsWithGlobalIDs in class com.webobjects.eocontrol.EOEditingContext

invalidateAllObjects

public void invalidateAllObjects()
Overrides:
invalidateAllObjects in class com.webobjects.eocontrol.EOEditingContext

lockObject

public void lockObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
Overrides:
lockObject in class com.webobjects.eocontrol.EOEditingContext

revert

public void revert()
Overridden to support autoLocking and will/did revert delegate methods. *

Overrides:
revert in class com.webobjects.eocontrol.EOEditingContext

saveChanges

public void saveChanges(java.lang.Object obj)
Deprecated. 

Overrides:
saveChanges in class com.webobjects.eocontrol.EOEditingContext

refreshObject

public void refreshObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
Overrides:
refreshObject in class com.webobjects.eocontrol.EOEditingContext

undo

public void undo()
Overrides:
undo in class com.webobjects.eocontrol.EOEditingContext

redo

public void redo()
Overrides:
redo in class com.webobjects.eocontrol.EOEditingContext

invokeRemoteMethod

public java.lang.Object invokeRemoteMethod(com.webobjects.eocontrol.EOEditingContext eoeditingcontext,
                                           com.webobjects.eocontrol.EOGlobalID eoglobalid,
                                           java.lang.String s,
                                           java.lang.Class[] aclass,
                                           java.lang.Object[] aobj)
Overrides:
invokeRemoteMethod in class com.webobjects.eocontrol.EOEditingContext

_objectsChangedInStore

public void _objectsChangedInStore(com.webobjects.foundation.NSNotification nsnotification)
Overridden so add a bugfix from Lenny Marks

Overrides:
_objectsChangedInStore in class com.webobjects.eocontrol.EOEditingContext

_processObjectStoreChanges

public void _processObjectStoreChanges(com.webobjects.foundation.NSDictionary info)
Quick and experimental hack to hook into the merge-changes system. If it's not useful, it should be removed again.

Overrides:
_processObjectStoreChanges in class com.webobjects.eocontrol.EOEditingContext

setDelegate

public void setDelegate(java.lang.Object d)
Sets the delegate for this context.

Overrides:
setDelegate in class com.webobjects.eocontrol.EOEditingContext

factory

public static ERXEC.Factory factory()
Gets the factory used to create editing contexts

Returns:
editing context factory

setFactory

public static void setFactory(ERXEC.Factory aFactory)
Sets the default editing context factory

Parameters:
aFactory - factory used to create editing contexts

newEditingContext

public static com.webobjects.eocontrol.EOEditingContext newEditingContext()
Factory method to create a new editing context. Sets the current default delegate on the newly created editing context.

Returns:
a newly created editing context with the default delegate set.

newTolerantEditingContext

public static com.webobjects.eocontrol.EOEditingContext newTolerantEditingContext(com.webobjects.eocontrol.EOObjectStore parent,
                                                                                  boolean retry,
                                                                                  boolean merge)
Factory method to create a new tolerant editing context.


newTolerantEditingContext

public static com.webobjects.eocontrol.EOEditingContext newTolerantEditingContext()

newTolerantEditingContext

public static com.webobjects.eocontrol.EOEditingContext newTolerantEditingContext(com.webobjects.eocontrol.EOObjectStore osc)

saveChangesTolerantly

public static void saveChangesTolerantly(com.webobjects.eocontrol.EOEditingContext ec,
                                         boolean doesRetry,
                                         boolean mergesChanges)

saveChangesTolerantly

public static void saveChangesTolerantly(com.webobjects.eocontrol.EOEditingContext ec)

newEditingContext

public static com.webobjects.eocontrol.EOEditingContext newEditingContext(com.webobjects.eocontrol.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. This method is useful when creating nested editing contexts. After creating the editing context the default delegate is set on the editing context if validation is enabled or the default no validation delegate is set if validation is disabled.

Note: an EOEditingContext is a subclass of EOObjectStore so passing in another editing context to this method is completely kosher.

Parameters:
parent - object store for the newly created editing context.
validationEnabled - determines if the editing context should perform validation
Returns:
new editing context with the given parent object store and the delegate corresponding to the validation flag

newEditingContext

public static com.webobjects.eocontrol.EOEditingContext newEditingContext(boolean validation)
Factory method to create a new editing context with validation disabled. Sets the default no validation delegate on the editing context. Be careful - an editing context that does not perform validation means that none of the usual validation methods are called on the enterprise objects before they are saved to the database.

Parameters:
validation - flag that determines if validation should or should not be enabled.
Returns:
a newly created editing context with a delegate set that has disabled validation.

newEditingContext

public static com.webobjects.eocontrol.EOEditingContext newEditingContext(com.webobjects.eocontrol.EOObjectStore objectStore)
Creates a new editing context with the specified object store as the parent object store. This method is useful when creating nested editing contexts. After creating the editing context the default delegate is set on the editing context.

Note: an EOEditingContext is a subclass of EOObjectStore so passing in another editing context to this method is completely kosher.

Parameters:
objectStore - parent object store for the newly created editing context.
Returns:
new editing context with the given parent object store

registerOpenEditingContextLockSignalHandler

public static void registerOpenEditingContextLockSignalHandler()
Register the OpenEditingContextLockSignalHandler signal handle on the HUP signal.


registerOpenEditingContextLockSignalHandler

public static void registerOpenEditingContextLockSignalHandler(java.lang.String signalName)
Register the OpenEditingContextLockSignalHandler signal handle on the named signal.

Parameters:
signalName - the name of the signal to handle

outstandingLockDescription

public static java.lang.String outstandingLockDescription()
Returns a string describing outstanding locks for the created ECs

Returns:
description of locks

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.