The org.zkoss.zk.ui.event.EventThreadInit interface"

From Documentation
m (correct highlight (via JWB))
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
  {{ZKConfigurationReferencePageHeader}}
 
  {{ZKConfigurationReferencePageHeader}}
'''Property:'''
 
The org.zkoss.zk.ui.event.EventThreadInit Interface
 
  
 +
'''Listener:'''
  
<javadoc type="interface">org.zkoss.zk.ui.event.EventThreadInit</javadoc> is implemented by a listener class that will be used to initialize an event processing thread, before an event is dispatched to it for processing.
+
org.zkoss.zk.ui.event.EventThreadInit
  
If a listener implements this interface, an instance is created, and then the <tt>prepare</tt> method is called in the main thread (aka., the servlet thread), before processing an event. Then, the <tt>init</tt> method is called in the event processing thread.
 
  
If a developer wants to prevent an event from being processed, he can throw an exception in the <tt>prepare</tt> method or the <tt>init</tt> method.
+
A listener could implement <javadoc type="interface">org.zkoss.zk.ui.event.EventThreadInit</javadoc> to initialize an event processing thread, before an event is dispatched to it for processing.
  
A typical use of this feature is to implement auto-authentication. For example, [http://www.jboss.org JBoss] required you to call <tt>SecurityAssociation.setPrincipal</tt> to grant permissions of a user to the event processing thread, as described in the '''Initialization Before Processing Each Event''' section, the '''Event Listening and Processing''' chapter.
+
<blockquote>
 +
----
 +
Notice that it is useless unless [[ZK Developer's Reference/UI Patterns/Event Threads|the event processing threads]] are enabled (it is disabled by default).
 +
</blockquote>
  
{{ZKConfigurationReferencePageFooter}}
+
 
 +
If a listener implements this interface, an instance is created, and then the <code>prepare</code> method is called in the main thread (aka., the servlet thread), before processing an event. Then, the <code>init</code> method is called in the event processing thread.
 +
 
 +
If a developer wants to prevent an event from being processed, he can throw an exception in the <code>prepare</code> method or the <code>init</code> method.
 +
 
 +
A typical use of this feature is to implement auto-authentication. For example, [http://www.jboss.org JBoss] required you to call <code>SecurityAssociation.setPrincipal</code> to grant permissions of a user to the event processing thread.
 +
 
 +
'''Instantiation:'''
 +
An independent instance of the given class is instantiated each time before the method is invoked. It means it is thread safe, and all information stored in non-static members will be lost after called.
 +
 
 +
{{ZKConfigurationReferencePageFooter}}

Latest revision as of 10:23, 19 January 2022


DocumentationZK Configuration Referencezk.xmlThe listener ElementThe org.zkoss.zk.ui.event.EventThreadInit interface
The org.zkoss.zk.ui.event.EventThreadInit interface


Listener:

org.zkoss.zk.ui.event.EventThreadInit


A listener could implement EventThreadInit to initialize an event processing thread, before an event is dispatched to it for processing.


Notice that it is useless unless the event processing threads are enabled (it is disabled by default).


If a listener implements this interface, an instance is created, and then the prepare method is called in the main thread (aka., the servlet thread), before processing an event. Then, the init method is called in the event processing thread.

If a developer wants to prevent an event from being processed, he can throw an exception in the prepare method or the init method.

A typical use of this feature is to implement auto-authentication. For example, JBoss required you to call SecurityAssociation.setPrincipal to grant permissions of a user to the event processing thread.

Instantiation: An independent instance of the given class is instantiated each time before the method is invoked. It means it is thread safe, and all information stored in non-static members will be lost after called.



Last Update : 2022/01/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.