use of com.baidu.hugegraph.plugin.HugeGraphPlugin in project incubator-hugegraph by apache.
the class RegisterUtil method registerPlugins.
/**
* Scan the jars in plugins directory and load them
*/
public static void registerPlugins() {
ServiceLoader<HugeGraphPlugin> plugins = ServiceLoader.load(HugeGraphPlugin.class);
for (HugeGraphPlugin plugin : plugins) {
LOG.info("Loading plugin {}({})", plugin.name(), plugin.getClass().getCanonicalName());
String minVersion = plugin.supportsMinVersion();
String maxVersion = plugin.supportsMaxVersion();
if (!VersionUtil.match(CoreVersion.VERSION, minVersion, maxVersion)) {
LOG.warn("Skip loading plugin '{}' due to the version range " + "'[{}, {})' that it's supported doesn't cover " + "current core version '{}'", plugin.name(), minVersion, maxVersion, CoreVersion.VERSION.get());
continue;
}
try {
plugin.register();
LOG.info("Loaded plugin '{}'", plugin.name());
} catch (Exception e) {
throw new HugeException("Failed to load plugin '%s'", plugin.name(), e);
}
}
}
Aggregations