struts source reading diary 1
来源: BlogBus 原始链接: http://www.blogbus.com:80/blogbus/blog/diary.php?diaryid=322465 存档链接: https://web.archive.org/web/20041217071500id_/http://www.blogbus.com:80/blogbus/blog/diary.php?diaryid=322465
struts source reading diary 1 一、RequestUtils的一个方法,使用application的classloader加载class,这个应该和不同的appserver实现相关 public static Class applicationClass(String className) throws ClassNotFoundException { // Look up the class loader to be used ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { classLoader = RequestUtils.class.getClassLoader(); } // Attempt to load the specified class return (classLoader.loadClass(className)); } 以下是log4j的源码,一样是调用context class loader, 就这段描述来讲log4j比struts更严谨:) private static ClassLoader getTCL() throws IllegalAccessException, InvocationTargetException { // Are we running on a JDK 1.2 or later system? Method method = null; try { method = Thread.class.getMethod("getContextClassLoader", null); } catch (NoSuchMethodException e) { // We are running on JDK 1.1 return null; } return (ClassLoader) method.invoke(Thread.currentThread(), null); } 二、在ActionServlet.initServlet()方法中的Digester Digester是Jakarta 子项目Commons下的一个模块,支持基于规则的对任意XML文档的处理。它最初是Structs项目的一部分,后因其通用性而划归Commons.