public class EventExecutor extends Object
| 构造器和说明 |
|---|
EventExecutor(ThreadPoolExecutor threadPoolExecutor)
构造一个EventExecutor.
|
EventExecutor(ThreadPoolExecutor threadPoolExecutor,
EventHandlerList eventHandlerList,
EventHandlerObjectMap eventHandlerObjectMap)
构造一个EventExecutor.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addHandler(EventHandler handler)
添加EventHandler.
|
boolean |
awaitTermination(long timeout,
TimeUnit unit)
等待线程池内任务执行完成并关闭线程池.
|
static boolean |
checkMethod(Method method)
检查指定方法是否为合法的事件接收方法
|
int |
executor(EventHandler handler,
EventObject eventObject)
对指定
EventHandler投递事件 |
void |
executor(EventObject eventObject)
投递事件.
|
void |
executorSync(EventObject eventObject)
同步投递事件.
|
protected void |
finalize() |
Thread.UncaughtExceptionHandler |
getExceptionHandler()
获取设定的UncaughtExceptionHandler
|
ThreadPoolExecutor |
getThreadPoolExecutor()
获取EventExecutor所使用的
ThreadPoolExecutor |
void |
removeHandler(EventHandler handler)
删除EventHandler
|
static void |
resendCurrentEvent()
重新投递当前任务到当前Handler.
|
void |
setEnableEventResend(boolean enable)
设置事件重投是否启用.
|
void |
setEventUncaughtExceptionHandler(EventUncaughtExceptionHandler handler)
设置事件异常捕获处理对象.
|
void |
setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler handler)
设置线程池异常处理类.
|
List<Runnable> |
shutdown(boolean shutdownNow)
关闭执行器.
|
public EventExecutor(ThreadPoolExecutor threadPoolExecutor)
threadPoolExecutor - 事件线程池, 线程池将用于执行Handler中的EventMethod.public EventExecutor(ThreadPoolExecutor threadPoolExecutor, EventHandlerList eventHandlerList, EventHandlerObjectMap eventHandlerObjectMap)
threadPoolExecutor - 事件线程池, 线程池将用于执行Handler中的EventMethod.eventHandlerList - 事件列表, 用于存储EventObject对应EventHandlerMethod.eventHandlerObjectMap - EventHandlerObject存储, 用于存储EventHandler对象.public void addHandler(EventHandler handler) throws IllegalAccessException
handler - EventHandler对象IllegalAccessException - 当EventHandler内方法不为Public时可能会抛出,
是否抛出由EventHandlerList所使用的实现决定public void removeHandler(EventHandler handler)
handler - 要删除的EventHandler对象public void executor(EventObject eventObject)
eventObject - 带有事件参数的事件对象public void executorSync(EventObject eventObject) throws InterruptedException
eventObject - 需投递的事件对象InterruptedException - 当等待执行完成时发生中断, 则抛出异常.public int executor(EventHandler handler, EventObject eventObject) throws IllegalAccessException
EventHandler投递事件handler - 要进行事件投递的EventHandlereventObject - 事件对象IllegalAccessException - 当EventHandler访问权不为public时抛出异常.public void setEnableEventResend(boolean enable)
enable - 如果启用,
则EventHandler内的事件处理方法将可以调用resendCurrentEvent()重新投递当前任务到该EventHandler.public boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
timeout - 时间unit - 时间单位InterruptedException - 当发生中断时抛出public void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler handler)
setEventUncaughtExceptionHandler(EventUncaughtExceptionHandler),
设置捕获EventHandler抛出的异常, 因EventExecutor内部处理,
UncaughtExceptionHandler无法捕获InvocationTargetException异常来获取事件方法抛出的异常.handler - 处理类对象public ThreadPoolExecutor getThreadPoolExecutor()
ThreadPoolExecutorpublic Thread.UncaughtExceptionHandler getExceptionHandler()
public List<Runnable> shutdown(boolean shutdownNow)
shutdownNow - 是否立刻关闭shutdownNow为 true, 则返回线程池内未完成的事件任务.public void setEventUncaughtExceptionHandler(EventUncaughtExceptionHandler handler)
handler - 事件异常捕获处理对象public static void resendCurrentEvent()
public static boolean checkMethod(Method method)
method - 待检查的方法Copyright © 2020. All rights reserved.