View Javadoc

1   package ch.elca.el4j.services.xmlmerge;
2   
3   import java.util.HashMap;
4   import java.util.Map;
5   
6   import org.xml.sax.EntityResolver;
7   
8   /**
9    * Holds thread local context information that would otherwise be difficult to pass into
10   *  each part of the framework. Is intentionally designed to be extensible.
11   *
12   *  CAVEAT:
13   *     * Do not abuse. It could be used as general thread-local global variables
14   *     * There is a potential security risk here (do not put confidential info in here)
15   *
16   * @svnLink $Revision: 3884 $;$Date: 2009-08-04 15:48:31 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/xml_merge/common/src/main/java/ch/elca/el4j/services/xmlmerge/XmlMergeContext.java $
17   *
18   * @author Philipp H. Oser (POS)
19   */
20  public class XmlMergeContext {
21  
22  	protected static final String ENTITY_RESOLVER_KEY = "entityResolver";
23  	
24  	protected static final ThreadLocal<Map<String,Object>> m_context = new ThreadLocal<Map<String,Object>>() {
25  		protected Map<String,Object> initialValue() {
26  			return new HashMap<String, Object>();
27  		}
28  	};
29  	
30  	public static EntityResolver getEntityResolver() {
31  		if (m_context.get().containsKey(ENTITY_RESOLVER_KEY)) {
32  			return (EntityResolver) m_context.get().get(ENTITY_RESOLVER_KEY);
33  		}
34  		return null;
35  	}
36  	
37  	public static void setEntityResolver(EntityResolver er) {
38  		m_context.get().put(ENTITY_RESOLVER_KEY, er);
39  	}
40  	
41  }