diff --git a/distro/changelog.xml b/distro/changelog.xml
index 9543198..934f4d7 100644
--- a/distro/changelog.xml
+++ b/distro/changelog.xml
@@ -6,7 +6,10 @@
Modular handler discovery and delegation
Fix: WSDL cache now releases the lock it acquires when clearing
-
+
Moved tests to separate suite
+
+ Stub cache can be safely used across multiple classloaders
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 31eef40..0239e8a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
org.gcube.core
common-gcore-stubs
- 1.1.1-SNAPSHOT
+ 1.2.0-SNAPSHOT
GCore Stubs
JAXWS Stub Support for gCore Service
diff --git a/src/main/java/org/gcube/common/clients/stubs/jaxws/StubCache.java b/src/main/java/org/gcube/common/clients/stubs/jaxws/StubCache.java
index 4f2468d..9bd5a1b 100644
--- a/src/main/java/org/gcube/common/clients/stubs/jaxws/StubCache.java
+++ b/src/main/java/org/gcube/common/clients/stubs/jaxws/StubCache.java
@@ -6,7 +6,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import org.slf4j.Logger;
@@ -28,9 +27,9 @@ class StubCache {
private volatile LRUCache cache = new LRUCache();
//holds key locks for LRU map
- private ConcurrentHashMap nameLocks = new ConcurrentHashMap();
+ private ConcurrentHashMap,Lock> nameLocks = new ConcurrentHashMap, Lock>();
- void clear(QName name) {
+ void clear(Class> name) {
//obtain a lock for current key
Lock nameLock = lockFor(name);
@@ -47,28 +46,28 @@ class StubCache {
}
- Service get(QName name,Callable task) {
+ Service get(Class> type,Callable task) {
//obtain a lock for current key
- Lock nameLock = lockFor(name);
+ Lock nameLock = lockFor(type);
nameLock.lock();
try {
- Service service = cache.get(name);
+ Service service = cache.get(type);
if (service==null)
try {
service= task.call();
- log.trace("caching stub for "+name);
- cache.put(name,service);
+ log.info("caching stub for "+type);
+ cache.put(type,service);
}
catch(Exception e) {
throw new RuntimeException("could not build service",e);
}
else {
- log.trace("using cached stub for "+name);
+ log.info("using cached stub for "+type);
}
return service;
@@ -79,7 +78,7 @@ class StubCache {
}
//helper
- private Lock lockFor(QName name) {
+ private Lock lockFor(Class> name) {
Lock nameLock = nameLocks.get(name);
@@ -99,7 +98,7 @@ class StubCache {
return nameLock;
}
- private class LRUCache extends LinkedHashMap {
+ private class LRUCache extends LinkedHashMap,Service> {
private static final long serialVersionUID = 1L;
@@ -111,7 +110,7 @@ class StubCache {
}
@Override
- protected boolean removeEldestEntry(java.util.Map.Entry eldest) {
+ protected boolean removeEldestEntry(java.util.Map.Entry, Service> eldest) {
if (size()>=max) {
nameLocks.remove(eldest.getKey());
return true;
diff --git a/src/main/java/org/gcube/common/clients/stubs/jaxws/StubFactory.java b/src/main/java/org/gcube/common/clients/stubs/jaxws/StubFactory.java
index 6db647a..9ced1c6 100644
--- a/src/main/java/org/gcube/common/clients/stubs/jaxws/StubFactory.java
+++ b/src/main/java/org/gcube/common/clients/stubs/jaxws/StubFactory.java
@@ -102,7 +102,7 @@ public class StubFactory implements StubFactoryDSL.AtClause {
try {
// get JAXWS service from endpoint address
- Service service = buildService(endpointAddress+"?wsdl", target.qName());
+ Service service = buildService(endpointAddress+"?wsdl", target.type(),target.qName());
// get JAXWS stub
T stub = service.getPort(reference,target.type(),features);
@@ -116,7 +116,7 @@ public class StubFactory implements StubFactoryDSL.AtClause {
} catch (Error e) { //bad stubs/wsdls cause java.lang.Errors
- cache.clear(target.qName()); //clear cache
+ cache.clear(target.type()); //clear cache
throw new RuntimeException("could not configure discovery service", e);
@@ -136,7 +136,7 @@ public class StubFactory implements StubFactoryDSL.AtClause {
}
// helper
- private synchronized Service buildService(final String wsdlAddress, final QName name) throws Exception {
+ private synchronized Service buildService(final String wsdlAddress, final Class> type, final QName name) throws Exception {
Callable task = new Callable() {
@Override
@@ -146,7 +146,7 @@ public class StubFactory implements StubFactoryDSL.AtClause {
}
};
- Service service = cache.get(name,task);
+ Service service = cache.get(type,task);
return service;
}