/** * @param cls Component class. * @param <T> Component type. * @return Component class instance or {@code null} if no one plugin override this component. */ public <T> T createComponent(Class<T> cls) { for (PluginProvider plugin : plugins.values()) { PluginContext ctx = pluginContextForProvider(plugin); T comp = (T) plugin.createComponent(ctx, cls); if (comp != null) return comp; } return null; }
/** {@inheritDoc} */ @Override public void onDiscoveryDataReceived(UUID nodeId, UUID rmtNodeId, Serializable data) { Map<String, Serializable> discData = (Map<String, Serializable>) data; if (discData != null) { for (Map.Entry<String, Serializable> e : discData.entrySet()) { PluginProvider provider = plugins.get(e.getKey()); if (provider != null) provider.receiveDiscoveryData(nodeId, e.getValue()); else U.warn(log, "Received discovery data for unknown plugin: " + e.getKey()); } } }
/** Print plugins information. */ private void ackPluginsInfo() { U.quietAndInfo(log, "Configured plugins:"); if (plugins.isEmpty()) { U.quietAndInfo(log, " ^-- None"); U.quietAndInfo(log, ""); } else { for (PluginProvider plugin : plugins.values()) { U.quietAndInfo(log, " ^-- " + plugin.name() + " " + plugin.version()); U.quietAndInfo(log, " ^-- " + plugin.copyright()); U.quietAndInfo(log, ""); } } }
/** * @param ctx Kernal context. * @param cfg Ignite configuration. * @param providers Plugin providers. */ @SuppressWarnings("TypeMayBeWeakened") public IgnitePluginProcessor( GridKernalContext ctx, IgniteConfiguration cfg, List<PluginProvider> providers) { super(ctx); ExtensionRegistryImpl registry = new ExtensionRegistryImpl(); for (PluginProvider provider : providers) { GridPluginContext pluginCtx = new GridPluginContext(ctx, cfg); if (F.isEmpty(provider.name())) throw new IgniteException("Plugin name can not be empty."); if (plugins.containsKey(provider.name())) throw new IgniteException("Duplicated plugin name: " + provider.name()); plugins.put(provider.name(), provider); pluginCtxMap.put(provider, pluginCtx); provider.initExtensions(pluginCtx, registry); if (provider.plugin() == null) throw new IgniteException("Plugin is null."); } extensions = registry.createExtensionMap(); }
/** {@inheritDoc} */ @Nullable @Override public IgniteNodeValidationResult validateNode(ClusterNode node) { try { plugin.validateNewNode(node); return null; } catch (PluginValidationException e) { return new IgniteNodeValidationResult(e.nodeId(), e.getMessage(), e.remoteMessage()); } }
/** {@inheritDoc} */ @Override public void onKernalStop(boolean cancel) { plugin.onIgniteStop(cancel); }
/** {@inheritDoc} */ @Override public void onKernalStart() throws IgniteCheckedException { plugin.onIgniteStart(); }
/** {@inheritDoc} */ @Override public void stop(boolean cancel) throws IgniteCheckedException { plugin.stop(cancel); }