[jboss-dev-forums] [Design of POJO Server] - Re: Caching of classes in BaseClassLoaderDomain
bstansberry@jboss.com
do-not-reply at jboss.com
Mon May 4 17:44:43 EDT 2009
Done. That would be this:
Index: BaseClassLoader.java
| ===================================================================
| --- BaseClassLoader.java (revision 88165)
| +++ BaseClassLoader.java (working copy)
| @@ -351,18 +351,22 @@
| * Check the cache and blacklist
| *
| * @param name the name of the class
| + * @param failIfBlackListed <code>true</code> if a blacklisted class should
| + * result in ClassNotFoundException; <code>false</code>
| + * if a <code>null</code> return value is acceptable
| * @param trace whether trace is enabled
| * @return the class is if it is already loaded, null otherwise
| - * @throws ClassNotFoundException when blacklisted
| + * @throws ClassNotFoundException when the class is blacklisted and
| + * <code>failIfBlackListed</code> is <code>true</code>
| */
| - protected Class<?> checkCacheAndBlackList(String name, boolean trace) throws ClassNotFoundException
| + protected Class<?> checkCacheAndBlackList(String name, boolean failIfBlackListed, boolean trace) throws ClassNotFoundException
| {
| BaseClassLoaderPolicy basePolicy = policy;
| BaseClassLoaderDomain domain = basePolicy.getClassLoaderDomain();
| if (domain == null)
| return null;
|
| - return domain.checkClassCacheAndBlackList(this, name, null, basePolicy.isImportAll());
| + return domain.checkClassCacheAndBlackList(this, name, null, basePolicy.isImportAll(), false);
| }
|
| /**
| @@ -426,17 +430,9 @@
| if (result != null)
| return result;
|
| - try
| - {
| - result = checkCacheAndBlackList(name, trace);
| - if (result != null)
| - return result;
| - }
| - catch (ClassNotFoundException blacklisted)
| - {
| - if (trace)
| - log.trace(name + " has been blacklisted; cannot load from domain cache");
| - }
| + result = checkCacheAndBlackList(name, false, trace);
| + if (result != null)
| + return result;
|
| synchronized (this)
| {
| Index: BaseClassLoaderDomain.java
| ===================================================================
| --- BaseClassLoaderDomain.java (revision 88158)
| +++ BaseClassLoaderDomain.java (working copy)
| @@ -1487,10 +1487,14 @@
| * @param name the name
| * @param path the path of the class resource
| * @param allExports whether to look at all exports
| + * @param failIfBlackListed <code>true</code> if a blacklisted class should
| + * result in ClassNotFoundException; <code>false</code>
| + * if a <code>null</code> return value is acceptable
| * @return the class when found in the cache
| - * @throws ClassNotFoundException when the class is blacklisted
| + * @throws ClassNotFoundException when the class is blacklisted and
| + * <code>failIfBlackListed</code> is <code>true</code>
| */
| - protected Class<?> checkClassCacheAndBlackList(BaseClassLoader classLoader, String name, String path, boolean allExports) throws ClassNotFoundException
| + protected Class<?> checkClassCacheAndBlackList(BaseClassLoader classLoader, String name, String path, boolean allExports, boolean failIfBlackListed) throws ClassNotFoundException
| {
| if (path == null)
| path = ClassLoaderUtils.classNameToPath(name);
| @@ -1498,8 +1502,11 @@
| Class<?> result = checkClassCache(classLoader, name, path, allExports);
| if (result != null)
| return result;
| -
| - checkClassBlackList(classLoader, name, path, allExports);
| +
| + if (failIfBlackListed)
| + {
| + checkClassBlackList(classLoader, name, path, allExports);
| + }
| return null;
| }
|
Which is simple enough. I'm not sure if there's a use case for failIfBlackListed=true, but it's exposed if there is one.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4228440#4228440
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4228440
More information about the jboss-dev-forums
mailing list