((Configurable)eventListener).configure(conf);
}
}
addEventListener(eventListener);
} catch (ClassCastException e) {
throw new ConfigurationException("Event listener '"+classname+"' is not of type EventListener", config);
} catch (Exception e) {
throw new ConfigurationException("Event listener '"+classname+"' could not be loaded", config);
}
}
Enumeration enableConfigs = config.getConfigurations("event");
while (enableConfigs.hasMoreElements()) {
Configuration enableConfig = (Configuration)enableConfigs.nextElement();
String classname = enableConfig.getAttribute("classname");
String method = enableConfig.getAttribute("method", null);
boolean enable = enableConfig.getAttributeAsBoolean("enable", true);
try {
Class eventClass = Class.forName(classname);
Field methodsField = eventClass.getField("methods");
AbstractEventMethod[] methods = (AbstractEventMethod [])methodsField.get(null);
for ( int i = 0; i < methods.length; i++ ) {
if ( method == null || methods[i].getName().equals(method) ) {
methods[i].setEnabled(enable);
}
}
} catch (NoSuchFieldException e) {
throw new ConfigurationException("Event '"+classname+"' does not provide the required static member 'methods'", config);
} catch (Exception e) {
throw new ConfigurationException("Event '"+classname+"' could not be loaded", config);
}
}
}