WebObjects 5.4.2

com.webobjects.eocontrol
Class EOSharedEditingContext

java.lang.Object
  extended by com.webobjects.eocontrol.EOObjectStore
      extended by com.webobjects.eocontrol.EOEditingContext
          extended by com.webobjects.eocontrol.EOSharedEditingContext
All Implemented Interfaces:
EOKeyValueArchiving, EOObserving, NSDisposable, NSLocking, Serializable

public class EOSharedEditingContext
extends EOEditingContext

The EOSharedEditingContext class defines a mechanism that allows EOEditingContexts to share enterprise objects for reading. This mechanism can reduce redundant data and the number of fetches an application requires.

Shared enterprise objects are read-only and persist for the life of the application; they can't be modified or deleted. They must be unique in the shared context and across all other editing contexts that share objects from the shared context.

Objects can be fetched into a shared context using objectsWithFetchSpecification and bindObjectsWithFetchSpecification. The latter method makes it easier to access result sets, using objectsByEntityNameAndFetchSpecificationName.

In multithreaded applications, shared objects can be used safely by many threads at once. Shared editing contexts use NSMultiReaderLocks to maintain thread safety. The methods objectsWithFetchSpecification bindObjectsWithFetchSpecification, faultForGlobalID, and objectForGlobalID are thread safe, but the context must be locked before using any other shared context API.

It is possible to modify shared objects while an application is running, but only indirectly. A regular editing context can be created that doesn't share objects by setting it's sharedEditingContext to null. Fetch the object that is to be changed into the regular context, modify or delete it, and save. Since shared editing contexts listen for ObjectsChangedInStoreNotifications, the shared editing context updates when it learns that an object was modified. The shared context removes from its objectsByEntityName and objectsByEntityNameAndFetchSpecificationName dictionaries any objects that have been deleted, and it refaults any objects that have been updated. However, to register newly inserted objects in the shared editing context, it should be refetched.

See Also:
EOSharedEditingContext.objectsByEntityName(), EOSharedEditingContext.objectsByEntityNameAndFetchSpecificationName(), EOSharedEditingContext.bindObjectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification, java.lang.String), EOSharedEditingContext.objectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification, com.webobjects.eocontrol.EOEditingContext), EOSharedEditingContext.DefaultSharedEditingContextWasInitializedNotification, EOSharedEditingContext.SharedEditingContextInitializedObjectsNotification, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.webobjects.eocontrol.EOEditingContext
EOEditingContext.Delegate, EOEditingContext.EditingContextEvent, EOEditingContext.Editor, EOEditingContext.MessageHandler
 
Nested classes/interfaces inherited from interface com.webobjects.eocontrol.EOKeyValueArchiving
EOKeyValueArchiving.Awaking, EOKeyValueArchiving.FinishInitialization, EOKeyValueArchiving.Support
 
Field Summary
static String DefaultSharedEditingContextWasInitializedNotification
          Posted when an EOSharedEditingContext is created and assigned as the default shared editing context.
static String SharedEditingContextInitializedObjectsNotification
          Posted when new objects are added to a shared editing context (by fetching or fault firing).
 
Fields inherited from class com.webobjects.eocontrol.EOEditingContext
EditingContextDidSaveChangesNotification, EditingContextFlushChangesRunLoopOrdering, ObjectsChangedInEditingContextNotification
 
Fields inherited from class com.webobjects.eocontrol.EOObjectStore
DeletedKey, InsertedKey, InvalidatedAllObjectsInStoreNotification, InvalidatedKey, ObjectsChangedInStoreNotification, UpdatedKey
 
Fields inherited from interface com.webobjects.foundation.NSLocking
OneCentury, OneDay, OneHour, OneMinute, OneSecond, OneWeek, OneYear
 
Constructor Summary
EOSharedEditingContext()
          Creates a new EOSharedEditingContext object with the default parent object store as its parent object store.
EOSharedEditingContext(EOObjectStore parent)
          Creates a new EOSharedEditingContext with a specified EOObjectStoreCoordinator as the parent EOObjectStore.
 
