public void sendCallbacks(ModelService model, Map context, Object cbObj, int mode) throws GenericServiceException {
List callbacks = dispatcher.getCallbacks(model.name);
if (callbacks != null) {
Iterator i = callbacks.iterator();
while (i.hasNext()) {
GenericServiceCallback gsc = (GenericServiceCallback) i.next();
if (gsc.isEnabled()) {
if (cbObj == null) {
gsc.receiveEvent(context);
} else if (cbObj instanceof Throwable) {
gsc.receiveEvent(context, (Throwable) cbObj);
} else if (cbObj instanceof Map) {
gsc.receiveEvent(context, (Map) cbObj);
} else {
throw new GenericServiceException("Callback object is not Throwable or Map");
}
} else {
i.remove();