public class ERXEC
extends com.webobjects.eocontrol.EOEditingContext
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()
or use the
er.extensions.ERXEC.editingContextClassName property to specify the name of the
editing context class to be instantiated by ERXEC.DefaultFactory's
_createEditingContext() core method.Name | Description |
---|---|
er.extensions.ERXEC.useSharedEditingContext | er.extensions.ERXEC.useSharedEditingContext |
er.extensions.ERXEC.markOpenLocks | er.extensions.ERXEC.markOpenLocks |
er.extensions.ERXEC.traceOpenLocks | er.extensions.ERXEC.traceOpenLocks |
er.extensions.ERXEC.useUnlocker | er.extensions.ERXEC.useUnlocker |
er.extensions.ERXEC.denyMerges | er.extensions.ERXEC.denyMerges |
er.extensions.ERXEC.defaultAutomaticLockUnlock | er.extensions.ERXEC.defaultAutomaticLockUnlock |
er.extensions.ERXEC.defaultCoalesceAutoLocks | er.extensions.ERXEC.defaultCoalesceAutoLocks |
er.extensions.ERXEC.safeLocking | er.extensions.ERXEC.safeLocking |
er.extensions.ERXEC.editingContextClassName | er.extensions.ERXEC.editingContextClassName |
Modifier and Type | Class and Description |
---|---|
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 |
com.webobjects.eocontrol.EOEditingContext._EventLoggingEnabler, com.webobjects.eocontrol.EOEditingContext.EditingContextEvent, com.webobjects.eocontrol.EOEditingContext.Editor, com.webobjects.eocontrol.EOEditingContext.MessageHandler
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
Modifier and Type | Field and Description |
---|---|
static boolean |
_shouldLockOnLockObjectStore
Technically, the OSC is public API and as such should also get
auto-locked.
|
protected static Map<ERXEC,String> |
activeEditingContexts |
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.
|
static com.webobjects.foundation.NSSelector |
ERXECProcessQueuedNotificationsSelector |
protected static ERXEC.Factory |
factory
holds a reference to the factory used to create editing contexts
|
static org.slf4j.Logger |
lockLogger
Logs a message when set to DEBUG and an EC is locked/unlocked.
|
static org.slf4j.Logger |
lockTrace
Logs a message with trace when set to DEBUG if autoLocking is enabled and an EC is
used without a lock.
|
_CLASS, _EditingContextDidChangeSharedEditingContextNotification, _EditingContextEditorHasChangesNotification, _IsEventLoggingEnabled, EditingContextDidSaveChangesNotification, EditingContextFlushChangesRunLoopOrdering, ObjectsChangedInEditingContextNotification
Constructor and Description |
---|
ERXEC() |
ERXEC(com.webobjects.eocontrol.EOObjectStore os) |
Modifier and Type | Method and Description |
---|---|
protected void |
_checkOpenLockTraces() |
static ERXEC.Factory |
_factory()
Gets the factory used to create editing contexts
|
void |
_objectsChangedInStore(com.webobjects.foundation.NSNotification nsnotification)
Overridden so add a bugfix from Lenny Marks
|
void |
_processObjectStoreChanges(NSDictionary info)
Quick and experimental hack to hook into the merge-changes system.
|
protected void |
_saveChanges() |
NSArray |
arrayFaultWithSourceGlobalID(com.webobjects.eocontrol.EOGlobalID eoglobalid,
String s,
com.webobjects.eocontrol.EOEditingContext eoeditingcontext) |
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(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject) |
Exception |
creationTrace()
If traceOpenEditingContextLocks is true, returns the stack trace from
when this EC was created
|
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. |
NSArray<com.webobjects.eocontrol.EOEnterpriseObject> |
deletedObjects() |
void |
deleteObject(com.webobjects.eocontrol.EOEnterpriseObject eo)
Overridden 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() |
static String |
editingContextClassName() |
void |
editingContextDidForgetObjectWithGlobalID(com.webobjects.eocontrol.EOEditingContext eoeditingcontext,
com.webobjects.eocontrol.EOGlobalID eoglobalid) |
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) |
NSArray<com.webobjects.eocontrol.EOEnterpriseObject> |
insertedObjects() |
void |
insertObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject) |
void |
insertObjectWithGlobalID(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject,
com.webobjects.eocontrol.EOGlobalID eoglobalid) |
void |
invalidateAllObjects() |
void |
invalidateObjectsWithGlobalIDs(NSArray nsarray) |
Object |
invokeRemoteMethod(com.webobjects.eocontrol.EOEditingContext eoeditingcontext,
com.webobjects.eocontrol.EOGlobalID eoglobalid,
String s,
Class[] aclass,
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) |
NSArray |
objectsForSourceGlobalID(com.webobjects.eocontrol.EOGlobalID eoglobalid,
String s,
com.webobjects.eocontrol.EOEditingContext eoeditingcontext) |
NSArray |
objectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification fs,
com.webobjects.eocontrol.EOEditingContext eoeditingcontext) |
void |
objectWillChange(Object obj) |
NSDictionary<Thread,NSMutableArray<Exception>> |
openLockTraces() |
static 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 |
processQueuedNotificationsNotification(com.webobjects.foundation.NSNotification n) |
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) |
NSArray |
registeredObjects() |
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() |
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 |
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(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() |
NSArray<com.webobjects.eocontrol.EOEnterpriseObject> |
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(NSArray insertedObjects,
NSArray updatedObjects,
NSArray deletedObjects) |
_clearChangedThisTransaction, _clearOriginalSnapshotAndInitializeRec, _clearOriginalSnapshotForObject, _defaultEditingContextNowInitialized, _defaultSharedEditingContextWasInitialized, _editorHasChanges, _EOAssertSafeMultiThreadedAccess, _EOAssertSafeMultiThreadedAccess, _EOAssertSafeMultiThreadedReadAccess, _globalIDChanged, _globalIDsForObjects, _initWithParentObjectStore, _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, saveChanges, setDefaultFetchTimestampLag, setDefaultParentObjectStore, setFetchTimestamp, setInstancesRetainRegisteredObjects, setInvalidatesObjectsWhenFinalized, setLocksObjectsBeforeFirstModification, setMessageHandler, setPropagatesDeletesAtEndOfEvent, setRetainsRegisteredObjects, setStopsValidationAfterFirstError, setSubstitutionEditingContext, setUndoManager, setUsesContextRelativeEncoding, sharedEditingContext, stopsValidationAfterFirstError, substitutionEditingContext, tryLock, tryToSaveChanges, undoManager, usesContextRelativeEncoding
public static final org.slf4j.Logger lockLogger
lockTrace
is also set to DEBUG.public static final org.slf4j.Logger lockTrace
lockLogger
if it is also set to DEBUG.public static final String EditingContextDidCreateNotification
public static final String EditingContextWillSaveChangesNotification
public static final String EditingContextDidRevertChanges
public static final String EditingContextFailedToSaveChanges
public static final com.webobjects.foundation.NSSelector ERXECProcessQueuedNotificationsSelector
public static boolean _shouldLockOnLockObjectStore
protected static volatile ERXEC.Factory factory
public ERXEC()
public ERXEC(com.webobjects.eocontrol.EOObjectStore os)
public static String editingContextClassName()
er.extensions.ERXEC.editingContextClassName
property, which
is the name of the editing context class instantiated by ERXEC.DefaultFactory's _createEditingContext()
core method. It defaults to the name of the ERXEC class.public static boolean safeLocking()
er.extensions.ERXEC.safeLocking
property, which is the
new catch-all setting that turns on all of the recommended locking settings.er.extensions.ERXEC.safeLocking
propertypublic static boolean defaultAutomaticLockUnlock()
er.extensions.ERXEC.defaultAutomaticLockUnlock
property, which
turns on auto-locking by default. Also returns true if safeLocking
is true.er.extensions.ERXEC.defaultAutomaticLockUnlock
propertypublic static boolean defaultCoalesceAutoLocks()
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.er.extensions.ERXEC.defaultCoalesceAutoLocks
propertypublic static boolean useUnlocker()
er.extensions.ERXEC.useUnlocker
property, which
turns on unlocking at the end of the RR loop.
Also returns true if safeLocking
is true.er.extensions.ERXEC.useUnlocker
propertypublic static void setUseUnlocker(boolean value)
public static boolean traceOpenLocks()
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
.er.extensions.ERXEC.traceOpenLocks
propertypublic static boolean markOpenLocks()
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.er.extensions.ERXEC.markOpenLocks
propertypublic static void setTraceOpenLocks(boolean value)
value
- if open locks should be tracedpublic static void setMarkOpenLocks(boolean value)
value
- if open locks should be markedpublic static void pushLockedContextForCurrentThread(com.webobjects.eocontrol.EOEditingContext ec)
ec
- locked EOEditingContextpublic static void popLockedContextForCurrentThread(com.webobjects.eocontrol.EOEditingContext ec)
ec
- unlocked EOEditingContextpublic static void unlockAllContextsForCurrentThread()
public void deleteObjects(NSArray objects)
objects
- objects to deletepublic boolean useAutoLock()
public void setUseAutoLock(boolean value)
value
- if autolocking should be usedpublic boolean coalesceAutoLocks()
public void setCoalesceAutoLocks(boolean value)
value
- if coalescing auto locks should be enabledpublic Exception creationTrace()
public NSDictionary<Thread,NSMutableArray<Exception>> openLockTraces()
public void lock()
lock
in interface com.webobjects.foundation.NSLocking
lock
in class com.webobjects.eocontrol.EOEditingContext
public void unlock()
unlock
in interface com.webobjects.foundation.NSLocking
unlock
in class com.webobjects.eocontrol.EOEditingContext
protected boolean autoLock(String method)
useAutoLock()
.method
- method name which to prepend to log messageprotected void autoUnlock(boolean wasAutoLocked)
wasAutoLocked
- true if the EC was autolockedpublic boolean isAutoLocked()
protected void _checkOpenLockTraces()
public void dispose()
dispose
in interface com.webobjects.foundation.NSDisposable
dispose
in class com.webobjects.eocontrol.EOEditingContext
public void finalize() throws Throwable
finalize
in class com.webobjects.eocontrol.EOEditingContext
Throwable
public void lockObjectStore()
lockObjectStore
in class com.webobjects.eocontrol.EOEditingContext
public void unlockObjectStore()
unlockObjectStore
in class com.webobjects.eocontrol.EOEditingContext
public void reset()
reset
in class com.webobjects.eocontrol.EOEditingContext
public void recordObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject, com.webobjects.eocontrol.EOGlobalID eoglobalid)
recordObject
in class com.webobjects.eocontrol.EOEditingContext
public void forgetObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
forgetObject
in class com.webobjects.eocontrol.EOEditingContext
public void processRecentChanges()
processRecentChanges
in class com.webobjects.eocontrol.EOEditingContext
public NSArray<com.webobjects.eocontrol.EOEnterpriseObject> updatedObjects()
updatedObjects
in class com.webobjects.eocontrol.EOEditingContext
public NSArray registeredObjects()
registeredObjects
in class com.webobjects.eocontrol.EOEditingContext
public NSArray<com.webobjects.eocontrol.EOEnterpriseObject> insertedObjects()
insertedObjects
in class com.webobjects.eocontrol.EOEditingContext
public NSArray<com.webobjects.eocontrol.EOEnterpriseObject> deletedObjects()
deletedObjects
in class com.webobjects.eocontrol.EOEditingContext
public void setSharedEditingContext(com.webobjects.eocontrol.EOSharedEditingContext eosharededitingcontext)
setSharedEditingContext
in class com.webobjects.eocontrol.EOEditingContext
public com.webobjects.eocontrol.EOEnterpriseObject objectForGlobalID(com.webobjects.eocontrol.EOGlobalID eoglobalid)
objectForGlobalID
in class com.webobjects.eocontrol.EOEditingContext
public com.webobjects.eocontrol.EOGlobalID globalIDForObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
globalIDForObject
in class com.webobjects.eocontrol.EOEditingContext
public NSDictionary committedSnapshotForObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
committedSnapshotForObject
in class com.webobjects.eocontrol.EOEditingContext
public NSDictionary currentEventSnapshotForObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
currentEventSnapshotForObject
in class com.webobjects.eocontrol.EOEditingContext
public void objectWillChange(Object obj)
objectWillChange
in interface com.webobjects.eocontrol.EOObserving
objectWillChange
in class com.webobjects.eocontrol.EOEditingContext
public void insertObjectWithGlobalID(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject, com.webobjects.eocontrol.EOGlobalID eoglobalid)
insertObjectWithGlobalID
in class com.webobjects.eocontrol.EOEditingContext
public void insertObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
insertObject
in class com.webobjects.eocontrol.EOEditingContext
public void deleteObject(com.webobjects.eocontrol.EOEnterpriseObject eo)
deleteObject
in class com.webobjects.eocontrol.EOEditingContext
public boolean hasChanges()
hasChanges
in class com.webobjects.eocontrol.EOEditingContext
protected void willSaveChanges(NSArray insertedObjects, NSArray updatedObjects, NSArray deletedObjects)
protected void didSaveChanges(NSArray insertedObjects, NSArray updatedObjects, NSArray deletedObjects)
public void saveChanges()
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:
processRecentChanges()
on the child context to
propagate changes.
flushCaches()
on each corresponding EO in the parent
context.
saveChanges()
on the child, committing the child
changes to the parent editing context.
flushCaches()
on each corresponding EO in the parent
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.
saveChanges
in class com.webobjects.eocontrol.EOEditingContext
public void saveChangesTolerantly(boolean doesRetry, boolean mergesChanges)
doesRetry
- when true, saves again after resolving. when false, throws the
optimistic locking after resolvingmergesChanges
- public void saveChangesTolerantly()
public void saveChangesTolerantly(boolean doesRetry)
public void setOptions(boolean recoversFromException, boolean doesRetry, boolean mergesChanges)
recoversFromException
- doesRetry
- when true, saves again after resolving. when false, throws the
optimistic locking after resolvingmergesChanges
- protected void _saveChanges()
public com.webobjects.eocontrol.EOEnterpriseObject faultForGlobalID(com.webobjects.eocontrol.EOGlobalID eoglobalid, com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
faultForGlobalID
in class com.webobjects.eocontrol.EOEditingContext
public NSArray arrayFaultWithSourceGlobalID(com.webobjects.eocontrol.EOGlobalID eoglobalid, String s, com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
arrayFaultWithSourceGlobalID
in class com.webobjects.eocontrol.EOEditingContext
public void initializeObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject, com.webobjects.eocontrol.EOGlobalID eoglobalid, com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
initializeObject
in class com.webobjects.eocontrol.EOEditingContext
public void editingContextDidForgetObjectWithGlobalID(com.webobjects.eocontrol.EOEditingContext eoeditingcontext, com.webobjects.eocontrol.EOGlobalID eoglobalid)
editingContextDidForgetObjectWithGlobalID
in class com.webobjects.eocontrol.EOEditingContext
public NSArray objectsForSourceGlobalID(com.webobjects.eocontrol.EOGlobalID eoglobalid, String s, com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
objectsForSourceGlobalID
in class com.webobjects.eocontrol.EOEditingContext
public void refaultObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
refaultObject
in class com.webobjects.eocontrol.EOEditingContext
public void refaultObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject, com.webobjects.eocontrol.EOGlobalID eoglobalid, com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
refaultObject
in class com.webobjects.eocontrol.EOEditingContext
public NSArray objectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification fs, com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
objectsWithFetchSpecification
in class com.webobjects.eocontrol.EOEditingContext
public void saveChangesInEditingContext(com.webobjects.eocontrol.EOEditingContext eoeditingcontext)
saveChangesInEditingContext
in class com.webobjects.eocontrol.EOEditingContext
public void refaultAllObjects()
refaultAllObjects
in class com.webobjects.eocontrol.EOEditingContext
public void invalidateObjectsWithGlobalIDs(NSArray nsarray)
invalidateObjectsWithGlobalIDs
in class com.webobjects.eocontrol.EOEditingContext
public void invalidateAllObjects()
invalidateAllObjects
in class com.webobjects.eocontrol.EOEditingContext
public void lockObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
lockObject
in class com.webobjects.eocontrol.EOEditingContext
public void revert()
revert
in class com.webobjects.eocontrol.EOEditingContext
public void refreshObject(com.webobjects.eocontrol.EOEnterpriseObject eoenterpriseobject)
refreshObject
in class com.webobjects.eocontrol.EOEditingContext
public void undo()
undo
in class com.webobjects.eocontrol.EOEditingContext
public void redo()
redo
in class com.webobjects.eocontrol.EOEditingContext
public Object invokeRemoteMethod(com.webobjects.eocontrol.EOEditingContext eoeditingcontext, com.webobjects.eocontrol.EOGlobalID eoglobalid, String s, Class[] aclass, Object[] aobj)
invokeRemoteMethod
in class com.webobjects.eocontrol.EOEditingContext
public void _objectsChangedInStore(com.webobjects.foundation.NSNotification nsnotification)
_objectsChangedInStore
in class com.webobjects.eocontrol.EOEditingContext
public void _processObjectStoreChanges(NSDictionary info)
_processObjectStoreChanges
in class com.webobjects.eocontrol.EOEditingContext
public void processQueuedNotificationsNotification(com.webobjects.foundation.NSNotification n)
public void setDelegate(Object d)
setDelegate
in class com.webobjects.eocontrol.EOEditingContext
public static ERXEC.Factory _factory()
public static void setFactory(ERXEC.Factory aFactory)
aFactory
- factory used to create editing contextspublic static com.webobjects.eocontrol.EOEditingContext newEditingContext()
public static com.webobjects.eocontrol.EOEditingContext newTolerantEditingContext(com.webobjects.eocontrol.EOObjectStore parent, boolean retry, boolean merge)
parent
- the parent object storeretry
- true if the ec should retry on failed savemerge
- true if ec changes should be mergedpublic static com.webobjects.eocontrol.EOEditingContext newTolerantEditingContext()
public static com.webobjects.eocontrol.EOEditingContext newTolerantEditingContext(com.webobjects.eocontrol.EOObjectStore osc)
public static void saveChangesTolerantly(com.webobjects.eocontrol.EOEditingContext ec, boolean doesRetry, boolean mergesChanges)
public static void saveChangesTolerantly(com.webobjects.eocontrol.EOEditingContext ec)
public static com.webobjects.eocontrol.EOEditingContext newEditingContext(com.webobjects.eocontrol.EOObjectStore parent, boolean validationEnabled)
Note:
an EOEditingContext
is
a subclass of EOObjectStore so passing in another editing context to this
method is completely kosher.
parent
- object store for the newly created editing context.validationEnabled
- determines if the editing context should perform validationpublic static com.webobjects.eocontrol.EOEditingContext newEditingContext(boolean validation)
validation
- flag that determines if validation should or should not be
enabled.public static com.webobjects.eocontrol.EOEditingContext newEditingContext(com.webobjects.eocontrol.EOObjectStore objectStore)
Note: an EOEditingContext
is
a subclass of EOObjectStore so passing in another editing context to this
method is completely kosher.
objectStore
- parent object store for the newly created editing context.public static void registerOpenEditingContextLockSignalHandler()
public static void registerOpenEditingContextLockSignalHandler(String signalName)
signalName
- the name of the signal to handlepublic static String outstandingLockDescription()
Copyright © 2002 – 2020 Project Wonder.