Method Summary
 void bindObjectsWithFetchSpecification(EOFetchSpecification fetchSpecification, String fetchSpecificationName)
          Fetches objects with fetchSpecification and binds the results to fetchSpecification's entity and fetchSpecification's name, which is provided with the fetchSpecificationName argument.
static EOSharedEditingContext defaultSharedEditingContext()
          If a shared context hasn't yet been created, this method creates one and posts a DefaultSharedEditingContextWasInitializedNotification.
 NSArray deletedObjects()
          The shared objects in a shared editing context can't be deleted.
 void deleteObject(EOEnterpriseObject object)
          Raises an exception.
 void dispose()
          Invoked when the receiver should prepare itself for destruction.
 EOEnterpriseObject faultForGlobalID(EOGlobalID gid, EOEditingContext editingContext)
          Overrides the implementation inherited from EOObjectStore.
 void forgetObject(EOEnterpriseObject object)
          Removes object from the uniquing tables and causes this EOEditingContext to remove itself from the object's list of observers.
 EOGlobalID globalIDForObject(EOEnterpriseObject object)
          Returns the EOGlobalID associated with object in this EOEditingContext or its shared context.
 boolean hasChanges()
          Shared objects in a shared editing context cannot be modified or be deleted.
 void initializeObject(EOEnterpriseObject object, EOGlobalID gid, EOEditingContext editingContext)
          Overrides the implementation inherited from EOObjectStore to build the properties for the object identified by gid.
 NSArray insertedObjects()
          You can't insert objects into a shared editing context.
 void insertObject(EOEnterpriseObject object)
          Throws an exception.
 void insertObjectWithGlobalID(EOEnterpriseObject object, EOGlobalID gid)
          Throws an exception.
 void invalidateAllObjects()
          Overrides the implementation inherited from EOObjectStore to discard the values of objects cached in memory and refault them, which causes them to be refetched from the external store the next time they're accessed.
 void invalidateObjectsWithGlobalIDs(NSArray gids)
          Overrides the implementation inherited from EOObjectStore to signal to the parent object store that the cached values for the objects identified by globalIDs should no longer be considered valid and that they should be refaulted.
 void lock()
          Acquires a writer lock to this EOSharedEditingContext to prevent other threads from accessing it.
 void lockForReading()
          Locks the receiver for reading.
 void lockObjectStore()
           
 EOEnterpriseObject objectForGlobalID(EOGlobalID gid)
          Returns the EOEnterpriseObject associated with gid in this EOEditingContext or its shared context, or null if no such object exists.
 NSDictionary objectsByEntityName()
          The dictionary keys are entity names and the corresponding values are NSArrays of enterprise objects for that entity.
 NSDictionary objectsByEntityNameAndFetchSpecificationName()
          Returns the objects fetched into the receiver with bindObjectsWithFetchSpecification.
 NSArray objectsWithFetchSpecification(EOFetchSpecification fetchSpecification, EOEditingContext editingContext)
          A thread-safe version of the superclass implementation that binds the results to fetchSpecification's entity.
 void objectWillChange(Object object)
          Raises an exception.
 void refaultAllObjects()
          Refaults all objects cached in this EOEditingContext that have not been inserted, deleted, or updated.
 void refaultObject(EOEnterpriseObject object, EOGlobalID gid, EOEditingContext editingContext)
          Overrides the implementation inherited from EOObjectStore to refault the enterprise object object identified by gid in ctx.
 NSArray registeredObjects()
           
 void reset()
          Overrides the superclass implementation to do nothing.
 void retrieveReaderLocks()
          Reinstates the current thread's reader locks that have been suspended using suspendReaderLocks.
 void saveChanges()
          Raises an exception.
