OPENJPA256 this class differs from most plugins in that the plugin type is the standard java interface Map.class (rather than an openjpa-specific interface), which means that the ClassLoader used to load the implementation will be the system class loader; this presents a problem if OpenJPA is not in the system classpath, so work around the problem by catching the IllegalArgumentException (which is what we wrap the ClassNotFoundException in) and try again, this time using this class' ClassLoader.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@562011 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Marc Prud'hommeaux 2007-08-02 03:51:38 +00:00
parent f61968f302
commit 97b94f6aa9
1 changed files with 18 additions and 1 deletions

View File

@ -54,7 +54,24 @@ public class QueryCompilationCacheValue
public Object newInstance(String clsName, Class type,
Configuration conf, boolean fatal) {
// make sure map handles concurrency
Map map = (Map) super.newInstance(clsName, type, conf, fatal);
Map map;
try {
map = (Map) super.newInstance(clsName, type, conf, fatal);
} catch (IllegalArgumentException iae) {
// OPENJPA256: this class differs from most plugins in that
// the plugin type is the standard java interface Map.class (rather
// than an openjpa-specific interface), which means that the
// ClassLoader used to load the implementation will be the system
// class loader; this presents a problem if OpenJPA is not in the
// system classpath, so work around the problem by catching
// the IllegalArgumentException (which is what we wrap the
// ClassNotFoundException in) and try again, this time using
// this class' ClassLoader.
map = (Map) super.newInstance(clsName,
QueryCompilationCacheValue.class, conf, fatal);
}
if (map != null && !(map instanceof Hashtable)
&& !(map instanceof CacheMap)
&& !(map instanceof ConcurrentMap))