40 lines
1.0 KiB
Java
40 lines
1.0 KiB
Java
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;
|
||
}
|
||
}
|