use of org.apache.inlong.manager.workflow.plugin.ProcessPlugin in project incubator-inlong by apache.
the class ServiceTaskListenerFactory method acceptPlugin.
@Override
public void acceptPlugin(Plugin plugin) {
if (!(plugin instanceof ProcessPlugin)) {
return;
}
ProcessPlugin processPlugin = (ProcessPlugin) plugin;
Map<DataSourceOperateListener, EventSelector> pluginDsOperateListeners = processPlugin.createSourceOperateListeners();
if (MapUtils.isNotEmpty(pluginDsOperateListeners)) {
sourceOperateListeners.putAll(processPlugin.createSourceOperateListeners());
}
Map<SinkOperateListener, EventSelector> pluginSinkOperateListeners = processPlugin.createSinkOperateListeners();
if (MapUtils.isNotEmpty(pluginSinkOperateListeners)) {
sinkOperateListeners.putAll(pluginSinkOperateListeners);
}
Map<QueueOperateListener, EventSelector> pluginQueueOperateListeners = processPlugin.createQueueOperateListeners();
if (MapUtils.isNotEmpty(pluginQueueOperateListeners)) {
queueOperateListeners.putAll(pluginQueueOperateListeners);
}
Map<SortOperateListener, EventSelector> pluginSortOperateListeners = processPlugin.createSortOperateListeners();
if (MapUtils.isNotEmpty(pluginSortOperateListeners)) {
sortOperateListeners.putAll(pluginSortOperateListeners);
}
}
use of org.apache.inlong.manager.workflow.plugin.ProcessPlugin in project incubator-inlong by apache.
the class PluginClassLoaderTest method testLoadPlugin.
@Test
public void testLoadPlugin() {
String path = this.getClass().getClassLoader().getResource("").getPath();
PluginClassLoader pluginClassLoader = PluginClassLoader.getFromPluginUrl(path + "plugins", Thread.currentThread().getContextClassLoader());
Map<String, PluginDefinition> pluginDefinitionMap = pluginClassLoader.getPluginDefinitions();
Assert.assertEquals(1, pluginDefinitionMap.size());
PluginDefinition pluginDefinition = Lists.newArrayList(pluginDefinitionMap.values()).get(0);
Assert.assertNotNull(pluginDefinition);
String pluginClass = pluginDefinition.getPluginClass();
Assert.assertTrue(StringUtils.isNotEmpty(pluginClass));
try {
Class cls = pluginClassLoader.loadClass(pluginClass);
Plugin plugin = (Plugin) cls.getDeclaredConstructor().newInstance();
Assert.assertTrue(plugin instanceof ProcessPlugin);
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
Assert.assertTrue(e instanceof ClassNotFoundException);
Assert.fail();
}
}
Aggregations