|
WebObjects 5.2.3 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.eocontrol.EOObjectStore com.webobjects.eocontrol.EOObjectStoreCoordinator
EOObjectStoreCoordinator provides the abstraction of a single object
store by coordinating one or more EOCooperatingObjectStores.
For the basic object store methods, such as
objectsWithFetchSpecification(EOFetchSpecification, EOEditingContext)
, the coordinator forwards
the message to the appropriate coorperating object store based on entity name.
For saveChangesInEditingContext(EOEditingContext)
, the coordinator guides its cooperating
object stores through a multi-pass save protocol in which each cooperating
object store saves its own changes and forwards other changes on to other
object stores. For example, if in its recordChangesInEditingContext
method,
one store notices the removal of an object from an "owning" relationship,
but that object comes from another store, it should inform the other store
by passing the coordinator a forwardUpdateForObject(EOEnterpriseObject, NSDictionary)
message.
For more information on EOObjectStoreCoordinator, refer to:
Field Summary | |
static String |
CooperatingObjectStoreNeededNotification
|
static String |
CooperatingObjectStoreWasAddedNotification
|
static String |
CooperatingObjectStoreWasRemovedNotification
|
static String |
FetchSpecificationKey
|
static String |
GlobalIDKey
|
static String |
ObjectKey
|
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 | |
EOObjectStoreCoordinator()
Creates and returns an EOObjectStoreCoordinator. |
Method Summary | |
void |
addCooperatingObjectStore(EOCooperatingObjectStore objectStore)
Adds objectStore to the list of EOCooperatingObjectStores that need to
be queried and notified about changes to enterprise objects. |
NSArray |
arrayFaultWithSourceGlobalID(EOGlobalID gid,
String relationshipName,
EOEditingContext editingContext)
Implementation for arrayFaultWithSourceGlobalID inherited from EOObjectStore. |
NSArray |
cooperatingObjectStores()
Returns the receiver's EOCooperatingObjectStores. |
static EOObjectStoreCoordinator |
defaultCoordinator()
Returns a shared instance of EOObjectStoreCoordinator. |
void |
dispose()
Invoked when the receiver should prepare itself for destruction. |
void |
editingContextDidForgetObjectWithGlobalID(EOEditingContext editingContext,
EOGlobalID gid)
Invoked to inform the object store that it can stop keeping data about an object it passed to a child. |
EOEnterpriseObject |
faultForGlobalID(EOGlobalID gid,
EOEditingContext editingContext)
Implementation for faultForGlobalID inherited from EOObjectStore. |
EOEnterpriseObject |
faultForRawRow(NSDictionary row,
String entityName,
EOEditingContext editingContext)
Implementation for faultForRawRow inherited from EOObjectStore. |
void |
forwardUpdateForObject(EOEnterpriseObject object,
NSDictionary changes)
Tells the receiver to forward a message from an EOCooperatingObjectStore to another store, informing it that changes need to be made to object . |
void |
initializeObject(EOEnterpriseObject object,
EOGlobalID gid,
EOEditingContext editingContext)
Implementation for initializeObject inherited from EOObjectStore to set
object's properties, as obtained for gid . |
void |
invalidateAllObjects()
Tells the receiver's coopertating object stores to discard the values of all objects they hold and turn them into faults (empty enterprise objects). |
void |
invalidateObjectsWithGlobalIDs(NSArray gids)
Signals that the objects identified by the EOGlobalIDs in gids
should no longer be considered valid and that they should be turned
into faults (empty enterprise objects). |
boolean |
isObjectLockedWithGlobalID(EOGlobalID gid,
EOEditingContext editingContext)
Returns true if the object identified by gid in editingContext
is locked, false otherwise. |
void |
lock()
This method is used to protect access to the receiver from concurrent operations by multiple threads. |
void |
lockObjectWithGlobalID(EOGlobalID gid,
EOEditingContext editingContext)
Overrides the implementation inherited from EOObjectStore to attempt to lock the object identified by gid in editingContext in
the external store. |
NSArray |
objectsForSourceGlobalID(EOGlobalID gid,
String relationshipName,
EOEditingContext editingContext)
Returns the destination objects for a to-many relationship. |
EOCooperatingObjectStore |
objectStoreForFetchSpecification(EOFetchSpecification fetchSpecification)
Returns the EOCooperatingObjectStore responsible for fetching objects with fetchSpecification . |
EOCooperatingObjectStore |
objectStoreForGlobalID(EOGlobalID gid)
Returns the EOCooperatingObjectStore for the object identified by gid . |
EOCooperatingObjectStore |
objectStoreForObject(EOEnterpriseObject object)
Returns the EOCooperatingObjectStore that owns object. |
NSArray |
objectsWithFetchSpecification(EOFetchSpecification fetchSpecification,
EOEditingContext editingContext)
Overrides the EOObjectStore implementation to fetch objects from the receiver's cooperating object stores. |
void |
refaultObject(EOEnterpriseObject object,
EOGlobalID gid,
EOEditingContext editingContext)
Turns object into a fault (an empty enterprise object), identified
by globalID in editingContext . |
void |
removeCooperatingObjectStore(EOCooperatingObjectStore objectStore)
Removes objectStore from the list of EOCooperatingObjectStores that need
to be queried and notified about changes to enterprise objects. |
void |
saveChangesInEditingContext(EOEditingContext context)
Overrides the EOObjectStore implementation to save the changes made in context . |
static void |
setDefaultCoordinator(EOObjectStoreCoordinator coordinator)
Sets a shared instance EOObjectStoreCoordinator. |
void |
setUserInfo(NSDictionary userInfo)
Sets the dictionary of auxiliary data, which your application can use for whatever it needs. |
void |
unlock()
This method is used to protect access to the receiver from concurrent operations by multiple threads. |
NSDictionary |
userInfo()
Returns a dictionary of user data. |
NSDictionary |
valuesForKeys(NSArray keys,
EOEnterpriseObject object)
Communicates with the appropriate EOCooperatingObjectStore to get the values identified by keys for object, so that it can then forward them on to another EOCooperatingObjectStore. |
Methods inherited from class com.webobjects.eocontrol.EOObjectStore |
invokeRemoteMethod |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String CooperatingObjectStoreNeededNotification
public static final String CooperatingObjectStoreWasAddedNotification
public static final String CooperatingObjectStoreWasRemovedNotification
public static final String FetchSpecificationKey
public static final String GlobalIDKey
public static final String ObjectKey
Constructor Detail |
public EOObjectStoreCoordinator()
Method Detail |
public void addCooperatingObjectStore(EOCooperatingObjectStore objectStore)
objectStore
to the list of EOCooperatingObjectStores that need to
be queried and notified about changes to enterprise objects. The
receiver reuses its stores: they don't go away until the EOObjectStoreCoordinator
is destroyed or until the stores are explicitly removed. Posts the
notification CooperatingObjectStoreWasAdded
.
objectStore
- an EOCooperatingObjectStore that will be
queried and notified about changes to enterprise objectsremoveCooperatingObjectStore(com.webobjects.eocontrol.EOCooperatingObjectStore)
,
cooperatingObjectStores()
public NSArray arrayFaultWithSourceGlobalID(EOGlobalID gid, String relationshipName, EOEditingContext editingContext)
arrayFaultWithSourceGlobalID
inherited from EOObjectStore.
EOObjectStoreCoordinator's implementation forwards this message to the
EOCooperatingObjectStore returned by objectStoreForGlobalID
for gid
.
arrayFaultWithSourceGlobalID
in class EOObjectStore
gid
- EOGlobalID of a source object with a to-many relationshiprelationshipName
- name of the to-many relationship from which to generate the array
of destination objectseditingContext
- the EOEditingContext that will contain the source and destination
objects
relationshipName
from
the source object identified by gidEOObjectStore.arrayFaultWithSourceGlobalID(com.webobjects.eocontrol.EOGlobalID, java.lang.String, com.webobjects.eocontrol.EOEditingContext)
public NSArray cooperatingObjectStores()
addCooperatingObjectStore(com.webobjects.eocontrol.EOCooperatingObjectStore)
,
removeCooperatingObjectStore(com.webobjects.eocontrol.EOCooperatingObjectStore)
public static EOObjectStoreCoordinator defaultCoordinator()
public void dispose()
NSDisposable
dispose
in interface NSDisposable
dispose
in class EOObjectStore
public void editingContextDidForgetObjectWithGlobalID(EOEditingContext editingContext, EOGlobalID gid)
objectStoreForGlobalID
for gid
.
editingContextDidForgetObjectWithGlobalID
in class EOObjectStore
editingContext
- the EOEditingContext that has stopped storing data about
the object identified by gid
gid
- the EOGlobalID of the object that was forgotten by editingContext
EOObjectStore.editingContextDidForgetObjectWithGlobalID(com.webobjects.eocontrol.EOEditingContext, com.webobjects.eocontrol.EOGlobalID)
public EOEnterpriseObject faultForGlobalID(EOGlobalID gid, EOEditingContext editingContext)
faultForGlobalID
inherited from EOObjectStore. EOObjectStoreCoordinator's
implementation forwards this message to the EOCooperatingObjectStore of
the object identified by gid
.
faultForGlobalID
in class EOObjectStore
gid
- EOGlobalID of the object to faulteditingContext
- the EOEditingContext that either contains the object identified
by gid
, or will contain the object's fault
gid
EOObjectStore.faultForGlobalID(com.webobjects.eocontrol.EOGlobalID, com.webobjects.eocontrol.EOEditingContext)
public EOEnterpriseObject faultForRawRow(NSDictionary row, String entityName, EOEditingContext editingContext)
faultForRawRow
inherited from EOObjectStore. EOObjectStoreCoordinator's
implementation forwards this message to the EOCooperatingObjectStore returned by
objectStoreForEntityNamed
for entityName
.
faultForRawRow
in class EOObjectStore
row
- dictionary containing at least the the primary key of the corresponding rowentityName
- the name of the entity to create an EO fromeditingContext
- the EOEditingContext that either contains the object from row,
or will contain the object's fault
EOObjectStore.faultForRawRow(com.webobjects.foundation.NSDictionary, java.lang.String, com.webobjects.eocontrol.EOEditingContext)
public void forwardUpdateForObject(EOEnterpriseObject object, NSDictionary changes)
object
.
For example, inserting an object in a relationship property of one
EOCooperatingObjectStore might require changing a foreign key property
in an object owned by another EOCooperatingObjectStore.
This method first locates the EOCooperatingObjectStore that's
responsible for applying changes, and then it sends the store the
message recordUpdateForObject
.
object
- EOEnterpriseObject that needs updatingchanges
- a dictionary of changes for the appropriate EOCooperatingObjectStore
to make in objectpublic void initializeObject(EOEnterpriseObject object, EOGlobalID gid, EOEditingContext editingContext)
initializeObject
inherited from EOObjectStore to set
object's properties, as obtained for gid
. EOObjectStoreCoordinator's
implementation forwards this message to the EOCooperatingObjectStore returned
by objectStoreForGlobalID
for gid
.
initializeObject
in class EOObjectStore
object
- the EOEnterpriseObject to set the properties ofgid
- the EOGlobalID that identifies the set of properties to set in objecteditingContext
- the EOEditingContext that contains the objectEOObjectStore.initializeObject(com.webobjects.eocontrol.EOEnterpriseObject, com.webobjects.eocontrol.EOGlobalID, com.webobjects.eocontrol.EOEditingContext)
public void invalidateAllObjects()
InvalidatedAllObjectsInStoreNotification
.
invalidateAllObjects
in class EOObjectStore
EOObjectStore.invalidateAllObjects()
public void invalidateObjectsWithGlobalIDs(NSArray gids)
gids
should no longer be considered valid and that they should be turned
into faults (empty enterprise objects). EOObjectStoreCoordinator's
implementation forwards this message to the EOCooperatingObjectStore
for each object identified by the EOGlobalIDs in gids
.
invalidateObjectsWithGlobalIDs
in class EOObjectStore
gids
- array of EOGlobalIDs that identify objects to invalidateEOObjectStore.invalidateObjectsWithGlobalIDs(com.webobjects.foundation.NSArray)
public boolean isObjectLockedWithGlobalID(EOGlobalID gid, EOEditingContext editingContext)
true
if the object identified by gid
in editingContext
is locked, false
otherwise. This method works by forwarding the
message isObjectLockedWithGlobalID
to its parent object store.
isObjectLockedWithGlobalID
in class EOObjectStore
gid
- the EOGlobalID of the object to testeditingContext
- EOEditingContext to locate the object with gid in
true
if the object identified by gid
in editingContext
is locked, false
otherwiseEOEditingContext.lockObject(com.webobjects.eocontrol.EOEnterpriseObject)
,
lockObjectWithGlobalID(com.webobjects.eocontrol.EOGlobalID, com.webobjects.eocontrol.EOEditingContext)
,
EOEditingContext.locksObjectsBeforeFirstModification()
public void lock()
lock
in interface NSLocking
lock
in class EOObjectStore
unlock()
,
EOObjectStore.lock()
public void lockObjectWithGlobalID(EOGlobalID gid, EOEditingContext editingContext)
gid
in editingContext
in
the external store. Throws an exception if unable to obtain the
lock. This method works by forwarding the message lockObjectWithGlobalID
to its parent object store.
lockObjectWithGlobalID
in class EOObjectStore
gid
- the EOGlobalID of the object to lock.editingContext
- the EOEditingContext that holds the object to lock.EOEditingContext.lockObject(com.webobjects.eocontrol.EOEnterpriseObject)
,
isObjectLockedWithGlobalID(com.webobjects.eocontrol.EOGlobalID, com.webobjects.eocontrol.EOEditingContext)
,
EOEditingContext.locksObjectsBeforeFirstModification()
public EOCooperatingObjectStore objectStoreForFetchSpecification(EOFetchSpecification fetchSpecification)
fetchSpecification
. Returns null
if no EOCooperatingObjectStore
can be found that responds true
to handlesFetchSpecification
.
fetchSpecification
- the EOFetchSpecification to locate an
EOCooperatingObjectStore for
fetchSpecification
,
or null
if no such cooperating object store can be foundobjectStoreForGlobalID(com.webobjects.eocontrol.EOGlobalID)
,
objectStoreForObject(com.webobjects.eocontrol.EOEnterpriseObject)
public EOCooperatingObjectStore objectStoreForGlobalID(EOGlobalID gid)
gid
. Returns null
if no EOCooperatingObjectStore can be
found that responds true
to ownsGlobalID
.
gid
- the EOGlobalID of the object to locate a cooperating object
store for
gid
,
or null
if no such store can be foundobjectStoreForFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification)
,
objectStoreForObject(com.webobjects.eocontrol.EOEnterpriseObject)
public EOCooperatingObjectStore objectStoreForObject(EOEnterpriseObject object)
null
if no EOCooperatingObjectStore can be found that responds true
to ownsObject
.
object
- the EOEnterpriseObject to locate a cooperating object store for
object
, or null
if no such store can be foundobjectStoreForFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification)
,
objectStoreForGlobalID(com.webobjects.eocontrol.EOGlobalID)
public NSArray objectsForSourceGlobalID(EOGlobalID gid, String relationshipName, EOEditingContext editingContext)
objectStoreForGlobalID
for gid
.
objectsForSourceGlobalID
in class EOObjectStore
gid
- the EOGlobalID of the source objectrelationshipName
- the name of the to-many relationshipeditingContext
- the EOEditingContext that contains the source and destination objects
EOObjectStore.objectsForSourceGlobalID(com.webobjects.eocontrol.EOGlobalID, java.lang.String, com.webobjects.eocontrol.EOEditingContext)
public NSArray objectsWithFetchSpecification(EOFetchSpecification fetchSpecification, EOEditingContext editingContext)
objectsWithFetchSpecification
in class EOObjectStore
fetchSpecification
- the EOFetchSpecification that speicifies which objects to fetcheditingContext
- container of objects fetched using fetchSpecification
EOObjectStore.objectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification, com.webobjects.eocontrol.EOEditingContext)
public void refaultObject(EOEnterpriseObject object, EOGlobalID gid, EOEditingContext editingContext)
object
into a fault (an empty enterprise object), identified
by globalID
in editingContext
. EOObjectStoreCoordinator's
implementation forwards this message to the EOCooperatingObjectStore returned
by objectStoreForGlobalID
for gid
.
refaultObject
in class EOObjectStore
object
- the object to turn into a faultgid
- the EOGlobalID identifier for the resulting fault objecteditingContext
- contains object and the resulting fault for objectEOObjectStore.refaultObject(com.webobjects.eocontrol.EOEnterpriseObject, com.webobjects.eocontrol.EOGlobalID, com.webobjects.eocontrol.EOEditingContext)
public void removeCooperatingObjectStore(EOCooperatingObjectStore objectStore)
objectStore
from the list of EOCooperatingObjectStores that need
to be queried and notified about changes to enterprise objects.
Posts the notification CooperatingObjectStoreWasRemoved
.
objectStore
- the EOCooperatingObjectStore to remove from the
receiver's notification listaddCooperatingObjectStore(com.webobjects.eocontrol.EOCooperatingObjectStore)
,
cooperatingObjectStores()
public void saveChangesInEditingContext(EOEditingContext context)
context
. This message is sent by an EOEditingContext
to an EOObjectStoreCoordinator to commit changes. When an EOObjectStoreCoordinator
receives this message, it guides its EOCooperatingObjectStores through
a multi-pass save protocol in which each EOCooperatingObjectStore
saves its own changes and forwards remaining changes to other EOCooperatingObjectStores.
When this method is invoked, the following sequence of events occurs:
prepareForSaveWithCoordinator
, which informs them that a
multi-pass save operation is beginning. When the EOCooperatingObjectStore
is an EODatabaseContext (EOAccess), it takes this opportunity to
generate primary keys for any new objects in the EOEditingContext.recordChangesInEditingContext
, which prompts them to examine
the changed objects in the editing context, record operations that
need to be performed, and notify the receiver of any changes that
need to be forwarded to other stores. For example, if in its recordChangesInEditingContext
method one EOCooperatingObjectStore notices the removal of an object
from an owning relationship but that object belongs to another
EOCooperatingObjectStore, it informs the other store by sending
the coordinator a forwardUpdateForObject
message. ownsGlobalID
. This tells the stores to transmit their changes
to their underlying databases. When the EOCooperatingObjectStore
is an EODatabaseContext, it responds to this message by taking the
EODatabaseOperations (EOAccess) that were constructed in the previous
step, constructing EOAdaptorOperations (EOAccess) from them, and
giving the EOAdaptorOperations to an available EOAdaptorChannel
(EOAccess) for execution.ownsGlobalID
fails for any of the EOCooperatingObjectStores,
all stores are sent the message rollbackChanges
.ownsGlobalID
succeeds for all EOCooperatingObjectStores,
the receiver sends them the message commitChanges
, which has the
effect of telling the adaptor to commit the changes. commitChanges
fails for a particular EOCooperatingObjectStore,
that store and all subsequent ones are sent the message rollbackChanges
.
However, the stores that have already committed their changes do
not roll back. In other words, the coordinator doesn't perform
the two-phase commit protocol necessary to guarantee consistent
distributed update.
saveChangesInEditingContext
in class EOObjectStore
context
- EOEditingContext that will have its object graph changes savedEOEditingContext.saveChangesInEditingContext(com.webobjects.eocontrol.EOEditingContext)
,
EODatabaseContext.saveChangesInEditingContext(com.webobjects.eocontrol.EOEditingContext)
,
EOAdaptor
public static void setDefaultCoordinator(EOObjectStoreCoordinator coordinator)
coordinator
- the new shared instance EOObjectStoreCoordinatorpublic void setUserInfo(NSDictionary userInfo)
userInfo
- dictionary of application defined datauserInfo()
public void unlock()
unlock
in interface NSLocking
unlock
in class EOObjectStore
lock()
,
EOObjectStore.unlock()
public NSDictionary userInfo()
setUserInfo(com.webobjects.foundation.NSDictionary)
public NSDictionary valuesForKeys(NSArray keys, EOEnterpriseObject object)
valuesForKeys
message (through the coordinator).
keys
- NSArray of keys to return values forobject
- the EOEnterpriseObject to return values for
|
Last updated Thu Oct 21 15:04:16 PDT 2004. | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |