Advertisement
Guest User

Untitled

a guest
Jul 15th, 2011
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.69 KB | None | 0 0
  1. ------------- PersistentFacesState.java
  2.  
  3. package com.icesoft.faces.webapp.xmlhttp
  4.  
  5. public class PersistentFacesState implements Serializable {
  6.     private static InheritableThreadLocal localInstance = new InheritableThreadLocal() {
  7.             protected Object childValue(Object parentValue) {
  8.                 if (parentValue == null) {
  9.                     return parentValue;
  10.                 }
  11.                 PersistentFacesState state = (PersistentFacesState)parentValue;
  12.                 return state.isInheritable() ? state : null;
  13.             }
  14.     };
  15.  
  16.     public boolean isInheritable() {
  17.         String value =            facesContext.getExternalContext().getInitParameter("InheritableThreadLocalExcludeFilter");
  18.         if (value == null) {
  19.             return true;
  20.         }
  21.         StackTraceElement[] elements = Thread.currentThread().getStackTrace();
  22.         String[] classNames = value.split(";");
  23.         String rhsClassName;
  24.         for (int i = 0; i < classNames.length; ++i) {
  25.             rhsClassName =  classNames[i];
  26.             for (int j = 0; j < elements.length; ++j) {
  27.                 StackTraceElement e = elements[j];
  28.                 String lhsClassName = e.getClassName();
  29.                 if (lhsClassName.equals(rhsClassName)) {
  30.                     return false;
  31.                 }
  32.             }
  33.         }
  34.         return true;
  35.     }
  36.  
  37.  
  38. ------------- web.xml
  39.  
  40.   <context-param>
  41.     <param-name>InheritableThreadLocalExcludeFilter</param-name>
  42.     <param-value>net.sf.ehcache.CacheManager$1;java.util.TimerThread;com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread;net.sf.ehcache.store.DiskStore$SpoolAndExpiryThread</param-value>
  43.   </context-param>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement