private void addDependency(Plugin plugin, Plugin dependency) {
if (isClassPathLoaded(plugin) || isClassPathLoaded(dependency))
return;
PluginClassLoader pluginClassLoader = getClassLoader(plugin);
if (pluginClassLoader == null)
throw new IllegalPluginException("plugin '"+plugin.getName()+"' can not have dependencies");
ClassLoader classLoader = getClassLoader(dependency);
if (classLoader == null)
throw new IllegalPluginException("plugin '"+dependency.getName()+"' can not be set as dependency");
log.info("["+plugin.getName()+"] dependent from ["+dependency.getName()+"]");
pluginClassLoader.addDependency(classLoader);
}