static void setDefaultSharedEditingContext(EOSharedEditingContext context)
          Sets the default shared editing context.
 void setSharedEditingContext(EOSharedEditingContext sharedEditingContext)
          Raises an exception unless sharedEditingContext is null.
 void setUndoManager(NSUndoManager undoManager)
          Raises an exception unless undoManager is null.
 EOSharedEditingContext sharedEditingContext()
          Always returns null
 void suspendReaderLocks()
          Temporarily relinquishes all of the current thread's reader locks, releasing the lock if all reader locks are unlocked.
 boolean tryLock()
          Attempts to take the lock on this EOSharedEditingContext for writing.
 boolean tryLockForReading()
          Attempts to take the lock on this EOSharedEditingContext for reading.
 void unlock()
          Releases a previously acquired lock for writing on this EOSharedEditingContext.
 void unlockForReading()
          Releases a previously acquired lock for reading on this EOSharedEditingContext.
 void unlockObjectStore()
           
 NSArray updatedObjects()
          Returns an empty array.
 void validateChangesForSave()
          Overrides the superclass implementation to do nothing.
 
Methods inherited from class com.webobjects.eocontrol.EOEditingContext
addEditor, arrayFaultWithSourceGlobalID, committedSnapshotForObject, currentEventSnapshotForObject, decodeWithKeyValueUnarchiver, defaultFetchTimestampLag, defaultParentObjectStore, delegate, editingContextDidForgetObjectWithGlobalID, editors, editorsHaveChanges, encodeObjectWithCoder, encodeWithKeyValueArchiver, faultForRawRow, faultForRawRow, fetchTimestamp, finalize, initObjectWithCoder, instancesRetainRegisteredObjects, invalidatesObjectsWhenFinalized, invokeRemoteMethod, isObjectLockedWithGlobalID, lockObject, lockObjectWithGlobalID, locksObjectsBeforeFirstModification, messageHandler, objectsForSourceGlobalID, objectsWithFetchSpecification, parentObjectStore, processRecentChanges, propagatesDeletesAtEndOfEvent, readResolve, recordObject, redo, refaultObject, refaultObjects, refetch, refreshAllObjects, refreshObject, removeEditor, retainsRegisteredObjects, revert, rootObjectStore, saveChanges, saveChangesInEditingContext, setDefaultFetchTimestampLag, setDefaultParentObjectStore, setDelegate, setFetchTimestamp, setInstancesRetainRegisteredObjects, setInvalidatesObjectsWhenFinalized, setLocksObjectsBeforeFirstModification, setMessageHandler, setPropagatesDeletesAtEndOfEvent, setRetainsRegisteredObjects, setStopsValidationAfterFirstError, setSubstitutionEditingContext, setUsesContextRelativeEncoding, stopsValidationAfterFirstError, substitutionEditingContext, tryToSaveChanges, undo, undoManager, usesContextRelativeEncoding
 
Methods inherited from class com.webobjects.eocontrol.EOObjectStore
setUserInfo, setUserInfoForKey, userInfo, userInfoForKey
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DefaultSharedEditingContextWasInitializedNotification

public static final String DefaultSharedEditingContextWasInitializedNotification
Posted when an EOSharedEditingContext is created and assigned as the default shared editing context.

Notification Object None
userInfo Dictionary None

See Also:
EOSharedEditingContext.defaultSharedEditingContext(), Constant Field Values

SharedEditingContextInitializedObjectsNotification

public static final String SharedEditingContextInitializedObjectsNotification
Posted when new objects are added to a shared editing context (by fetching or fault firing).

Notification Object The shared editing context
userInfo Dictionary NSArray of global IDs of the initialized objects

See Also:
Constant Field Values
Constructor Detail

EOSharedEditingContext

public EOSharedEditingContext(EOObjectStore parent)
Creates a new EOSharedEditingContext with a specified EOObjectStoreCoordinator as the parent EOObjectStore.

Parameters:
parent - must be an EOObjectStoreCoordinator
Throws:
IllegalArgumentException - if parent is not an object store coordinator
See Also:
EOSharedEditingContext.EOSharedEditingContext()

EOSharedEditingContext

public EOSharedEditingContext()
Creates a new EOSharedEditingContext object with the default parent object store as its parent object store.

See Also:
EOEditingContext.defaultParentObjectStore()
Method Detail

defaultSharedEditingContext

public static EOSharedEditingContext defaultSharedEditingContext()
If a shared context hasn't yet been created, this method creates one and posts a DefaultSharedEditingContextWasInitializedNotification.

