added search of LocalDiscoveryClient in case it is deployed on the

Collector
This commit is contained in:
lucio 2019-10-29 18:19:50 +01:00
parent 4dc045bdee
commit f8d7918468
4 changed files with 30 additions and 4 deletions

View File

@ -16,6 +16,7 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">

View File

@ -5,6 +5,11 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
@ -15,9 +20,17 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>

View File

@ -9,7 +9,7 @@
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
<version>1.0.4</version>
<version>1.0.5-SNAPSHOT</version>
<name>Information Collector Client</name>
<description>Client API for the Information Collector service</description>

View File

@ -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<Class<?>, Map<String, String>> registry = new HashMap<Class<?>, Map<String, String>>();
@ -85,7 +89,7 @@ public class ICFactory {
* @return the client
*/
public static <R> DiscoveryClient<R> clientFor(Class<R> type) {
return new DelegateClient<R>(new JAXBParser<R>(type), new ICClient());
return new DelegateClient<R>(new JAXBParser<R>(type), client());
}
/**
@ -95,7 +99,15 @@ public class ICFactory {
* @return the client
*/
public static DiscoveryClient<String> client() {
return new ICClient();
try {
@SuppressWarnings("unchecked")
Class<? extends DiscoveryClient<String>> localClientclass =(Class<? extends DiscoveryClient<String>>) 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 <R> DiscoveryClient<R> clientWith(ResultParser<R> parser) {
return new DelegateClient<R>(parser, new ICClient());
return new DelegateClient<R>(parser, client());
}
// utils