[jboss-cvs] JBossAS SVN: r73402 - projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/lang.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed May 14 21:13:27 EDT 2008
Author: ALRubinger
Date: 2008-05-14 21:13:27 -0400 (Wed, 14 May 2008)
New Revision: 73402
Modified:
projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/lang/ClassHelper.java
Log:
[EJBTHREE-1365] Add a getClassFromTypeName Utility
Modified: projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/lang/ClassHelper.java
===================================================================
--- projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/lang/ClassHelper.java 2008-05-15 01:12:17 UTC (rev 73401)
+++ projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/lang/ClassHelper.java 2008-05-15 01:13:27 UTC (rev 73402)
@@ -27,7 +27,7 @@
import java.util.List;
/**
- * Usefull methods for classes.
+ * Useful methods for classes.
*
* @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
* @version $Revision$
@@ -159,6 +159,31 @@
return result;
}
+ /**
+ * Obtains a Class corresponding to the specified type using
+ * the specified ClassLoader, throwing a descriptive RuntimeException
+ * in the case the Class could not be found
+ *
+ * @param type
+ * @param cl
+ * @return
+ * @author ALR
+ */
+ public static final Class<?> getClassFromTypeName(String type, ClassLoader cl)
+ {
+ try
+ {
+ // Load the class
+ return cl.loadClass(type);
+ }
+ catch (ClassNotFoundException e)
+ {
+ // Throw descriptive message
+ throw new RuntimeException("Specified class " + type + " could not be found by the "
+ + ClassLoader.class.getSimpleName() + ", " + cl, e);
+ }
+ }
+
private static void populateWithMethodsByName(List<Method> methods, Class<?> cls, String methodName)
{
// Top of the world
More information about the jboss-cvs-commits
mailing list