PATH |
EOSharedEditingContext
Inherits from: EOEditingContext : EOObjectStore
Package: com.webobjects.eocontrol
Class Description
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 EOMultiReaderLocks to maintain thread safety. The methods objectsWithFetchSpecification bindObjectsWithFetchSpecification, faultForGlobalID, and objectForGlobalID are thread-safe, but you must lock the context before using any other shared context API.
It is possible to modify shared objects while an application is running, but only indirectly. You can create a regular editing context that doesn't share objects by setting it's sharedEditingContext to null. Fetch the object that you want to change 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, you should refetch.
Constants
EOSharedEditingContext defines constants for the notifications it post. For more information, see "Notifications" (page 346).
Method Types
Accessing a shared editing context defaultSharedEditingContext setDefaultSharedEditingContext sharedEditingContext setSharedEditingContext Accessing shared objects bindObjectsWithFetchSpecification objectsByEntityName objectsByEntityNameAndFetchSpecificationName objectsWithFetchSpecification Locking a shared editing context lockForReading tryLockForReading unlockForReading Overridden EOEditingContext methods deleteObject deletedObjects faultForGlobalID hasChanges insertedObjects insertObject objectForGlobalID objectWillChange refaultObject registeredObjects reset saveChanges setUndoManager updatedObjects validateChangesForSave
Constructors
EOSharedEditingContext
public EOSharedEditingContext(EOObjectStore anObjectStore)
public EOSharedEditingContext()
Static Methods
defaultSharedEditingContext
public static EOSharedEditingContext defaultSharedEditingContext()
setDefaultSharedEditingContext
public static synchronized void setDefaultSharedEditingContext(EOSharedEditingContext context)
Instance Methods
bindObjectsWithFetchSpecification
public void bindObjectsWithFetchSpecification( EOFetchSpecification fetchSpecification, String name)
deleteObject
public void deleteObject(EOEnterpriseObject object)
deletedObjects
public NSArray deletedObjects()
dispose
public void dispose()
faultForGlobalID
public EOEnterpriseObject faultForGlobalID( EOGlobalID gid, EOEditingContext context)
See Also: faultForGlobalID (EOEditingContext)
forgetObject
public void forgetObject(EOEnterpriseObject anEO)
globalIDForObject
public EOGlobalID globalIDForObject(EOEnterpriseObject anEO)
hasChanges
public boolean hasChanges()
initializeObject
public void initializeObject( EOEnterpriseObject anEO, EOGlobalID anID, EOEditingContext aEC)
insertedObjects
public NSArray insertedObjects()
insertObject
public void insertObject(EOEnterpriseObject object)
insertObjectWithGlobalID
public void insertObjectWithGlobalID( EOEnterpriseObject anEO, EOGlobalID anID)
invalidateAllObjects
public void invalidateAllObjects()
invalidateObjectsWithGlobalIDs
public void invalidateObjectsWithGlobalIDs(NSArray arrayOfIDs)
lock
public void lock()
lockForReading
public void lockForReading()
See Also: tryLockForReading
objectForGlobalID
public EOEnterpriseObject objectForGlobalID(EOGlobalID gid)
See Also: objectForGlobalID (EOEditingContext)
objectsByEntityName
public NSDictionary objectsByEntityName()
See Also: bindObjectsWithFetchSpecification
objectsByEntityNameAndFetchSpecificationName
public NSDictionary objectsByEntityNameAndFetchSpecificationName()
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. |
objectsWithFetchSpecification
public NSArray objectsWithFetchSpecification( EOFetchSpecification fetchSpecification, EOEditingContext anEditingContext)
See Also: objectsWithFetchSpecification (EOEditingContext)
objectWillChange
public void objectWillChange(Object object)
refaultObject
public void refaultObject( EOEnterpriseObject object, EOGlobalID gid, EOEditingContext context)
refaultObjects
public void refaultObjects()
registeredObjects
public NSArray registeredObjects()
See Also: registeredObjects (EOEditingContext)
reset
public void reset()
retrieveReaderLocks
public void retrieveReaderLocks()
saveChanges
public void saveChanges()
setSharedEditingContext
public void setSharedEditingContext(EOSharedEditingContext sharedEC)
setUndoManager
public void setUndoManager(NSUndoManager undoManager)
sharedEditingContext
public EOSharedEditingContext sharedEditingContext()
suspendReaderLocks
public void suspendReaderLocks()
tryLock
public boolean tryLock()
tryLockForReading
public boolean tryLockForReading()
unlock
public void unlock()
unlockForReading
public void unlockForReading()
updatedObjects
public NSArray updatedObjects()
validateChangesForSave
public void validateChangesForSave()
Notifications
DefaultSharedEditingContextWasInitializedNotification
public static final String DefaultSharedEditingContextWasInitializedNotification
Notification Object | None |
userInfo Dictionary | None |
SharedEditingContextInitializedObjectsNotification
public static final String SharedEditingContextInitializedObjectsNotification
Notification Object | The shared editing context |
userInfo Dictionary | NSArray of global IDs of the initialized objects |
© 2001 Apple Computer, Inc. (Last Published April 19, 2001)