From f8d791846803021671537f5317c40f21833ef964 Mon Sep 17 00:00:00 2001 From: lucio Date: Tue, 29 Oct 2019 18:19:50 +0100 Subject: [PATCH] added search of LocalDiscoveryClient in case it is deployed on the Collector --- .classpath | 1 + .project | 13 +++++++++++++ pom.xml | 2 +- .../discovery/icclient/ICFactory.java | 18 +++++++++++++++--- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.classpath b/.classpath index b8c44f6..502bd4a 100644 --- a/.classpath +++ b/.classpath @@ -16,6 +16,7 @@ + diff --git a/.project b/.project index 0f0211c..55fc0f8 100644 --- a/.project +++ b/.project @@ -5,6 +5,11 @@ + + org.eclipse.wst.common.project.facet.core.builder + + + org.eclipse.jdt.core.javabuilder @@ -15,9 +20,17 @@ + + org.eclipse.wst.validation.validationbuilder + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature diff --git a/pom.xml b/pom.xml index ef500f5..4eb76c6 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.gcube.resources.discovery ic-client - 1.0.4 + 1.0.5-SNAPSHOT Information Collector Client Client API for the Information Collector service diff --git a/src/main/java/org/gcube/resources/discovery/icclient/ICFactory.java b/src/main/java/org/gcube/resources/discovery/icclient/ICFactory.java index 81b86cf..6cebd3a 100644 --- a/src/main/java/org/gcube/resources/discovery/icclient/ICFactory.java +++ b/src/main/java/org/gcube/resources/discovery/icclient/ICFactory.java @@ -17,6 +17,8 @@ import org.gcube.resources.discovery.client.api.ResultParser; import org.gcube.resources.discovery.client.impl.DelegateClient; import org.gcube.resources.discovery.client.impl.JAXBParser; import org.gcube.resources.discovery.client.queries.impl.XQuery; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Factory of {@link XQuery}s and {@link DiscoveryClient}s for the Information Collector service. @@ -26,6 +28,8 @@ import org.gcube.resources.discovery.client.queries.impl.XQuery; */ public class ICFactory { + private static Logger logger = LoggerFactory.getLogger(ICFactory.class); + // known query parameters, indexed by resource type private static Map, Map> registry = new HashMap, Map>(); @@ -85,7 +89,7 @@ public class ICFactory { * @return the client */ public static DiscoveryClient clientFor(Class type) { - return new DelegateClient(new JAXBParser(type), new ICClient()); + return new DelegateClient(new JAXBParser(type), client()); } /** @@ -95,7 +99,15 @@ public class ICFactory { * @return the client */ public static DiscoveryClient client() { - return new ICClient(); + try { + @SuppressWarnings("unchecked") + Class> localClientclass =(Class>) Class.forName("org.gcube.informationsystem.collector.client.LocalDiscoveryClient", true, Thread.currentThread().getContextClassLoader()); + logger.info("using LocalDiscoveryClient"); + return localClientclass.newInstance(); + } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) { + return new ICClient(); + } + } /** @@ -106,7 +118,7 @@ public class ICFactory { * @return the client */ public static DiscoveryClient clientWith(ResultParser parser) { - return new DelegateClient(parser, new ICClient()); + return new DelegateClient(parser, client()); } // utils