Lucio Lelii 7 years ago
parent
commit
3d5467032e
  1. 1
      .settings/org.eclipse.core.resources.prefs
  2. 3
      distro/changelog.xml
  3. 2
      pom.xml
  4. 5
      src/main/java/org/gcube/common/resources/gcore/Resource.java
  5. 5
      src/main/java/org/gcube/common/resources/gcore/Resources.java

1
.settings/org.eclipse.core.resources.prefs

@ -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

3
distro/changelog.xml

@ -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

@ -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
src/main/java/org/gcube/common/resources/gcore/Resource.java

@ -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
*/

5
src/main/java/org/gcube/common/resources/gcore/Resources.java

@ -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…
Cancel
Save