Returns:
Returns the default EOSharedEditingContext.
See Also:
EOSharedEditingContext.DefaultSharedEditingContextWasInitializedNotification

setDefaultSharedEditingContext

public static void setDefaultSharedEditingContext(EOSharedEditingContext context)
Sets the default shared editing context. If context is null, object sharing is disabled in subsequently created EOEditingContexts.

This has no effect on previously created EOEditingContexts.

Parameters:
context - specifies container in which source object belong to

objectsByEntityName

public NSDictionary objectsByEntityName()
The dictionary keys are entity names and the corresponding values are NSArrays of enterprise objects for that entity.

Returns:
Returns a dictionary of all the objects fetched into the shared context.
See Also:
EOSharedEditingContext.bindObjectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification, java.lang.String)

objectsByEntityNameAndFetchSpecificationName

public NSDictionary objectsByEntityNameAndFetchSpecificationName()
Returns the objects fetched into the receiver with bindObjectsWithFetchSpecification. The return value is a dictionary whose keys are entity names and whose values are subdictionaries. The keys of the subdictionaries are fetch specification names, and the values are NSArrays of the enterprise objects fetched with the corresponding fetch specification. The fetch specification names are the names specified in bindObjectsWithFetchSpecification. Generally these names are the same names used to identify stored fetch specifications in EOModeler.
Note: The dictionary returned from this method might not contain all the receiver's shared objects. It only contains objects fetched with a named fetch specification using bindObjectsWithFetchSpecification. Shared objects fetched into the receiver with other methods are not returned from this method.

Returns:
Returns the objects fetched into the receiver with bindObjectsWithFetchSpecification.
See Also:
EOSharedEditingContext.bindObjectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification, java.lang.String)

reset

public void reset()
Overrides the superclass implementation to do nothing.

Overrides:
reset in class EOEditingContext
See Also:
EOEditingContext.revert(), EOEditingContext.fetchTimestamp()

dispose

public void dispose()
Description copied from interface: NSDisposable
Invoked when the receiver should prepare itself for destruction. Implementations of this method should break connections that other objects have to the receiver, including unregistering for notifications, resigning as other objects' delegates, release locks and system resources, close files, and any other clean up operations.

Specified by:
dispose in interface NSDisposable
Overrides:
dispose in class EOEditingContext

sharedEditingContext

public EOSharedEditingContext sharedEditingContext()
Always returns null

Overrides:
sharedEditingContext in class EOEditingContext
Returns:
null

setSharedEditingContext

public void setSharedEditingContext(EOSharedEditingContext sharedEditingContext)
Raises an exception unless sharedEditingContext is null.

Overrides:
setSharedEditingContext in class EOEditingContext
Parameters:
sharedEditingContext - input sharedEditingContext
See Also:
EOSharedEditingContext, EOSharedEditingContext.DefaultSharedEditingContextWasInitializedNotification

setUndoManager

public void setUndoManager(NSUndoManager undoManager)
Raises an exception unless undoManager is null.

Overrides:
setUndoManager in class EOEditingContext
Parameters:
undoManager - input sharedEditingContext
See Also:
EOEditingContext.undoManager()

globalIDForObject

public EOGlobalID globalIDForObject(EOEnterpriseObject object)
Description copied from class: EOEditingContext
Returns the EOGlobalID associated with object in this EOEditingContext or its shared context. All objects fetched from an external store are registered in an EOEditingContext along with a global identifier (EOGlobalID) that's used to uniquely identify each object to the external store. If object has not been registered in the EOEditingContext or in its shared editing context (that is, if no match is found), this method returns null. Objects are registered in an EOEditingContext using the insertObject method, or when fetching, with recordObject.

Overrides:
globalIDForObject in class EOEditingContext
Parameters:
object - the target of the search
Returns:
the EOGlobalID for object
See Also:
EOGlobalID, EOEditingContext.objectForGlobalID(com.webobjects.eocontrol.EOGlobalID), EOEditingContext.insertObject(com.webobjects.eocontrol.EOEnterpriseObject), EOEditingContext.recordObject(com.webobjects.eocontrol.EOEnterpriseObject, com.webobjects.eocontrol.EOGlobalID), EOEditingContext.sharedEditingContext()

