if(!(o instanceof Plugin)) {
throw new IOException(className+" doesn't extend from hudson.Plugin");
}
wrapper.setPlugin((Plugin) o);
} catch (LinkageError e) {
throw new IOException2("Unable to load " + className + " from " + wrapper.getShortName(),e);
} catch (ClassNotFoundException e) {
throw new IOException2("Unable to load " + className + " from " + wrapper.getShortName(),e);
} catch (IllegalAccessException e) {
throw new IOException2("Unable to create instance of " + className + " from " + wrapper.getShortName(),e);
} catch (InstantiationException e) {
throw new IOException2("Unable to create instance of " + className + " from " + wrapper.getShortName(),e);
}
}
// initialize plugin
try {
Plugin plugin = wrapper.getPlugin();
plugin.setServletContext(pluginManager.context);
startPlugin(wrapper);
} catch(Throwable t) {
// gracefully handle any error in plugin.
throw new IOException2("Failed to initialize",t);
}
} finally {
Thread.currentThread().setContextClassLoader(old);
}
}