• 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: To Many Fault and Locking
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: To Many Fault and Locking


  • Subject: Re: To Many Fault and Locking
  • From: Chuck Hill <email@hidden>
  • Date: Tue, 18 May 2004 09:22:29 -0700

Yes, sessionless direct actions and ec locking can be a nuisance. The problem is that the unlocked access that you see takes place when generateResponse() is called on the page returned from the action. This happens long after DirectAction.performActionNamed returns. The easiest solution is to do something like this:

WOResponse response = null;
EOEditingContext ec = new EOEditingContext();
ec.lock();
try {
     WOComponent resultPage = pageWithName("...");
    // Do whatever you need here
    // Calls appendToResponse, does all EOF access while ec locked
    response = resultPage.generateResponse();
}
finally {
    ec.unlock();
    ec.dispose();
}

return response;


Note that WOResponse (what we are returning) implements generateResponse() as:
public WOActionResults generateResponse() { return this;}
so there is no danger of unlocked access.


Hope that helps.


Chuck


On May 17, 2004, at 8:45 AM, Hunter Hillegas wrote:

Let me elaborate a bit...

This component is setup by a direct action. There is no session. I was under the impression that to use the MultiECLockManager I need to be using session derived ECs. Maybe I should look at the code again.

The value is grabbed by a a binding in the template, on the page, not from code in my .java file - so then, how do I get the EC locked at that point? The EO is fetched via the EC in the constructor after having some work done by the DirectAction. Once I leave the constructor, I unlock my EC. Then, WOF pulls the value from the EO and I get the locking exception.

So, I guess I'm not sure how to lock the EO since the exception is being generated while in my Java code, but from the component template.

Does that make more sense?

On May 16, 2004, at 10:16 PM, Chuck Hill wrote:

The best thing is to keep the EC locked. You should not do anything to any
eo in an ec unless the ec is locked. See the MultiECLockManager on WOCode
for a good solution to this.



Chuck



At 01:19 PM 16/05/2004 -0700, you wrote:
I have an entity, Hotel, that has a toMany relationship with another
entity, Restaurant.

I fetch a hotel via a locked editing context. It fetches fine.

I assume at this point that the restaurants() relationship hasn't been
fetched, it is a fault.


Later on in the same component, I call restaurants().count(). This
triggers all of the locking exceptions, as at that point the EC that
the object is in has been unlocked... So... Is the best thing to do
here to fire that fault before I unlock the EC, right after I do the
fetch?

Hunter

_______________________________________________
WebObjects-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/webobjects-dev


--

Chuck Hill email@hidden
Global Village Consulting Inc. http://www.global-village.net
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: To Many Fault and Locking (From: Hunter Hillegas <email@hidden>)

  • Prev by Date: RE: How to make URL shorter?
  • Next by Date: inserting files into projects
  • Previous by thread: Re: To Many Fault and Locking
  • Next by thread: Re: XHTML/WO help for XCode
  • Index(es):
    • Date
    • Thread