Re: Deadlock using EOObjectStore.invalidateObjectsWithGlobalIDs(NSArray)
Re: Deadlock using EOObjectStore.invalidateObjectsWithGlobalIDs(NSArray)
- Subject: Re: Deadlock using EOObjectStore.invalidateObjectsWithGlobalIDs(NSArray)
- From: Gary Teter <email@hidden>
- Date: Wed, 20 Sep 2006 10:06:07 -0700
My superstition: Lock the root object store instead of just the
database context.
try {
WHEnterpriseObject.lockRootObjectStore(editingContext);
// do stuff
} finally {
WHEnterpriseObject.unlockRootObjectStore(editingContext);
}
public static void lockRootObjectStore(EOObjectStore objectStore) {
EOObjectStoreCoordinator osc = _objectStoreCoordinator
(objectStore);
osc.lock();
}
public static void unlockRootObjectStore(EOObjectStore
objectStore) {
EOObjectStoreCoordinator osc = _objectStoreCoordinator
(objectStore);
osc.unlock();
}
private static EOObjectStoreCoordinator _objectStoreCoordinator
(Object objectStore) {
if (objectStore == null) {
return EOObjectStoreCoordinator.defaultCoordinator();
} else if (objectStore instanceof EOObjectStoreCoordinator) {
return (EOObjectStoreCoordinator)objectStore;
} else if (objectStore instanceof EOEditingContext) {
return (EOObjectStoreCoordinator)((EOEditingContext)
objectStore).rootObjectStore();
} else if (objectStore instanceof EOCooperatingObjectStore) {
return (EOObjectStoreCoordinator)
((EOCooperatingObjectStore)objectStore).coordinator();
} else if (objectStore instanceof EODatabase) {
NSArray dbContexts = ((EODatabase)
objectStore).registeredContexts();
if (dbContexts.count() > 0) {
EODatabaseContext dbContext = (EODatabaseContext)
dbContexts.objectAtIndex(0);
return dbContext.coordinator();
} else {
return EOObjectStoreCoordinator.defaultCoordinator();
}
} else {
throw new IllegalArgumentException("Unable to determine
EOObjectStoreCoordinator for objects of type " + objectStore.getClass
().getName());
}
}
On Sep 20, 2006, at 9:50 AM, Chuck Hill wrote:
editingContext.lockObjectStore();
Probably just superstition, but I always get the EODatabaseContext
directly and lock it.
--
WireHose: Smart metadata and personalization for WebObjects.
http://www.wirehose.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden