我正在尝试实现自定义插件。我按照Ignite教程中的说明进行操作,并向default-config.xml配置文件添加了一个属性:
<property name="pluginConfigurations">
<bean class="com.plugins.SecurityPluginConfiguration"/>
</property>
然后我实现了“ SecurityPluginConfiguration”:
public class SecurityPluginConfiguration implements PluginConfiguration {
public Class<? extends PluginProvider> providerClass() {
return SecurityPluginProvider.class;
}
}
和“ SecurityPluginProvider”:
public class SecurityPluginProvider implements PluginProvider<SecurityPluginConfiguration>{
@Override
public String name() {
System.out.println("%%%% Plugin Name : WhiteListSecurity %%%%%%");
return "WhiteListSecurity";
}
@Override
public String version() {
return "1.0.0";
}
@Override
public void start(PluginContext arg0) throws IgniteCheckedException {
// TODO Auto-generated method stub
System.out.println(" %%%%%% Starting Security Plugin Provider %%%%%%% ");
}
@Nullable
@Override
public Object createComponent(PluginContext ctx, Class cls) {
System.out.println(" %%%%%% Create Component HERE!!! %%%%%%% ");
if (cls.isAssignableFrom(GridSecurityProcessor.class)) {
return new WhiteListSecurityProcessor();
} else {
return null;
}
}
.....
// other methods
}
当我启动Ignite Node时,我在日志文件中看不到任何我要打印的内容。看起来 不会调用start()或onIgniteStart()方法。
我添加了 org.apache.ignite.plugin.PluginProvider 文件到META-INF目录,其中包含 com.plugins.SecurityPluginConfiguration
我想念什么吗?有没有明确的插件实现示例?
通过将“ org.apache.ignite.plugin.PluginProvider”文件放置在“ resources / META-INF / services”目录中,部分解决了该问题。
现在在启动时出现此错误:
无法启动网格:java.util.ServiceConfigurationError:org.apache.ignite.plugin.PluginProvider:提供者com.plugins.SecurityPluginConfiguration不是子类型