objectForGlobalID

public EOEnterpriseObject objectForGlobalID(EOGlobalID gid)
Description copied from class: EOEditingContext
Returns the EOEnterpriseObject associated with gid in this EOEditingContext or its shared context, or null if no such object exists.

Overrides:
objectForGlobalID in class EOEditingContext
Parameters:
gid - the identifier to search for
Returns:
the object identified by globalID, or null
See Also:
EOGlobalID, EOEditingContext.globalIDForObject(com.webobjects.eocontrol.EOEnterpriseObject), EOEditingContext.sharedEditingContext()

faultForGlobalID

public EOEnterpriseObject faultForGlobalID(EOGlobalID gid,
                                           EOEditingContext editingContext)
Description copied from class: EOEditingContext
Overrides the implementation inherited from EOObjectStore. If the object associated with globalID is already registered in this EOEditingContext (or its shared context), this method returns that object. Otherwise, the method propagates the message up the object store hierarchy, through the parent object store, ultimately to the associated EODatabaseContext. The EODatabaseContext creates and returns a to-one fault. For example, suppose you want the department object whose deptID has a particular value. The most efficient way to get it is to look it up by its globalID using faultForGlobalID. If the department object is already registered in the EOEditingContext, faultForGlobalID returns that object (without going to the database). If not, a fault for this object is created, and the object is fetched from the database only when you trigger the fault. In a nested editing context configuration, where a parent EOEditingContext is sent faultForGlobalID on behalf of a child EOEditingContext and globalID identifies a newly inserted object in the parent, the parent registers a copy of the object in the child.

For more information refer to: "Working with Objects Across Multiple EOEditingContexts"

Overrides:
faultForGlobalID in class EOEditingContext
Parameters:
gid - the identifier for the desired object
editingContext - the EOEditingContext to search and register the fault
Returns:
object associated with the EOGlobalID
See Also:
EOObjectStore.faultForGlobalID(com.webobjects.eocontrol.EOGlobalID, com.webobjects.eocontrol.EOEditingContext), EOUtilities.localInstanceOfObject(com.webobjects.eocontrol.EOEditingContext, com.webobjects.eocontrol.EOEnterpriseObject), EODatabaseContext, EOEditingContext.arrayFaultWithSourceGlobalID(com.webobjects.eocontrol.EOGlobalID, java.lang.String, com.webobjects.eocontrol.EOEditingContext), EOFaultHandler

objectsWithFetchSpecification

public NSArray objectsWithFetchSpecification(EOFetchSpecification fetchSpecification,
                                             EOEditingContext editingContext)
A thread-safe version of the superclass implementation that binds the results to fetchSpecification's entity. The resulting shared objects can be retrieved later using the method objectsByEntityName.

Overrides:
objectsWithFetchSpecification in class EOEditingContext
Parameters:
fetchSpecification - specifies fetchSpecification
editingContext - specifies container in which source object belong to
Returns:
Returns an array
See Also:
EOSharedEditingContext.objectsByEntityName(), EOSharedEditingContext.bindObjectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification, java.lang.String), EOEditingContext.objectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification, com.webobjects.eocontrol.EOEditingContext)

bindObjectsWithFetchSpecification

public void bindObjectsWithFetchSpecification(EOFetchSpecification fetchSpecification,
                                              String fetchSpecificationName)
Fetches objects with fetchSpecification and binds the results to fetchSpecification's entity and fetchSpecification's name, which is provided with the fetchSpecificationName argument. The resulting shared objects can later be retrieved using the methods objectsByEntityName and objectsByEntityNameAndFetchSpecificationName.

Parameters:
fetchSpecification - specifies fetchSpecification
fetchSpecificationName - specifies fetchSpecification's name
See Also:
EOSharedEditingContext.objectsByEntityName(), EOSharedEditingContext.objectsByEntityNameAndFetchSpecificationName()

initializeObject

public void initializeObject(EOEnterpriseObject object,
                             EOGlobalID gid,
                             EOEditingContext editingContext)
