• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Invalidating objects asynchronously
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Invalidating objects asynchronously


  • Subject: Re: Invalidating objects asynchronously
  • From: Chuck Hill <email@hidden>
  • Date: Mon, 8 Sep 2008 17:32:45 -0700


On Sep 8, 2008, at 5:26 PM, Mike Schrag wrote:

Do you mean that attributes of the EO are suddenly null? I don't see how this is possible _unless_ you are looking at objects that are in an EOEditingContext that is not locked. That won't ever work reliably.
I'm assuming the root problem here is the old JMS stuff would invalidate objects, which means you end up in a very unreliable state. But I wasn't digging too much into it.


Hmmm, maybe if that happened before willRead() was called, this might still happen. But after the fault is fired, the attribute values should be stable if the EC is locked as it queues the notifications rather than responding to them. So, to be sure you had a real, live object, you could:

eo.willRead();
if ( ! eo.isDummyFaultEO(eo) ) {
	// process
}



/**
* Detecting WO 5 dummy fault EOs. The code below is a translation of code posted here:
* From http://wodeveloper.com/omniLists/eof/2001/November/msg00023.html
*
* As of WO4.5, EOF resolves faults for objects that don't exist in the database to a dummy object with mostly empty attributes (except those
that are set in -init), whereas earlier versions of EOF threw a _fireFault exception. This method detects whether the receiver is such a dummy object.
*
* A distinguishing feature of these dummy EOs is that they don't have a corresponding database context snapshot, so we use this to detect its dummy-ness. This seems more robust than checking if all or most attributes are empty, since these can be changed by client code.
*
* Dummy fault EOs should be removed from the editingContext (using forgetObject) before it is invalidated (invalidateAllObjects or invalidateObjectWithGlobalID), otherwise an unrecoverable "decrementSnapshotCountForGlobalID - unable to decrement snapshot count for object with global ID" exception is thrown by EOF.<br><br>
*
* See also: http://www.omnigroup.com/mailman/archive/eof/2001-May/001988.html andfollowing.
*/
public static boolean isDummyFaultEO(EOEnterpriseObject anObject)
{
/** require [valid_param] anObject != null; **/
JassAdditions.pre("EOObject", "isDummyFaultEO [object_in_ec]", anObject.editingContext() != null);
JassAdditions.pre("EOObject", "isDummyFaultEO [object_has_global_id]", anObject.editingContext().globalIDForObject(anObject) != null);


        boolean isDummyFaultEO = false;

// This method will fail if the object is still a fault. We fire the fault so that the correct result is returned.
if (anObject.isFault())
{
anObject.willRead();
}


        EOEditingContext ec = anObject.editingContext();
        EOGlobalID globalID = ec.globalIDForObject(anObject);

// NB. objects with temporary globalIDs legitimately have no DB snapshots, since these are by definition not yet saved to the database.
if (! globalID.isTemporary())
{
// Find the EODatabaseContext instance associated with anObject, or null if no databaseContext association can be found.
EOObjectStoreCoordinator rootStore = (EOObjectStoreCoordinator)ec.rootObjectStore();
rootStore.lock();
try
{
EODatabaseContext dbContext = (EODatabaseContext)rootStore.objectStoreForObject(anObject);
if (dbContext == null)
{
throw new RuntimeException("Could not locate EODatabaseContext for object '" +
anObject + "' in editingContext: " + ec);
}


isDummyFaultEO = (dbContext.snapshotForGlobalID(globalID) == null);
}
finally
{
rootStore.unlock();
}
}


        return isDummyFaultEO;
    }



Chuck

--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects







_______________________________________________ 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
  • Follow-Ups:
    • Re: Invalidating objects asynchronously
      • From: Peter Vandoros <email@hidden>
References: 
 >Invalidating objects asynchronously (From: Dan Grec <email@hidden>)
 >Re: Invalidating objects asynchronously (From: Mike Schrag <email@hidden>)
 >Re: Invalidating objects asynchronously (From: Dan Grec <email@hidden>)
 >Re: Invalidating objects asynchronously (From: Chuck Hill <email@hidden>)
 >Re: Invalidating objects asynchronously (From: Mike Schrag <email@hidden>)

  • Prev by Date: Re: Project Wonder Stable Release???
  • Next by Date: Re: Project Wonder Stable Release???
  • Previous by thread: Re: Invalidating objects asynchronously
  • Next by thread: Re: Invalidating objects asynchronously
  • Index(es):
    • Date
    • Thread