|
@@ -20,12 +20,15 @@ package org.apache.hadoop.util;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.FilenameFilter;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
import java.net.MalformedURLException;
|
|
|
import java.net.URL;
|
|
|
import java.net.URLClassLoader;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.Properties;
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
@@ -45,18 +48,12 @@ public class ApplicationClassLoader extends URLClassLoader {
|
|
|
* classes are considered system classes, and are not loaded by the
|
|
|
* application classloader.
|
|
|
*/
|
|
|
- public static final String DEFAULT_SYSTEM_CLASSES =
|
|
|
- "java.," +
|
|
|
- "javax.," +
|
|
|
- "org.w3c.dom.," +
|
|
|
- "org.xml.sax.," +
|
|
|
- "org.apache.commons.logging.," +
|
|
|
- "org.apache.log4j.," +
|
|
|
- "org.apache.hadoop.," +
|
|
|
- "core-default.xml," +
|
|
|
- "hdfs-default.xml," +
|
|
|
- "mapred-default.xml," +
|
|
|
- "yarn-default.xml";
|
|
|
+ public static final String SYSTEM_CLASSES_DEFAULT;
|
|
|
+
|
|
|
+ private static final String PROPERTIES_FILE =
|
|
|
+ "org.apache.hadoop.application-classloader.properties";
|
|
|
+ private static final String SYSTEM_CLASSES_DEFAULT_KEY =
|
|
|
+ "system.classes.default";
|
|
|
|
|
|
private static final Log LOG =
|
|
|
LogFactory.getLog(ApplicationClassLoader.class.getName());
|
|
@@ -69,6 +66,30 @@ public class ApplicationClassLoader extends URLClassLoader {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ static {
|
|
|
+ InputStream is = null;
|
|
|
+ try {
|
|
|
+ is = ApplicationClassLoader.class.getClassLoader().
|
|
|
+ getResourceAsStream(PROPERTIES_FILE);
|
|
|
+ if (is == null) {
|
|
|
+ throw new ExceptionInInitializerError("properties file " +
|
|
|
+ PROPERTIES_FILE + " is not found");
|
|
|
+ }
|
|
|
+ Properties props = new Properties();
|
|
|
+ props.load(is);
|
|
|
+ // get the system classes default
|
|
|
+ String systemClassesDefault =
|
|
|
+ props.getProperty(SYSTEM_CLASSES_DEFAULT_KEY);
|
|
|
+ if (systemClassesDefault == null) {
|
|
|
+ throw new ExceptionInInitializerError("property " +
|
|
|
+ SYSTEM_CLASSES_DEFAULT_KEY + " is not found");
|
|
|
+ }
|
|
|
+ SYSTEM_CLASSES_DEFAULT = systemClassesDefault;
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new ExceptionInInitializerError(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private final ClassLoader parent;
|
|
|
private final List<String> systemClasses;
|
|
|
|
|
@@ -85,7 +106,7 @@ public class ApplicationClassLoader extends URLClassLoader {
|
|
|
}
|
|
|
// if the caller-specified system classes are null or empty, use the default
|
|
|
this.systemClasses = (systemClasses == null || systemClasses.isEmpty()) ?
|
|
|
- Arrays.asList(StringUtils.getTrimmedStrings(DEFAULT_SYSTEM_CLASSES)) :
|
|
|
+ Arrays.asList(StringUtils.getTrimmedStrings(SYSTEM_CLASSES_DEFAULT)) :
|
|
|
systemClasses;
|
|
|
LOG.info("system classes: " + this.systemClasses);
|
|
|
}
|