This commit is contained in:
Lucio Lelii 2015-10-08 10:12:25 +00:00
parent 3637558618
commit 4c23f0c489
4 changed files with 21 additions and 13 deletions

View File

@ -1,13 +1,15 @@
The gCube System - ${name}
----------------------
This work has been partially supported by the following European projects: DILIGENT (FP6-2003-IST-2), D4Science (FP7-INFRA-2007-1.2.2),
D4Science-II (FP7-INFRA-2008-1.2.2), iMarine (FP7-INFRASTRUCTURES-2011-2), and EUBrazilOpenBio (FP7-ICT-2011-EU-Brazil).
This work has been partially supported by the following European projects: DILIGENT (FP6-2003-IST-2),
D4Science (FP7-INFRA-2007-1.2.2), D4Science-II (FP7-INFRA-2008-1.2.2), iMarine (FP7-INFRASTRUCTURES-2011-2),
and EUBrazilOpenBio (FP7-ICT-2011-EU-Brazil), Parthenos (H2020-INFRADEV-1-2014-1), BlueBridge (H2020-EINFRA-2015-1).
Authors
-------
* Fabio Simeoni (fabio.simeoni@fao.org), FAO of the UN, Italy
* Lucio Lelii (lucio.lelii@isti.cnr.it), FAO of the UN, Italy
Version and Release Date
------------------------

View File

@ -115,7 +115,7 @@ public class StubFactory<T> implements StubFactoryDSL.AtClause<T> {
// configure stub for gCube calls
registerHandler(provider, target);
return GenericProxyFactory.getProxy(target.type(), stub);
return GenericProxyFactory.getProxy(target.type(),endpointAddress, stub);
} catch (Error e) { //bad stubs/wsdls cause java.lang.Errors

View File

@ -1,22 +1,21 @@
package org.gcube.common.clients.stubs.jaxws.proxies;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GenericProxyFactory {
private static Map<String, Object> proxyMap = new HashMap<>();
public static Logger log = LoggerFactory.getLogger(MethodRetriever.class);
@SuppressWarnings("unchecked")
public static <T, I extends T> T getProxy(Class<T> intf,
public static <T, I extends T> T getProxy(Class<T> intf, String endpointAddress,
final I obj) {
if (proxyMap.containsKey(intf.getCanonicalName()))
return (T) proxyMap.get(intf.getCanonicalName());
T proxy = (T) Proxy.newProxyInstance(obj.getClass().getClassLoader(),
new Class[] { intf },
new MethodRetriever<I>(obj));
proxyMap.put(intf.getCanonicalName(), proxy);
log.debug("for interface "+intf.getCanonicalName()+" the proxy class is "+proxy.getClass().getCanonicalName());
return proxy;
}
}

View File

@ -1,6 +1,7 @@
package org.gcube.common.clients.stubs.jaxws.proxies;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
@ -22,6 +23,12 @@ public class MethodRetriever<T> implements InvocationHandler{
CalledMethodProvider.instance.set(method.getName());
try{
return method.invoke(service, args);
}catch(IllegalAccessException | IllegalArgumentException proxyEx){
log.error("error invoking method "+method.getName()+" in service "+service.getClass().getCanonicalName()+" using proxy ",proxyEx);
throw new RuntimeException(proxyEx);
}catch(InvocationTargetException ite){
log.error("error invoking method "+method.getName()+" in service "+service.getClass().getCanonicalName()+" using proxy ",ite);
throw ite.getCause();
}finally{
CalledMethodProvider.instance.reset();
}