[jboss-cvs] JBossAS SVN: r68880 - projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jan 11 07:24:00 EST 2008
Author: adrian at jboss.org
Date: 2008-01-11 07:24:00 -0500 (Fri, 11 Jan 2008)
New Revision: 68880
Modified:
projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/VFSClassLoaderPolicy.java
Log:
Optimization - cache the manifest by root url so we aren't continually parsing the manifest on every class definition
Modified: projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/VFSClassLoaderPolicy.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/VFSClassLoaderPolicy.java 2008-01-11 12:23:13 UTC (rev 68879)
+++ projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/VFSClassLoaderPolicy.java 2008-01-11 12:24:00 UTC (rev 68880)
@@ -30,7 +30,9 @@
import java.security.ProtectionDomain;
import java.security.cert.Certificate;
import java.util.Arrays;
+import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.jar.Manifest;
import org.jboss.classloader.spi.ClassLoaderPolicy;
@@ -51,6 +53,9 @@
/** The log */
private static Logger log = Logger.getLogger(VFSClassLoaderPolicy.class);
+ /** Tag for no manifest */
+ private static final Manifest NO_MANIFEST = new Manifest();
+
/** A name for the policy */
private String name;
@@ -66,6 +71,9 @@
/** The import all */
private boolean importAll;
+ /** Manifest cache */
+ private Map<URL, Manifest> manifestCache = new ConcurrentHashMap<URL, Manifest>();
+
/**
* Determine a name from the roots
*
@@ -293,24 +301,61 @@
}
return null;
}
+
+ /**
+ * Find a root from a path
+ *
+ * @param path the path
+ * @return the root if found in the roots
+ */
+ protected VirtualFile findRoot(String path)
+ {
+ for (VirtualFile root : roots)
+ {
+ try
+ {
+ if (root.findChild(path) != null)
+ return root;
+ }
+ catch (Exception ignored)
+ {
+ // not found
+ }
+ }
+ return null;
+ }
@Override
public PackageInformation getPackageInformation(String packageName)
{
String path = packageName.replace('.', '/');
- VirtualFile pkge = findChild(path);
- if (pkge == null)
- return null;
- try
+ VirtualFile root = findRoot(path);
+ Manifest manifest = null;
+ URL rootURL = null;
+ if (root != null)
{
- Manifest manifest = VFSUtils.getManifest(pkge.getVFS());
- return new PackageInformation(packageName, manifest);
+ try
+ {
+ rootURL = root.toURL();
+ manifest = manifestCache.get(rootURL);
+ if (manifest == null)
+ {
+ manifest = VFSUtils.getManifest(root);
+ if (manifest == null)
+ manifestCache.put(rootURL, NO_MANIFEST);
+ else
+ manifestCache.put(rootURL, manifest);
+ }
+
+ if (manifest == NO_MANIFEST)
+ manifest = null;
+ }
+ catch (Exception ignored)
+ {
+ log.trace("Unable to retrieve manifest for " + path + " url=" + rootURL + " error=" + ignored.getMessage());
+ }
}
- catch (IOException ignored)
- {
- log.trace("Unable to retrieve manifest for " + pkge + " " + ignored.getMessage());
- return null;
- }
+ return new PackageInformation(packageName, manifest);
}
@Override
More information about the jboss-cvs-commits
mailing list