1 17 package com.sun.org.apache.xml.internal.security.utils; 18 19 import com.sun.org.apache.xpath.internal.CachedXPathAPI; 20 import org.w3c.dom.Document ; 21 22 23 26 public class CachedXPathAPIHolder { 27 static java.util.logging.Logger log = 28 java.util.logging.Logger.getLogger(CachedXPathAPIHolder.class.getName()); 29 30 static ThreadLocal local=new ThreadLocal (); 31 static ThreadLocal localDoc=new ThreadLocal (); 32 33 37 public static void setDoc(Document doc) { 38 if (localDoc.get()!=doc) { 39 CachedXPathAPI cx=(CachedXPathAPI)local.get(); 40 if (cx==null) { 41 cx=new CachedXPathAPI(); 42 local.set(cx); 43 localDoc.set(doc); 44 return; 45 } 46 cx.getXPathContext().reset(); 48 localDoc.set(doc); 49 } 50 } 51 54 public static CachedXPathAPI getCachedXPathAPI() { 55 CachedXPathAPI cx=(CachedXPathAPI)local.get(); 56 if (cx==null) { 57 cx=new CachedXPathAPI(); 58 local.set(cx); 59 localDoc.set(null); 60 } 61 return cx; 62 } 63 } 64 | Popular Tags |