Author: remy.maucherat(a)jboss.com
Date: 2009-06-11 06:26:21 -0400 (Thu, 11 Jun 2009)
New Revision: 1102
Modified:
trunk/java/org/apache/catalina/loader/WebappClassLoader.java
trunk/java/org/apache/catalina/loader/WebappLoader.java
Log:
- Remove last modification checks for classes.
Modified: trunk/java/org/apache/catalina/loader/WebappClassLoader.java
===================================================================
--- trunk/java/org/apache/catalina/loader/WebappClassLoader.java 2009-06-10 22:51:34 UTC
(rev 1101)
+++ trunk/java/org/apache/catalina/loader/WebappClassLoader.java 2009-06-11 10:26:21 UTC
(rev 1102)
@@ -71,25 +71,22 @@
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
+import java.util.Map;
import java.util.Vector;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.jar.Attributes;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.jar.Attributes.Name;
-import javax.naming.NamingException;
-import javax.naming.directory.DirContext;
-
import org.apache.catalina.JarRepository;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.util.StringManager;
import org.apache.naming.JndiPermission;
-import org.apache.naming.resources.ResourceAttributes;
import org.apache.tomcat.util.IntrospectionUtils;
/**
@@ -130,7 +127,7 @@
*/
public class WebappClassLoader
extends URLClassLoader
- implements Reloader, Lifecycle
+ implements Lifecycle
{
protected static org.jboss.logging.Logger log=
@@ -249,23 +246,17 @@
/**
- * Associated directory context giving access to the resources in this
- * webapp.
- */
- protected DirContext resources = null;
-
-
- /**
* The cache of ResourceEntry for classes and resources we have loaded,
* keyed by resource name.
*/
- protected HashMap<String, ResourceEntry> resourceEntries = new
HashMap<String, ResourceEntry>();
+ protected Map<String, ResourceEntry> resourceEntries = new
ConcurrentHashMap<String, ResourceEntry>();
/**
* The list of not found resources.
*/
- protected HashSet<String> notFoundResources = new HashSet<String>();
+ protected Map<String, Object> notFoundResources = new
ConcurrentHashMap<String, Object>();
+ protected static final Object VALUE = new Object();
/**
@@ -337,14 +328,14 @@
* The list of JARs last modified dates, in the order they should be
* searched for locally loaded classes or resources.
*/
- protected long[] lastModifiedDates = new long[0];
+ //protected long[] lastModifiedDates = new long[0];
/**
* The list of resources which should be checked when checking for
* modifications.
*/
- protected String[] paths = new String[0];
+ //protected String[] paths = new String[0];
/**
@@ -421,16 +412,6 @@
}
- public DirContext getResources() {
- return resources;
- }
-
-
- public void setResources(DirContext resources) {
- this.resources = resources;
- }
-
-
/**
* Return the "delegate first" flag for this class loader.
*/
@@ -542,79 +523,7 @@
}
- // ------------------------------------------------------- Reloader Methods
-
-
/**
- * Add a new repository to the set of places this ClassLoader can look for
- * classes to be loaded.
- *
- * @param repository Name of a source of classes to be loaded, such as a
- * directory pathname, a JAR file pathname, or a ZIP file pathname
- *
- * @exception IllegalArgumentException if the specified repository is
- * invalid or does not exist
- */
- public void addRepository(String repository) {
-
- // FIXME: remove
- // Ignore any of the standard repositories, as they are set up using
- // either addJar or addRepository
- if (repository.startsWith("/WEB-INF/lib")
- || repository.startsWith("/WEB-INF/classes"))
- return;
-
- }
-
-
- /**
- * Return a String array of the current repositories for this class
- * loader. If there are no repositories, a zero-length array is
- * returned.For security reason, returns a clone of the Array (since
- * String are immutable).
- */
- public String[] findRepositories() {
- return null;
- }
-
-
- /**
- * Have one or more classes or resources been modified so that a reload
- * is appropriate?
- */
- public boolean modified() {
-
- if (log.isDebugEnabled())
- log.debug("modified()");
-
- int length = lastModifiedDates.length;
-
- for (int i = 0; i < length; i++) {
- try {
- long lastModified =
- ((ResourceAttributes) resources.getAttributes(paths[i]))
- .getLastModified();
- if (lastModified != lastModifiedDates[i]) {
- if( log.isDebugEnabled() )
- log.debug(" Resource '" + paths[i]
- + "' was modified; Date is now: "
- + new java.util.Date(lastModified) + " Was:
"
- + new java.util.Date(lastModifiedDates[i]));
- return (true);
- }
- } catch (NamingException e) {
- log.error(" Resource '" + paths[i] + "' is
missing");
- return (true);
- }
- }
-
- // No classes have been modified
- return (false);
-
- }
-
-
- /**
* Render a String representation of this object.
*/
public String toString() {
@@ -1233,10 +1142,7 @@
notFoundResources.clear();
resourceEntries.clear();
- resources = null;
repositoryURLs = null;
- lastModifiedDates = null;
- paths = null;
parent = null;
repository = null;
@@ -1274,7 +1180,7 @@
// Null out any static or final fields from loaded classes,
// as a workaround for apparent garbage collection bugs
if (ENABLE_CLEAR_REFERENCES) {
- Iterator loadedClasses = ((HashMap)
resourceEntries.clone()).values().iterator();
+ Iterator loadedClasses = resourceEntries.values().iterator();
while (loadedClasses.hasNext()) {
ResourceEntry entry = (ResourceEntry) loadedClasses.next();
if (entry.loadedClass != null) {
@@ -1572,32 +1478,9 @@
}
}
- // Register the full path for modification checking
- // Note: Only syncing on a 'constant' object is needed
- synchronized (allPermission) {
-
- int j;
-
- long[] result2 =
- new long[lastModifiedDates.length + 1];
- for (j = 0; j < lastModifiedDates.length; j++) {
- result2[j] = lastModifiedDates[j];
- }
- result2[lastModifiedDates.length] = entry.lastModified;
- lastModifiedDates = result2;
-
- String[] result = new String[paths.length + 1];
- for (j = 0; j < paths.length; j++) {
- result[j] = paths[j];
- }
- result[paths.length] = resource.getPath();
- paths = result;
-
- }
-
}
- if ((entry == null) && (notFoundResources.contains(name)))
+ if ((entry == null) && (notFoundResources.containsKey(name)))
return null;
JarEntry jarEntry = null;
@@ -1680,9 +1563,7 @@
}
if (entry == null) {
- synchronized (notFoundResources) {
- notFoundResources.add(name);
- }
+ notFoundResources.put(name, VALUE);
return null;
}
Modified: trunk/java/org/apache/catalina/loader/WebappLoader.java
===================================================================
--- trunk/java/org/apache/catalina/loader/WebappLoader.java 2009-06-10 22:51:34 UTC (rev
1101)
+++ trunk/java/org/apache/catalina/loader/WebappLoader.java 2009-06-11 10:26:21 UTC (rev
1102)
@@ -415,7 +415,7 @@
* such that the loaded classes should be reloaded?
*/
public boolean modified() {
- return (classLoader.modified());
+ return false;
}
@@ -562,7 +562,6 @@
try {
classLoader = createClassLoader();
- classLoader.setResources(container.getResources());
classLoader.setDelegate(this.delegate);
if (container instanceof StandardContext)
classLoader.setAntiJARLocking(((StandardContext)
container).getAntiJARLocking());
Show replies by date