Re: Trying to clear a dead-lock of some type
Re: Trying to clear a dead-lock of some type
- Subject: Re: Trying to clear a dead-lock of some type
- From: Chuck Hill <email@hidden>
- Date: Thu, 19 May 2005 13:49:42 -0700
In addition to all the other good advice...
public void SearchForSixAMTasks() {
TimeZone tz = TimeZone.getTimeZone("Etc/GMT");
NSTimestamp SixAM = new NSTimestamp(1899, 12, 30, 14, 2, 0, tz);
NSMutableArray args = new NSMutableArray();
args.addObject(SixAM);
args.addObject("0");
EOQualifier qualifier =
EOQualifier.qualifierWithQualifierFormat("starttime = %@ AND
taskcompletedindicator = %@", args);
EOFetchSpecification spec = new EOFetchSpecification("Tbltasks",
qualifier, null);
spec.setRefreshesRefetchedObjects(true); // Use fresh data
EOEditingContext ec = new EOEditingContext();
ec.lock();
try {
NSArray array = ec.objectsWithFetchSpecification(spec);
NSMutableArray foundTasks = new NSMutableArray(array);
Enumeration e = foundTasks.objectEnumerator();
while(e.hasMoreElements()) {
Tbltasks currentTask = (Tbltasks)e.nextElement();
// TaskReview is a process, not an EO - right?
TaskReview review = new TaskReview();
System.out.println(currentTask.taskcomment() + " -
before
change.");
review.GetRepsData(currentTask); //data is
read,modified,etc. in this method
System.out.println(currentTask.taskcompletedindicator());
System.out.println(currentTask.alarmindicator());
}
ec.saveChanges();
} catch (Exception e) {
// - Definite potential for locking issues with TPE, but
only when intentionally trying to break it
System.out.println("RepeatingTask: exception in
SearchForSixAMTasks()");
}
finally {
ec.unlock();
ec.dispose();
}
}
On May 19, 2005, at 12:22 PM, WebObjects wrote:
The following function works consistently, unless there is some
contention
(I'm sharing a datasource with other applications). There is the
expected
issue of saving to a locked row - but even if I trap the exception,
then
repeat this function some time later (after I'm certain the other apps
are
not locking the same rows) I still get the same contention.
First, do you see anything in this method that is out of place or
sequence?
(it occurs in a TimerTask within Application) I'm not 100% certain
that my
ec.refreshAllObjects is place in the proper place.
Advice is greatly appreciated!
-Bill
public void SearchForSixAMTasks() {
try{
TimeZone tz = TimeZone.getTimeZone("Etc/GMT");
NSTimestamp SixAM = new NSTimestamp(1899, 12, 30, 14, 2, 0,
tz);
NSMutableArray args = new NSMutableArray();
args.addObject(SixAM);
args.addObject("0");
EOQualifier qualifier =
EOQualifier.qualifierWithQualifierFormat("starttime = %@ AND
taskcompletedindicator = %@", args);
EOFetchSpecification spec = new
EOFetchSpecification("Tbltasks",
qualifier, null);
EOEditingContext ec = new EOEditingContext();
ec.refreshAllObjects();
//lock EC
ec.lock();
//Fetch
NSArray array = ec.objectsWithFetchSpecification(spec);
NSMutableArray foundTasks = new NSMutableArray(array);
Enumeration e = foundTasks.objectEnumerator();
while(e.hasMoreElements()) {
Tbltasks currentTask = (Tbltasks)e.nextElement();
TaskReview review = new TaskReview();
System.out.println(currentTask.taskcomment() + " -
before
change.");
review.GetRepsData(currentTask); //data is
read,modified,etc. in this method
System.out.println(currentTask.taskcompletedindicator());
System.out.println(currentTask.alarmindicator());
}
ec.saveChanges();
//-- unlock EC
ec.unlock();
ec.refreshAllObjects();
} catch (Exception e) {
// - Definite potential for locking issues with
TPE, but
only when intentionally trying to break it
System.out.println("RepeatingTask: exception in
SearchForSixAMTasks()");
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
village.net
This email sent to email@hidden
--
Practical WebObjects - a book for intermediate WebObjects developers
who want to increase their overall knowledge of WebObjects, or those
who are trying to solve specific application development 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