• 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: editing context locking
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: editing context locking


  • Subject: Re: editing context locking
  • From: Florijan Stamenkovic <email@hidden>
  • Date: Wed, 6 Apr 2005 23:15:47 +0200

Yes, I did go through Practical WO on locking, and know about the defaultEC, and having multithreading debugging on. And know that is regarded as the best practice, and am using exactly what you described (create and lock in constructor, unlock in sleep, lock in awake).

I was just wondering was it in this case necessary... Because it is impossible for any other concurrent user to try to fetch, insert, update or whatever on those objects, as they are still not "officially" there. And that is what locking is supposed to prevent in the first place, right???

So, I see that it is best practice and a "law to obey", but is it in the situation of creating new objects in a new editing context necessary?



Oh... And for disposing the ec i use:

public void sleep()
{
ec.unlock();
System.out.println("ADDDRAWING component sleep() called - ec unlocked");
if(! ec.hasChanges()) //in my construction in can not be without changes unless it was just saved to the parent ec
{
System.out.println("ADDDRAWING component sleep() called - will dispose ec");
ec.dispose();
System.out.println("ADDDRAWING component sleep() called - did dispose ec");
}
super.sleep();
}


Logging told me that all the right actions are happening in the right time. Is this really the way to do it???


On Apr 06, 2005, at 21:06, Kaj Hejer wrote:


On 6. apr 2005, at 20.45, Florijan Stamenkovic wrote:

When I am creating new objects within a completely new editing context (nested into the default one) do I _need_ to lock???

Yes! You should always lock any ec you create yourself. The only ec you don't need to lock is session.defaultEditingContext.


The best thing is to lock the ec just after it is created. You can unlock f.x. in sleep in the component (or some other place :)

You might want to take a look at MultiECLockManager, see <http://www.wocode.com/WOCode/Files/MultiECLockManager.java>

To dedect access to any ec that is not lock (as it should be! :) add the following lines to the constructor in your Application.java:

NSLog.debug.setAllowedDebugLevel(NSLog.DebugLevelInformational);
NSLog.allowDebugLoggingForGroups(NSLog.DebugGroupMultithreading);
setAllowsConcurrentRequestHandling(true);


You find a good guide to the art of locking editingcontexts in the book "Practical WebObjects", see <http://www.global-village.net/products/practical_webobjects>.


-Kaj :)

_______________________________________________ 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: editing context locking
      • From: Chris Hanson <email@hidden>
    • Re: editing context locking
      • From: Chuck Hill <email@hidden>
References: 
 >editing context locking (From: Florijan Stamenkovic <email@hidden>)
 >Re: editing context locking (From: Kaj Hejer <email@hidden>)

  • Prev by Date: Re: Deployment in windows 2000 help
  • Next by Date: Re: editing context locking
  • Previous by thread: Re: editing context locking
  • Next by thread: Re: editing context locking
  • Index(es):
    • Date
    • Thread