for (Element listener : eventListeners) {
String ref = listener.getAttribute("ref");
// if this a bean ref
if (StringUtils.hasText(ref)) {
if (TYPE_AGENDA_EVENT_LISTENER.equalsIgnoreCase(listenerType) || TYPE_PROCESS_EVENT_LISTENER.equalsIgnoreCase(listenerType) || TYPE_WORKING_MEMORY_EVENT_LISTENER.equalsIgnoreCase(listenerType)) {
ManagedList subList = (ManagedList) listeners.get(listenerType);
if (subList == null) {
subList = new ManagedList();
listeners.put(listenerType, subList);
}
subList.add(new RuntimeBeanReference(ref));
} else {
throw new IllegalArgumentException("eventListener must be of type 'agenda-event-listener or 'process-event-listener' or 'working-memory-event-listener'.");
}
} else {
//not a ref check if it is a nested bean
Element nestedBean = DomUtils.getChildElementByTagName(listener, "bean");
if (nestedBean == null) {
//no 'ref' and no nested beans, add the default debug listeners part of the core libs.
Object obj = null;
if (TYPE_AGENDA_EVENT_LISTENER.equalsIgnoreCase(listenerType)) {
obj = new DebugAgendaEventListener();
} else if (TYPE_PROCESS_EVENT_LISTENER.equalsIgnoreCase(listenerType)) {
obj = new DebugProcessEventListener();
} else if (TYPE_WORKING_MEMORY_EVENT_LISTENER.equalsIgnoreCase(listenerType)) {
obj = new DebugWorkingMemoryEventListener();
} else {
throw new IllegalArgumentException("eventListener must be of type 'agenda-event-listener or 'process-event-listener' or 'working-memory-event-listener'.");
}
ManagedList subList = (ManagedList) listeners.get(listenerType);
if (subList == null) {
subList = new ManagedList();
listeners.put(listenerType, subList);
}
subList.add(obj);
} else {
//String type = StringUtils.hasText(listenerType) ? listenerType: "infer";
Object obj = parserContext.getDelegate().parsePropertySubElement(nestedBean, null, null);
ManagedList subList = (ManagedList) listeners.get(listenerType);
if (subList == null) {
subList = new ManagedList();
listeners.put(listenerType, subList);
}
subList.add(obj);
}
}
}
return listeners;
}