Description copied from class: EOEditingContext
Overrides the implementation inherited from EOObjectStore to build the properties for the object identified by gid. When a parent EOEditingContext receives this on behalf of a child EOEditingContext (as represented by context), and the gid identifies an object instantiated in the parent, the parent returns properties extracted from its object and translated into the child's context. This ensures that a nested context "inherits" modified values from its parent EOEditingContext. If this EOEditingContext does not have object, the request is forwarded its parent EOObjectStore.

Overrides:
initializeObject in class EOEditingContext
Parameters:
object - the object identified by globalID
gid - the EOGlobalID corresponding to object
editingContext - the EOEditingContext in which to initialize the object
See Also:
EOObjectStore.initializeObject(com.webobjects.eocontrol.EOEnterpriseObject, com.webobjects.eocontrol.EOGlobalID, com.webobjects.eocontrol.EOEditingContext)

forgetObject

public void forgetObject(EOEnterpriseObject object)
Description copied from class: EOEditingContext
Removes object from the uniquing tables and causes this EOEditingContext to remove itself from the object's list of observers. You should never invoke this method directly. The correct way to remove an object from its editing context is to remove every reference to the object by refaulting any object that references it (using refaultAllObjects or invalidateAllObjects). Also note that this method does not have the effect of deleting an object. In order to delete an object, you should either use the deleteObject method or remove the object from an owning relationship.

Overrides:
forgetObject in class EOEditingContext
Parameters:
object - the object to be forgotten
See Also:
EOEditingContext.refaultAllObjects(), EOEditingContext.invalidateAllObjects(), EOEditingContext.deleteObject(com.webobjects.eocontrol.EOEnterpriseObject)

refaultObject

public void refaultObject(EOEnterpriseObject object,
                          EOGlobalID gid,
                          EOEditingContext editingContext)
Description copied from class: EOEditingContext
Overrides the implementation inherited from EOObjectStore to refault the enterprise object object identified by gid in ctx. This method should be used with caution since refaulting an object does not remove the object snapshot from the undo stack. Objects that have been newly inserted or deleted should not be refaulted.

The main purpose of this method is to break reference cycles between enterprise objects. For example, suppose you have an Employee object that has a to-one relationship to its Department, and the Department object in turn has an array of Employee objects. You can use this method to break the reference cycle. Note that reference cycles are automatically broken if the EOEditingContext is finalized.

For more information, see the sections:


Overrides:
refaultObject in class EOEditingContext
Parameters:
object - the enterprise object to be refaulted
gid - the EOs corresponding EOGlobalID
editingContext - the target EOEditingContext
See Also:
EOObjectStore.refaultObject(com.webobjects.eocontrol.EOEnterpriseObject, com.webobjects.eocontrol.EOGlobalID, com.webobjects.eocontrol.EOEditingContext), EOEditingContext.invalidateObjectsWithGlobalIDs(com.webobjects.foundation.NSArray)

refaultAllObjects

public void refaultAllObjects()
Description copied from class: EOEditingContext
Refaults all objects cached in this EOEditingContext that have not been inserted, deleted, or updated. Invokes processRecentChanges, then invokes refaultObject for all objects that haven't been inserted, deleted, or updated.

Overrides:
refaultAllObjects in class EOEditingContext
See Also:
EOEditingContext.refaultObject(com.webobjects.eocontrol.EOEnterpriseObject), EOObjectStore.refaultObject(com.webobjects.eocontrol.EOEnterpriseObject, com.webobjects.eocontrol.EOGlobalID, com.webobjects.eocontrol.EOEditingContext), EOEditingContext.processRecentChanges()

invalidateObjectsWithGlobalIDs

public void invalidateObjectsWithGlobalIDs(NSArray gids)
Description copied from class: EOEditingContext
Overrides the implementation inherited from EOObjectStore to signal to the parent object store that the cached values for the objects identified by globalIDs should no longer be considered valid and that they should be refaulted. Invokes processRecentChanges before refaulting the objects. This message is propagated to any underlying object store, resulting in a refetch the next time the objects are accessed. Any related (child or peer) object stores are notified that the objects are no longer valid. All uncommitted changed to the objects are lost.

