|
Jacson | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.spieleck.util.FastClassForName
This is a replacement for Class.forName(...).newInstance().
It is fast. In my bench it is much faster than the latter construct. Efficient caching and loading mechanism to obtain classes with a default constructor in the current ContextClassLoader.
It treats some classloader intricaties.
Field Summary | |
protected static java.util.HashMap |
classCache
Keep track of all classes aquired for faster second access. |
Method Summary | |
static java.lang.Class |
contextClassForName(java.lang.String className,
java.lang.Class context)
Try to load a class from the right contextual classloader. |
static java.lang.Class |
lookupClass(java.lang.String className,
java.lang.String defaultPackage,
java.lang.Class context)
Lookup the class, first in cache, then try loading it from context with two trials on the classname. |
static java.lang.Object |
newInstance(java.lang.String className,
java.lang.Class require)
|
static java.lang.Object |
newInstance(java.lang.String className,
java.lang.String defaultPackage,
java.lang.Class require)
|
static java.lang.Object |
newInstance(java.lang.String className,
java.lang.String defaultPackage,
java.lang.Class require,
java.lang.Class context)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static java.util.HashMap classCache
Method Detail |
public static java.lang.Object newInstance(java.lang.String className, java.lang.Class require)
public static java.lang.Object newInstance(java.lang.String className, java.lang.String defaultPackage, java.lang.Class require)
public static java.lang.Object newInstance(java.lang.String className, java.lang.String defaultPackage, java.lang.Class require, java.lang.Class context)
public static java.lang.Class lookupClass(java.lang.String className, java.lang.String defaultPackage, java.lang.Class context)
public static java.lang.Class contextClassForName(java.lang.String className, java.lang.Class context) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
|
Spieleck | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |