try
{
Object cacheKey = getGrammarPoolCacheKey();
// we're using thread local caches to avoid thread safety problems
ReferenceMap cacheMap = (ReferenceMap) GRAMMAR_POOL_CACHE.get();
if (cacheMap == null)
{
cacheMap = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.SOFT);
GRAMMAR_POOL_CACHE.set(cacheMap);
}
Object grammarPool = cacheMap.get(cacheKey);
if (grammarPool == null)
{
if (log.isDebugEnabled())
{
log.debug("Instantiating grammar pool of type " + poolClassName
+ " for cache key " + cacheKey);
}
grammarPool = ClassUtils.instantiateClass(poolClassName, Object.class);
cacheMap.put(cacheKey, grammarPool);
}
parser.setProperty(XERCES_PARSER_PROPERTY_GRAMMAR_POOL, grammarPool);
}
catch (Exception e)