use of iso.std.iso_iec._24727.tech.schema.RequestType in project open-ecard by ecsec.
the class MessageDispatcher method deliver.
@Override
public Object deliver(Object req) throws DispatcherException, InvocationTargetException {
EventDispatcher disp = environment.getEventDispatcher();
// send API CALL STARTED event
ConnectionHandleType handle = HandlerUtils.extractHandle(req);
if (disp != null && req instanceof RequestType) {
ApiCallEventObject startEvt = new ApiCallEventObject(handle, (RequestType) req);
LOG.debug("Sending API_CALL_STARTED event.");
disp.notify(EventType.API_CALL_STARTED, startEvt);
}
try {
Class<?> reqClass = req.getClass();
Service s = getService(reqClass);
Object serviceImpl = getServiceImpl(s);
LOG.debug("Delivering message of type: {}", req.getClass().getName());
Object result = s.invoke(serviceImpl, req);
// send API CALL FINISHED event
if (disp != null && req instanceof RequestType && result instanceof ResponseType) {
ApiCallEventObject finEvt = new ApiCallEventObject(handle, (RequestType) req);
finEvt.setResponse((ResponseType) result);
LOG.debug("Sending API_CALL_FINISHED event.");
disp.notify(EventType.API_CALL_FINISHED, finEvt);
}
return result;
} catch (IllegalAccessException | IllegalArgumentException ex) {
throw new DispatcherException(ex);
}
}
Aggregations