Package org.zkoss.zk.ui.event

## Interface EventThreadResume

- All Known Implementing Classes:
    `SpringTransactionSynchronizationListener`, `ThreadLocalListener`

      public interface EventThreadResume

  Used to listen after the event processing thread is resumed.

  How this interface is used.

  1. First, you specify a class that implements this interface in WEB-INF/zk.xml as a listener.
  2. Then, when a suspended event thread is being resumed, an instance of the specified class is constructed and `beforeResume(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)` is called first in the main thread (i.e., the servlet thread), right before resuming. And then, `afterResume(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)` is invoked in the event processing thread, after the thread is resumed.

  In addition to resuming normally, a suspended event thread might be aborted (usually caused by destroying the desktop owning the event thread). In this case, `abortResume(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)` is called instead of `beforeResume(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)` and `afterResume(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)`.

  Author:
    tomyeh

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `abortResume​(Component comp, Event evt)` | Called when the suspended event thread is aborted.
    `void` | `afterResume​(Component comp, Event evt)` | Called after the suspended event thread is resumed.
    `void` | `beforeResume​(Component comp, Event evt)` | Called just before the suspended event thread is resumed.

- - ### Method Detail

    - #### beforeResume

          void beforeResume​(Component comp,
                            Event evt)
                     throws java.lang.Exception

      Called just before the suspended event thread is resumed. Unlike `afterResume(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)`, it executes in the main thread that resumes the suspended event processing thread.

      If this method throws an exception, it will abort the execution and shows an error message to the end user. Note: `EventThreadCleanup.cleanup(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event, java.util.List<java.lang.Throwable>)` won't be called if an exception is thrown in this method, since it executes in the main thread.

      Throws:
        `java.lang.Exception`

    - #### afterResume

          void afterResume​(Component comp,
                           Event evt)
                    throws java.lang.Exception

      Called after the suspended event thread is resumed. Unlike `beforeResume(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)`, it executes in the event processing thread that is resumed.

      If this method throws an exception, it will abort the execution and shows an error message to the end user (unless it is cleaned up by `EventThreadCleanup.cleanup(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event, java.util.List<java.lang.Throwable>)`).

      Throws:
        `java.lang.Exception`

    - #### abortResume

          void abortResume​(Component comp,
                           Event evt)
                    throws java.lang.Exception

      Called when the suspended event thread is aborted. It is called in the main thread (i.e., the servlet thread).

      If a suspended event thread is resumed normally, `beforeResume(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)` and `afterResume(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)` are called. On the other hand, if it is aborted (usually caused by destroying the desktop that owns this thread), `abortResume(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)` is called instead.

      Note: if the suspended thread is aborted, none of `beforeResume(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)`, `afterResume(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)`, `EventThreadCleanup.cleanup(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event, java.util.List<java.lang.Throwable>)`, and `EventThreadCleanup.complete(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.event.Event)` will be called. Thus, you have to do necessary cleanups in this method.

      Throws:
        `java.lang.Exception`