Update of /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper/util
In directory sc8-pr-cvs1:/tmp/cvs-serv17764/src/java/core/org/krysalis/ruper/util
Modified Files:
ClassLoaderHelper.java
Log Message:
1) Unit test for messages
2) Fallback to "en" if messages in default locale not available
3) First stab at loading ruper.xml from a resource (classloader) not just file
Index: ClassLoaderHelper.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper/util/ClassLoaderHelper.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ClassLoaderHelper.java 12 Sep 2003 15:19:43 -0000 1.3
--- ClassLoaderHelper.java 22 Sep 2003 20:18:29 -0000 1.4
***************
*** 5,9 ****
package org.krysalis.ruper.util;
- import org.krysalis.ruper.log.Logger;
/**
--- 5,8 ----
***************
*** 11,43 ****
*/
public class ClassLoaderHelper {
! public static Class getClassForName(String name)
! throws ClassNotFoundException, NoClassDefFoundError {
! Class clazz = null;
! try {
! Logger.getLog().debug("Using the Context ClassLoader");
! ClassLoader ccl = Thread.currentThread().getContextClassLoader();
! clazz = Class.forName(name, true, ccl);
}
catch (Exception e) {
! Logger.getLog().warn(
! "Failed to load the class with context class loader " + e);
}
! if (null == clazz) {
! ClassLoader scl = ClassLoader.getSystemClassLoader();
try {
! Logger.getLog().info("Using the System ClassLoader");
! clazz = Class.forName(name, true, scl);
}
catch (Exception e) {
! Logger.getLog().warn(
! "Failed to load the class with system class loader " + e);
}
}
! return clazz;
}
--- 10,54 ----
*/
public class ClassLoaderHelper {
! public static ClassLoader getClassLoader() {
! return getClassLoader(null);
! }
! public static ClassLoader getClassLoader(Object caller) {
! ClassLoader cl = null;
! try {
! cl = Thread.currentThread().getContextClassLoader();
}
catch (Exception e) {
! cl = null;
}
! if (null != caller)
! // Try Object's Loader
! if (null == cl) {
! try {
! cl = caller.getClass().getClassLoader();
! }
! catch (Exception e) {
! cl = null;
! }
! }
+ // Try System Loader
+ if (null == cl) {
try {
! cl = ClassLoader.getSystemClassLoader();
}
catch (Exception e) {
! cl = null;
}
}
! return cl;
! }
!
! public static Class getClassForName(String name)
! throws ClassNotFoundException, NoClassDefFoundError {
! return Class.forName(name, true, getClassLoader());
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.