Listener to make sure servlet thread and ZK event thread got the same ThreadLocal values. You
have to declare this listener in WEB-INF/zk.xml as follows.
<listener>
<description>ThreadLocal Synchronization Listener</description>
<listener-class>org.zkoss.zkplus.util.ThreadLocalListener</listener-class>
</listener>
Besides that, you have to specify what ThreadLocal variables you want to sync. They are also
spcified in WEB-INF/zk.xml file in the form as below.
<preference>
<name>ThreadLocal</name>
<value>
class1=field1,field2,...;
class2=field1,field2,...;
...
</value>
</preference>
For example, to support synchronizing Spring's thread bounded resources, you have to specify the following
ThreadLocal variables:
<preference>
<name>ThreadLocal</name>
<value>
org.springframework.transaction.support.TransactionSynchronizationManager=resources,synchronizations,currentTransactionName,currentTransactionReadOnly,actualTransactionActive;
org.springframework.orm.hibernate3.SessionFactoryUtils=deferredCloseHolder;
org.springframework.transaction.interceptor.TransactionAspectSupport=transactionInfoHolder; <!-- ver. 2+ -->
<!--org.springframework.transaction.interceptor.TransactionAspectSupport=currentTransactionInfo; ver. 1.28 -->
</value>
</preference>
Another example, when you specify the Spring's bean as scope="session", you have to specify the following
ThreadLocal variables since Spring 2.0 use RequestContextHolder to handle the bean's scope.
<preference>
<name>ThreadLocal</name>
<value>
org.springframework.web.context.request.RequestContextHolder=requestAttributesHolder,inheritableRequestAttributesHolder;
</value>
author: henrichen since: 2.4.1
|