git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/common/common-gcore-resources/1.3@115634 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
54d9fcf300
commit
3d5467032e
|
@ -1,4 +1,3 @@
|
|||
#Mon Dec 03 17:40:30 CET 2012
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
|
|
|
@ -19,4 +19,7 @@
|
|||
<Changeset component="common-gcore-resources-1.3.0" date="2015-04-27">
|
||||
<Change>Deprecated localAvailableStorage() methods and added replacements localAvailableSpace()</Change>
|
||||
</Changeset>
|
||||
<Changeset component="common-gcore-resources-1.3.1" date="2015-06-30">
|
||||
<Change>Added lock on resource unmashalling</Change>
|
||||
</Changeset>
|
||||
</ReleaseNotes>
|
2
pom.xml
2
pom.xml
|
@ -8,7 +8,7 @@
|
|||
</parent>
|
||||
<groupId>org.gcube.resources</groupId>
|
||||
<artifactId>common-gcore-resources</artifactId>
|
||||
<version>1.3.0-SNAPSHOT</version>
|
||||
<version>1.3.1-SNAPSHOT</version>
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/${project.artifactId}</connection>
|
||||
|
|
|
@ -5,6 +5,8 @@ import java.util.LinkedHashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
@ -22,6 +24,9 @@ public abstract class Resource {
|
|||
//default resource type version
|
||||
private static String CURRENT_VERSION = "0.4.x";
|
||||
|
||||
|
||||
protected transient Lock lock = new ReentrantLock();
|
||||
|
||||
/**
|
||||
* The type of the resource
|
||||
*/
|
||||
|
|
|
@ -147,6 +147,8 @@ public class Resources {
|
|||
*/
|
||||
public static <T extends Result> T marshal(Object resource,T result) {
|
||||
|
||||
if (resource instanceof Resource)
|
||||
((Resource) resource).lock.lock();
|
||||
try {
|
||||
JAXBContext context = context(resource.getClass());
|
||||
Marshaller m = context.createMarshaller();
|
||||
|
@ -158,6 +160,9 @@ public class Resources {
|
|||
}
|
||||
catch(Exception e) {
|
||||
throw new RuntimeException("serialisation error",e);
|
||||
} finally{
|
||||
if (resource instanceof Resource)
|
||||
((Resource) resource).lock.unlock();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue