Search in sources :

Example 1 with RequestType

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);
    }
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) EventDispatcher(org.openecard.common.interfaces.EventDispatcher) ApiCallEventObject(org.openecard.common.event.ApiCallEventObject) DispatcherException(org.openecard.common.interfaces.DispatcherException) ApiCallEventObject(org.openecard.common.event.ApiCallEventObject) RequestType(iso.std.iso_iec._24727.tech.schema.RequestType) ResponseType(iso.std.iso_iec._24727.tech.schema.ResponseType)

Aggregations

ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)1 RequestType (iso.std.iso_iec._24727.tech.schema.RequestType)1 ResponseType (iso.std.iso_iec._24727.tech.schema.ResponseType)1 ApiCallEventObject (org.openecard.common.event.ApiCallEventObject)1 DispatcherException (org.openecard.common.interfaces.DispatcherException)1 EventDispatcher (org.openecard.common.interfaces.EventDispatcher)1