Search in sources :

Example 1 with HugeGraphPlugin

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);
        }
    }
}
Also used : HugeException(com.baidu.hugegraph.HugeException) HugeGraphPlugin(com.baidu.hugegraph.plugin.HugeGraphPlugin) ConfigurationException(org.apache.commons.configuration2.ex.ConfigurationException) HugeException(com.baidu.hugegraph.HugeException)

Aggregations

HugeException (com.baidu.hugegraph.HugeException)1 HugeGraphPlugin (com.baidu.hugegraph.plugin.HugeGraphPlugin)1 ConfigurationException (org.apache.commons.configuration2.ex.ConfigurationException)1