Package net.hasor.core

Examples of net.hasor.core.EventCallBackHook


    };
    /**引发事件*/
    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();//解锁
    };
View Full Code Here

TOP

Related Classes of net.hasor.core.EventCallBackHook

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.