Interface EventThreadCleanup
-
- All Known Implementing Classes:
SpringTransactionSynchronizationListener
,ThreadLocalListener
public interface EventThreadCleanup
Used to clean the event processing thread.How this interface is used.
- First, you specify a class that implements this interface in WEB-INF/zk.xml as a listener.
- Then, an instance of the specified class is constructed and
cleanup(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event, java.util.List<java.lang.Throwable>)
is invoked when the event processing thread has processed an event, and thencomplete(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)
of the same instance is called in the servlet thread.
Thus, the typical use is to cleanup un-closed transactions when
cleanup(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event, java.util.List<java.lang.Throwable>)
is called.- Author:
- tomyeh
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
cleanup(Component comp, Event evt, java.util.List<java.lang.Throwable> errs)
Cleans up the event processing thread.void
complete(Component comp, Event evt)
Called in the serlvet thread to clean up.
-
-
-
Method Detail
-
cleanup
void cleanup(Component comp, Event evt, java.util.List<java.lang.Throwable> errs) throws java.lang.Exception
Cleans up the event processing thread. It is called, after a event processing thread has processed an event.If this method threw an exception and errs is empty, the exception will be propagated back to the servlet thread and then reported to the user.
Note:
cleanup(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event, java.util.List<java.lang.Throwable>)
is called first in the event processing thread, and thencomplete(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)
is called in the servlet thread. Note:complete(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)
of anEventThreadCleanup
instance is called only ifcleanup(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event, java.util.List<java.lang.Throwable>)
called against the same instance didn't throw any exception.If the use of the event thread is disabled (
Configuration.isEventThreadEnabled()
returns false), this method is also invoked in the Servlet thread.- Parameters:
errs
- a list of exceptions (java.lang.Throwable) if any exception occurred before this method is called, or null if no exception at all. Note: you can manipulate the list directly to add or clean up exceptions. For example, if exceptions are fixed correctly, you can call errs.clear() such that no error message will be displayed at the client.- Throws:
java.lang.Exception
-
complete
void complete(Component comp, Event evt) throws java.lang.Exception
Called in the serlvet thread to clean up. It is called aftercleanup(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event, java.util.List<java.lang.Throwable>)
is called.Note:
cleanup(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event, java.util.List<java.lang.Throwable>)
is called first in the event processing thread, and thencomplete(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)
is called in the servlet thread.- Throws:
java.lang.Exception
-
-