};
/**引发事件*/
private void executeEvent(final EventObject eventObj) {
String eventType = eventObj.getEventType();
Object[] objects = eventObj.getParams();
EventCallBackHook callBack = eventObj.getCallBack();
callBack = callBack != null ? callBack : StandardEventManager.EmptyAsyncCallBack;
if (StringUtils.isBlank(eventType) == true) {
return;
}
//
//1.引发事务.
this.listenerRWLock.readLock().lock();//加锁(读)
EventListener[] eventListenerArray = this.listenerMap.get(eventType);
this.listenerRWLock.readLock().unlock();//解锁(读)
if (eventListenerArray != null) {
for (EventListener listener : eventListenerArray) {
try {
listener.onEvent(eventType, objects);
} catch (Throwable e) {
callBack.handleException(eventType, objects, e);
} finally {
callBack.handleComplete(eventType, objects);
}
}
}
//
//2.处理Once事务.
this.onceListenerLock.lock();//加锁
LinkedList<EventListener> eventList = this.onceListenerMap.get(eventType);
if (eventList != null) {
EventListener listener = null;
while ((listener = eventList.pollLast()) != null) {
try {
listener.onEvent(eventType, objects);
} catch (Throwable e) {
callBack.handleException(eventType, objects, e);
} finally {
callBack.handleComplete(eventType, objects);
}
}
}
this.onceListenerLock.unlock();//解锁
};