For more information, see the sections:


Overrides:
invalidateObjectsWithGlobalIDs in class EOEditingContext
Parameters:
gids - An array of EOGlobalIDs corresponding to objects which should be invalidated
See Also:
EOEditingContext.invalidateAllObjects(), EOObjectStore.invalidateObjectsWithGlobalIDs(com.webobjects.foundation.NSArray), EOEditingContext.processRecentChanges()

invalidateAllObjects

public void invalidateAllObjects()
Description copied from class: EOEditingContext
Overrides the implementation inherited from EOObjectStore to discard the values of objects cached in memory and refault them, which causes them to be refetched from the external store the next time they're accessed. This method sends the message invalidateObjectsWithGlobalIDs to the parent object store with the globalIDs of all of the objects cached in the receiver. When an EOEditingContext receives this message, it propagates the message down the object store hierarchy. EODatabaseContexts discard their snapshots for invalidated objects and broadcast an ObjectsChangedInStoreNotification. (EODatabaseContext is defined in EOAccess.)

The final effect of this method is to refault all objects currently in memory. The next time you access one of these objects, it's refetched from the database. To flush the entire application's cache of all values fetched from an external store, you have to use a statement such as the following:

 EOEditingContext.rootObjectStore().invalidateAllObjects();
 
If you just want to discard uncommitted changes but do not want to sacrifice the values cached in memory, the EOEditingContext revert method is to be used, which reverses all changes and clears the undo stack.

For more information, see the sections:


Overrides:
invalidateAllObjects in class EOEditingContext
See Also:
EOEditingContext.revert(), EOEditingContext.refaultAllObjects(), EOEditingContext.invalidateObjectsWithGlobalIDs(com.webobjects.foundation.NSArray), EOObjectStore.invalidateAllObjects()

updatedObjects

public NSArray updatedObjects()
Returns an empty array. You can't modify objects that are in a shared editing context.

Overrides:
updatedObjects in class EOEditingContext
Returns:
Returns an empty array.
See Also:
EOEditingContext.deletedObjects(), EOEditingContext.insertedObjects()

insertedObjects

public NSArray insertedObjects()
You can't insert objects into a shared editing context.

Overrides:
insertedObjects in class EOEditingContext
Returns:
Returns an empty array.
See Also:
EOEditingContext.deletedObjects(), EOEditingContext.updatedObjects()

deletedObjects

public NSArray deletedObjects()
The shared objects in a shared editing context can't be deleted.

Overrides:
deletedObjects in class EOEditingContext
Returns:
Returns an empty array.
See Also:
EOEditingContext.updatedObjects(), EOEditingContext.insertedObjects()

hasChanges

public boolean hasChanges()
Shared objects in a shared editing context cannot be modified or be deleted.

Overrides:
hasChanges in class EOEditingContext
Returns:
Returns false.

validateChangesForSave

public void validateChangesForSave()
Overrides the superclass implementation to do nothing.


registeredObjects

public NSArray registeredObjects()
Overrides:
registeredObjects in class EOEditingContext
Returns:
an array of enterprise objects known to this EOEditingContext

objectWillChange

public void objectWillChange(Object object)
Raises an exception. You can't modify the shared objects in a shared editing context.

Specified by:
objectWillChange in interface EOObserving
Overrides:
objectWillChange in class EOEditingContext
Parameters:
object - specifies object to be changed
See Also:
EOEnterpriseObject.willChange()

insertObjectWithGlobalID

public void insertObjectWithGlobalID(EOEnterpriseObject object,
                                     EOGlobalID gid)
Throws an exception. You cannot insert objects into an EOSharedEditingContext. You should fetch or fault objects into the shared context.

Overrides:
insertObjectWithGlobalID in class EOEditingContext
Parameters:
object - ignored
gid - ignored
See Also:
EOSharedEditingContext.objectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification, com.webobjects.eocontrol.EOEditingContext), EOEditingContext.faultForGlobalID(com.webobjects.eocontrol.EOGlobalID, com.webobjects.eocontrol.EOEditingContext), EOSharedEditingContext.bindObjectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification, java.lang.String)

