Methods Summary |
---|
public static java.lang.Class | getCallerClass(int callerOffset)
if (CALLER_RESOLVER == null) return null; // only happens if <clinit> failed
return CALLER_RESOLVER.getClassContext () [CALL_CONTEXT_OFFSET + callerOffset];
|
public static synchronized java.lang.ClassLoader | getClassLoader(java.lang.Class caller)This method selects the "best" classloader instance to be used for
class/resource loading by whoever calls this method. The decision
typically involves choosing between the caller's current, thread context,
system, and other classloaders in the JVM and is made by the {@link IClassLoadStrategy}
instance established by the last call to {@link #setStrategy}.
This method does not throw.
final ClassLoadContext ctx = new ClassLoadContext (caller);
return s_strategy.getClassLoader (ctx);
|
public static synchronized java.lang.ClassLoader | getClassLoader()This method selects the "best" classloader instance to be used for
class/resource loading by whoever calls this method. The decision
typically involves choosing between the caller's current, thread context,
system, and other classloaders in the JVM and is made by the {@link IClassLoadStrategy}
instance established by the last call to {@link #setStrategy}.
This method uses its own caller to set the call context. To be able to
override this decision explicitly, use {@link #getClassLoader(Class)}.
This method does not throw.
final Class caller = getCallerClass (1); // 'caller' can be set to null
final ClassLoadContext ctx = new ClassLoadContext (caller);
return s_strategy.getClassLoader (ctx);
|
public static synchronized IClassLoadStrategy | getStrategy()Gets the current classloader selection strategy setting.
return s_strategy;
|
public static boolean | isChild(java.lang.ClassLoader loader1, java.lang.ClassLoader loader2)Returns 'true' if 'loader2' is a delegation child of 'loader1' [or if
'loader1'=='loader2']. Of course, this works only for classloaders that
set their parent pointers correctly. 'null' is interpreted as the
primordial loader [i.e., everybody's parent].
if (loader1 == loader2) return true;
if (loader2 == null) return false;
if (loader1 == null) return true;
for ( ; loader2 != null; loader2 = loader2.getParent ())
{
if (loader2 == loader1) return true;
}
return false;
|
public static synchronized IClassLoadStrategy | setStrategy(IClassLoadStrategy strategy)Sets the classloader selection strategy to be used by subsequent calls
to {@link #getClassLoader()}. An instance of {@link ClassLoaderResolver.DefaultClassLoadStrategy}
is in effect if this method is never called.
if (strategy == null) throw new IllegalArgumentException ("null input: strategy");
final IClassLoadStrategy old = s_strategy;
s_strategy = strategy;
return old;
|