Search in sources :

Example 1 with OServerPluginInfo

use of com.orientechnologies.orient.server.plugin.OServerPluginInfo in project orientdb by orientechnologies.

the class OServer method registerPlugins.

protected void registerPlugins() throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    pluginManager = new OServerPluginManager();
    pluginManager.config(this);
    pluginManager.startup();
    if (serverSecurity != null)
        serverSecurity.onAfterDynamicPlugins();
    // PLUGINS CONFIGURED IN XML
    final OServerConfiguration configuration = serverCfg.getConfiguration();
    if (configuration.handlers != null) {
        // ACTIVATE PLUGINS
        final List<OServerPlugin> plugins = new ArrayList<OServerPlugin>();
        for (OServerHandlerConfiguration h : configuration.handlers) {
            if (h.parameters != null) {
                // CHECK IF IT'S ENABLED
                boolean enabled = true;
                for (OServerParameterConfiguration p : h.parameters) {
                    if (p.name.equals("enabled")) {
                        enabled = false;
                        String value = OSystemVariableResolver.resolveSystemVariables(p.value);
                        if (value != null) {
                            value = value.trim();
                            if ("true".equalsIgnoreCase(value)) {
                                enabled = true;
                                break;
                            }
                        }
                    }
                }
                if (!enabled)
                    // SKIP IT
                    continue;
            }
            final OServerPlugin plugin = (OServerPlugin) loadClass(h.clazz).newInstance();
            if (plugin instanceof ODistributedServerManager)
                distributedManager = (ODistributedServerManager) plugin;
            pluginManager.registerPlugin(new OServerPluginInfo(plugin.getName(), null, null, null, plugin, null, 0, null));
            pluginManager.callListenerBeforeConfig(plugin, h.parameters);
            plugin.config(this, h.parameters);
            pluginManager.callListenerAfterConfig(plugin, h.parameters);
            plugins.add(plugin);
        }
        // START ALL THE CONFIGURED PLUGINS
        for (OServerPlugin plugin : plugins) {
            pluginManager.callListenerBeforeStartup(plugin);
            plugin.startup();
            pluginManager.callListenerAfterStartup(plugin);
        }
    }
}
Also used : OServerPluginManager(com.orientechnologies.orient.server.plugin.OServerPluginManager) ODistributedServerManager(com.orientechnologies.orient.server.distributed.ODistributedServerManager) OServerPluginInfo(com.orientechnologies.orient.server.plugin.OServerPluginInfo) OServerPlugin(com.orientechnologies.orient.server.plugin.OServerPlugin)

Aggregations

ODistributedServerManager (com.orientechnologies.orient.server.distributed.ODistributedServerManager)1 OServerPlugin (com.orientechnologies.orient.server.plugin.OServerPlugin)1 OServerPluginInfo (com.orientechnologies.orient.server.plugin.OServerPluginInfo)1 OServerPluginManager (com.orientechnologies.orient.server.plugin.OServerPluginManager)1