if (elems == null || elems.length == 0) {
// Alternative way
Element[] whiteboards = elem.getElements("whiteboards", NAMESPACE);
if (whiteboards == null) {
throw new ConfigurationException("Cannot configure the whiteboard pattern handler - no suitable configuration found");
} else {
elems = whiteboards[0].getElements("wbp", NAMESPACE);
}
}
// Last check.
if (elems == null) {
throw new ConfigurationException("Cannot configure the whiteboard pattern handler - no suitable configuration found");
}
for (int i = 0; i < elems.length; i++) {
String filter = elems[i].getAttribute("filter");
String onArrival = elems[i].getAttribute("onArrival");
String onDeparture = elems[i].getAttribute("onDeparture");
String onModification = elems[i].getAttribute("onModification");
if (filter == null) {
throw new ConfigurationException("The white board pattern element requires a filter attribute");
}
if (onArrival == null || onDeparture == null) {
throw new ConfigurationException("The white board pattern element requires the onArrival and onDeparture attributes");
}
try {
WhiteBoardManager wbm = new WhiteBoardManager(this, getInstanceManager().getContext().createFilter(filter), onArrival, onDeparture, onModification);
m_managers.add(wbm);
} catch (InvalidSyntaxException e) {
throw new ConfigurationException("The filter " + filter + " is invalid : " + e);
}
}
}