added search of LocalDiscoveryClient in case it is deployed on the
Collector
This commit is contained in:
parent
4dc045bdee
commit
f8d7918468
|
@ -16,6 +16,7 @@
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
|
|
13
.project
13
.project
|
@ -5,6 +5,11 @@
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
<buildSpec>
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
|
@ -15,9 +20,17 @@
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<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.jdt.core.javanature</nature>
|
||||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.resources.discovery</groupId>
|
<groupId>org.gcube.resources.discovery</groupId>
|
||||||
<artifactId>ic-client</artifactId>
|
<artifactId>ic-client</artifactId>
|
||||||
<version>1.0.4</version>
|
<version>1.0.5-SNAPSHOT</version>
|
||||||
<name>Information Collector Client</name>
|
<name>Information Collector Client</name>
|
||||||
<description>Client API for the Information Collector service</description>
|
<description>Client API for the Information Collector service</description>
|
||||||
|
|
||||||
|
|
|
@ -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.DelegateClient;
|
||||||
import org.gcube.resources.discovery.client.impl.JAXBParser;
|
import org.gcube.resources.discovery.client.impl.JAXBParser;
|
||||||
import org.gcube.resources.discovery.client.queries.impl.XQuery;
|
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.
|
* 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 {
|
public class ICFactory {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(ICFactory.class);
|
||||||
|
|
||||||
// known query parameters, indexed by resource type
|
// known query parameters, indexed by resource type
|
||||||
private static Map<Class<?>, Map<String, String>> registry = new HashMap<Class<?>, Map<String, String>>();
|
private static Map<Class<?>, Map<String, String>> registry = new HashMap<Class<?>, Map<String, String>>();
|
||||||
|
|
||||||
|
@ -85,7 +89,7 @@ public class ICFactory {
|
||||||
* @return the client
|
* @return the client
|
||||||
*/
|
*/
|
||||||
public static <R> DiscoveryClient<R> clientFor(Class<R> type) {
|
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,9 +99,17 @@ public class ICFactory {
|
||||||
* @return the client
|
* @return the client
|
||||||
*/
|
*/
|
||||||
public static DiscoveryClient<String> client() {
|
public static DiscoveryClient<String> client() {
|
||||||
|
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();
|
return new ICClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link DiscoveryClient} that submits queries to the Information Collector service and parses query results with a
|
* Returns a {@link DiscoveryClient} that submits queries to the Information Collector service and parses query results with a
|
||||||
* given {@link ResultParser}.
|
* given {@link ResultParser}.
|
||||||
|
@ -106,7 +118,7 @@ public class ICFactory {
|
||||||
* @return the client
|
* @return the client
|
||||||
*/
|
*/
|
||||||
public static <R> DiscoveryClient<R> clientWith(ResultParser<R> parser) {
|
public static <R> DiscoveryClient<R> clientWith(ResultParser<R> parser) {
|
||||||
return new DelegateClient<R>(parser, new ICClient());
|
return new DelegateClient<R>(parser, client());
|
||||||
}
|
}
|
||||||
|
|
||||||
// utils
|
// utils
|
||||||
|
|
Loading…
Reference in New Issue