|
|
Re: P/Users, does not match outer scope rule [message #993841 is a reply to message #992231] |
Tue, 25 December 2012 17:35 |
Lukas Huser Messages: 42 Registered: March 2010 |
Member |
|
|
Hi Jérémie
It looks like you get this error because of conflicting scheduling rules while accessing a resource (a file or folder).
Code executed in one of the Scout model classes (such as execClickAction() on a button) is typically running inside a ClientSyncJob. All ClientSyncJobs are guaranteed to run sequentially; the current implementation is using a scheduling rule (ClientRule) which is set on the job. An ISchedulingRule basically represents a semaphore, allowing for exclusive access to a given resource, or in our case, for a sequential scheduling order. However, by design of the Jobs API, any given job can only aquire a single scheduling rule at the time (unless you are using hierarchical scheduling rules...).
An IResource (a file or a folder) also represents (inherits from) ISchedulingRule. Any (modifying) access to such a resource is guarded by the respective scheduling rule. We now get a runtime exception when trying to aquire the scheduling rule for such a resource, because we are already holding an (unrelated) scheduling rule in our ClientSyncJob.
For more information on the Jobs API and scheduling rules, see the following references:
http://www.eclipse.org/articles/Article-Concurrency/jobs-api.html
http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.isv/guide/runtime_jobs_rules.htm?cp=2_0_3_5_2
As a workaround, it should be possible to start another ClientAsyncJob (which does not hold any scheduling rules) from within execClickAction to perform your resource related operations. You can wait for the async job to finish using the join() method.
|
|
|
Re: P/Users, does not match outer scope rule [message #995829 is a reply to message #993841] |
Mon, 31 December 2012 08:04 |
Jeremie Bresson Messages: 1252 Registered: October 2011 |
Senior Member |
|
|
@Adrian Moser:
I try to serialize an EObject to XMI with the ECore tools (Bundle: org.eclipse.emf.ecore.xmi).
A minimal example could be:
@Override
protected void execClickAction() throws ProcessingException {
EPackage ePackage;
ePackage = EcoreFactory.eINSTANCE.createEPackage()
ePackage.setName("test");
ePackage.setNsPrefix("t");
ePackage.setNsURI("http://test.com/test");
ResourceSetImpl resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new XMIResourceFactoryImpl());
URI uri = URI.createURI(ROOT_PATH + "test.ecore");
org.eclipse.emf.ecore.resource.Resource resource = resourceSet.createResource(uri);
resource.getContents().add(ePackage);
try {
resource.save(null);
} catch (IOException e) {
e.printStackTrace();
}
}
@Lukas Huser:
Thanks for your explanation. I can imagine that the ECore XML serializer consider the Eclipse resource... I will try to schedule a new job that write my file to the disk.
[Updated on: Mon, 31 December 2012 08:05] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03944 seconds