insertObject

public void insertObject(EOEnterpriseObject object)
Throws an exception. You cannot insert objects into an EOSharedEditingContext. You should fetch or fault objects into the shared context.

Overrides:
insertObject in class EOEditingContext
Parameters:
object - ignored
See Also:
EOSharedEditingContext.objectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification, com.webobjects.eocontrol.EOEditingContext), EOEditingContext.faultForGlobalID(com.webobjects.eocontrol.EOGlobalID, com.webobjects.eocontrol.EOEditingContext), EOSharedEditingContext.bindObjectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification, java.lang.String)

deleteObject

public void deleteObject(EOEnterpriseObject object)
Raises an exception. Objects in a shared editing context cannot be modified or be deleted.

Overrides:
deleteObject in class EOEditingContext
Parameters:
object - ignored
See Also:
EOEditingContext.deletedObjects()

saveChanges

public void saveChanges()
Raises an exception. You can't modify the shared objects in a shared editing context.

Overrides:
saveChanges in class EOEditingContext
See Also:
EOEditingContext.saveChangesInEditingContext(com.webobjects.eocontrol.EOEditingContext), EOEditingContext.Delegate.editingContextWillSaveChanges(com.webobjects.eocontrol.EOEditingContext), EOEditingContext.editors()

lockObjectStore

public void lockObjectStore()
Overrides:
lockObjectStore in class EOEditingContext

unlockObjectStore

public void unlockObjectStore()
Overrides:
unlockObjectStore in class EOEditingContext

lock

public void lock()
Acquires a writer lock to this EOSharedEditingContext to prevent other threads from accessing it.

Specified by:
lock in interface NSLocking
Overrides:
lock in class EOEditingContext
See Also:
NSLocking.lock(), EOSharedEditingContext.unlock(), EOSharedEditingContext.tryLock(), EOSharedEditingContext.lockForReading()

tryLock

public boolean tryLock()
Attempts to take the lock on this EOSharedEditingContext for writing. However, instead of waiting until the lock is available, it returns immediately with false if it fails.

Overrides:
tryLock in class EOEditingContext
Returns:
true if the lock was successfully acquired
See Also:
EOSharedEditingContext.lock()

unlock

public void unlock()
Releases a previously acquired lock for writing on this EOSharedEditingContext.

Specified by:
unlock in interface NSLocking
Overrides:
unlock in class EOEditingContext
See Also:
NSLocking.unlock(), EOSharedEditingContext.lock(), EOSharedEditingContext.tryLock(), EOSharedEditingContext.lockForReading()

lockForReading

public void lockForReading()
Locks the receiver for reading. If the lock is unavailable, it waits.

See Also:
EOSharedEditingContext.lock(), EOSharedEditingContext.unlockForReading(), EOSharedEditingContext.tryLockForReading()

tryLockForReading

public boolean tryLockForReading()
Attempts to take the lock on this EOSharedEditingContext for reading. However, instead of waiting until the lock is available, it returns immediately with false if it fails.

Returns:
true if the lock was successfully acquired
See Also:
EOSharedEditingContext.lockForReading()

unlockForReading

public void unlockForReading()
Releases a previously acquired lock for reading on this EOSharedEditingContext.

See Also:
EOSharedEditingContext.lockForReading(), EOSharedEditingContext.tryLockForReading(), EOSharedEditingContext.unlock()

suspendReaderLocks

public void suspendReaderLocks()
Temporarily relinquishes all of the current thread's reader locks, releasing the lock if all reader locks are unlocked. To reinstate the current thread's suspended reader locks, use the retrieveReaderLocks method.

See Also:
NSMultiReaderLock#suspendReaderLocks, EOSharedEditingContext.retrieveReaderLocks()

retrieveReaderLocks

public void retrieveReaderLocks()
Reinstates the current thread's reader locks that have been suspended using suspendReaderLocks.

See Also:
NSMultiReaderLock#retrieveReaderLocks, EOSharedEditingContext.suspendReaderLocks()

Last updated June 2008

Copyright © 2000-2008 Apple Inc.