gcube-sdi-suite/sdi-interface/src/main/java/org/gcube/spatial/data/clients/SDIClientManager.java

40 lines
1.0 KiB
Java
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package org.gcube.spatial.data.clients;
import java.util.ArrayList;
import java.util.Collection;
import java.util.ServiceLoader;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class SDIClientManager {
private Collection<SDIGenericClient> clients=new ArrayList<SDIGenericClient>();
public SDIClientManager() {
ServiceLoader.load(SDIGenericClient.class).forEach((SDIGenericClient c)->{clients.add(c);});
log.info("Loaded {} clients ",clients.size());
clients.forEach((SDIGenericClient c)->{
log.debug("Loaded "+c.getInfo());
});
}
/**
* Returns the implementation for the target engine. Null if no suitable plugin is found
*
* @param engine
* @param version
* @return
*/
public SDIGenericClient get(String engine,String version) {
log.info("Looking for clients [target : {} {} ] ",engine,version);
for(SDIGenericClient c:clients) {
if(c.getInfo().getSupportedEngine().getEngineUniqueString().equals(engine)
&& c.getInfo().getSupportedEngine().getRange().supports(version))
return c;
}
return null;
}
}