super.loadPlugin(env, enabled);
if (enabled) {
AlertPluginDescriptorType type = (AlertPluginDescriptorType) env.getPluginDescriptor();
// make sure the alert sender class name is valid
String className = type.getPluginClass();
try {
loadPluginClass(env, className, false);
} catch (Exception e) {
log.error("Alert sender class [" + className + "] defined in plugin ["
+ env.getPluginKey().getPluginName() + "] is invalid and will be ignored. Cause: "
+ ThrowableUtil.getAllMessages(e));
try {
unloadPlugin(env.getPluginKey().getPluginName());
} catch (Throwable t) {
log.warn(" +--> unload failed too. Cause: " + ThrowableUtil.getAllMessages(t));
}
throw e;
}
//
// Ok, we have a valid plugin class, so we can look for other things and store the info
//
// The short name is basically the key into the plugin
String shortName = type.getShortName();
pluginClassByName.put(shortName, className);
// UI snippet path allows the plugin to inject user interface fragments to the alert pages
String uiSnippetPath = null;
URL uiSnippetUrl = null;
CustomUi customUI = type.getCustomUi();
if (customUI != null) {
uiSnippetPath = customUI.getUiSnippetName();
try {
uiSnippetUrl = env.getPluginClassLoader().getResource(uiSnippetPath);
if (uiSnippetUrl == null) {
throw new Exception("plugin is missing alert ui snippet named [" + uiSnippetPath + "]");
}
log.debug("Alert plugin UI snippet for [" + shortName + "] is at: " + uiSnippetUrl);
} catch (Exception e) {
log.error("Invalid alert UI snippet provided inside <custom-ui> for alert plugin [" + shortName
+ "]. Plugin will be ignored. Cause: " + ThrowableUtil.getAllMessages(e));
throw e;
}
className = customUI.getBackingBeanClass();
try {
loadPluginClass(env, className, true); // TODO how make this available to Seam and the Web-CL ?
backingBeanByName.put(shortName, className);
} catch (Throwable t) {
String errMsg = "Backing bean [" + className + "] not found for plugin [" + shortName + ']';
log.error(errMsg);
throw new Exception(errMsg, t);
}
String beanName = customUI.getBackingBeanName();
// Default to <backing-bean-class> value if name is not provided
if (beanName == null || beanName.length() == 0) {
beanName = className;
}
backingBeanNameByName.put(shortName, beanName);
}
AlertSenderInfo info = new AlertSenderInfo(shortName, type.getDescription(), env.getPluginKey());
info.setUiSnippetUrl(uiSnippetUrl);
info.setUiSnippetShortPath(uiSnippetPath);
senderInfoByName.put(shortName, info);
pluginEnvByName.put(shortName, env);
}