@Test public void testInitMethod() throws Exception { PluginManager pluginManager = PluginManager.getInstance(); SimplePlugin simplePlugin = new SimplePlugin(); pluginManager.getPluginRegistry().getRegisteredPlugins().put(SimplePlugin.class, Collections.<ClassLoader, Object>singletonMap(getClass().getClassLoader(), simplePlugin)); InitHandler initHandler = new InitHandler(pluginManager); Method method = SimplePlugin.class.getMethod("initPlugin", PluginManager.class); PluginAnnotation<Init> pluginAnnotation = new PluginAnnotation<Init>(SimplePlugin.class, simplePlugin, method.getAnnotation(Init.class), method); assertTrue("Init successful", initHandler.initMethod(pluginAnnotation)); }
@Override public boolean initMethod(PluginAnnotation pluginAnnotation) { Object plugin = pluginAnnotation.getPlugin(); if (plugin == null) { if (Modifier.isStatic(pluginAnnotation.getMethod().getModifiers())) return registerClassLoaderInit(pluginAnnotation); else return true; } else { if (!Modifier.isStatic(pluginAnnotation.getMethod().getModifiers())) { ClassLoader appClassLoader = pluginManager.getPluginRegistry().getAppClassLoader(plugin); return invokeInitMethod(pluginAnnotation, plugin, appClassLoader); } else return true; } }
InitHandler implements PluginHandler<Init> { @Override public boolean initMethod(PluginAnnotation pluginAnnotation) { Object plugin = pluginAnnotation.getPlugin(); if (plugin == null) { if (Modifier.isStatic(pluginAnnotation.getMethod().getModifiers())) return registerClassLoaderInit(pluginAnnotation); else return true; } else { if (!Modifier.isStatic(pluginAnnotation.getMethod().getModifiers())) { ClassLoader appClassLoader = pluginManager.getPluginRegistry().getAppClassLoader(plugin); return invokeInitMethod(pluginAnnotation, plugin, appClassLoader); } else return true; } } }
InitHandler implements PluginHandler<Init> { @Override public boolean initMethod(PluginAnnotation pluginAnnotation) { Object plugin = pluginAnnotation.getPlugin(); if (plugin == null) { if (Modifier.isStatic(pluginAnnotation.getMethod().getModifiers())) return registerClassLoaderInit(pluginAnnotation); else return true; } else { if (!Modifier.isStatic(pluginAnnotation.getMethod().getModifiers())) { ClassLoader appClassLoader = pluginManager.getPluginRegistry().getAppClassLoader(plugin); return invokeInitMethod(pluginAnnotation, plugin, appClassLoader); } else return true; } } InitHandler(PluginManager pluginManager); }
InitHandler implements PluginHandler<Init> { @Override public boolean initMethod(PluginAnnotation pluginAnnotation) { Object plugin = pluginAnnotation.getPlugin(); if (plugin == null) { if (Modifier.isStatic(pluginAnnotation.getMethod().getModifiers())) return registerClassLoaderInit(pluginAnnotation); else return true; } else { if (!Modifier.isStatic(pluginAnnotation.getMethod().getModifiers())) { ClassLoader appClassLoader = pluginManager.getPluginRegistry().getAppClassLoader(plugin); return invokeInitMethod(pluginAnnotation, plugin, appClassLoader); } else return true; } } InitHandler(PluginManager pluginManager); @Override boolean initField(PluginAnnotation pluginAnnotation); @Override boolean initMethod(PluginAnnotation pluginAnnotation); }
InitHandler implements PluginHandler<Init> { @Override public boolean initMethod(PluginAnnotation pluginAnnotation) { Object plugin = pluginAnnotation.getPlugin(); if (plugin == null) { if (Modifier.isStatic(pluginAnnotation.getMethod().getModifiers())) return registerClassLoaderInit(pluginAnnotation); else return true; } else { if (!Modifier.isStatic(pluginAnnotation.getMethod().getModifiers())) { ClassLoader appClassLoader = pluginManager.getPluginRegistry().getAppClassLoader(plugin); return invokeInitMethod(pluginAnnotation, plugin, appClassLoader); } else return true; } } InitHandler(PluginManager pluginManager); @Override boolean initField(PluginAnnotation pluginAnnotation); @Override boolean initMethod(PluginAnnotation pluginAnnotation);  }