org.apache.tools.ant.util

Class LoaderUtils

public class LoaderUtils extends Object

ClassLoader utility methods
Method Summary
static FilegetClassSource(Class c)
Find the directory or jar file the class has been loaded from.
static ClassLoadergetContextClassLoader()
JDK1.1 compatible access to set the context class loader.
static FilegetResourceSource(ClassLoader c, String resource)
Find the directory or a give resource has been loaded from.
static booleanisContextLoaderAvailable()
Indicates if the context class loader methods are available
static voidsetContextClassLoader(ClassLoader loader)
Set the context classloader

Method Detail

getClassSource

public static File getClassSource(Class c)
Find the directory or jar file the class has been loaded from.

Parameters: c the class whose location is required.

Returns: the file or jar with the class or null if we cannot determine the location.

Since: Ant 1.6

getContextClassLoader

public static ClassLoader getContextClassLoader()
JDK1.1 compatible access to set the context class loader.

Returns: the ClassLoader instance being used as the context classloader on the current thread. Returns null on JDK 1.1

getResourceSource

public static File getResourceSource(ClassLoader c, String resource)
Find the directory or a give resource has been loaded from.

Parameters: c the classloader to be consulted for the source resource the resource whose location is required.

Returns: the file with the resource source or null if we cannot determine the location.

Since: Ant 1.6

isContextLoaderAvailable

public static boolean isContextLoaderAvailable()
Indicates if the context class loader methods are available

Returns: true if the get and set methods dealing with the context classloader are available.

setContextClassLoader

public static void setContextClassLoader(ClassLoader loader)
Set the context classloader

Parameters: loader the ClassLoader to be used as the context class loader on the current thread.

Copyright B) 2000-2007 Apache Software Foundation. All Rights Reserved.