public final class CWClassLoader extends ClassLoader
The GNU Lesser General Public License for details.
Modifier and Type | Class and Description |
---|---|
private static class |
CWClassLoader.PrivilegedLoader<T>
PrivilegedLoader creates a CWClassLoader if it is able to obtain java
security permissions to do so.
|
Modifier and Type | Field and Description |
---|---|
private static URI[] |
homes
Notion of a project's home from where additional resources can be found.
|
private Class<?> |
owner
The class to which the resources belong
|
Constructor and Description |
---|
CWClassLoader()
Creates a class loader that finds resources for the calling class that
may not be in the class' package.
|
CWClassLoader(Class<?> resourceOwner)
Creates a class loader that finds resources for the supplied class that
may not be in the class' package.
|
Modifier and Type | Method and Description |
---|---|
private String |
adjustPackageSearch(String aSearch)
Prefix the search with a package prefix, if not already.
|
private String |
adjustPathSearch(String aSearch)
Change all but a leading '/' to '.'
|
static URI |
findHomeResource(String search)
Look for the resource in the home directories, returning the first
readable file.
|
URL |
findResource(String search) |
ClassLoader |
getClassLoader()
Pick the best class loader
|
static URI |
getHome(int i)
If the application has set the homes, it will return the application's
requested home directory, otherwise it returns null.
|
static CWClassLoader |
instance()
Creates a privileged class loader that finds resources for the calling
class that may not be in the class' package.
|
static CWClassLoader |
instance(Class<?> resourceOwner)
Creates a privileged class loader that finds resources for the supplied
class that may not be in the class' package.
|
private static ClassLoader |
pickLoader(ClassLoader loader1,
ClassLoader loader2)
Returns 'true' if 'loader2' is a delegation child of 'loader1' [or if
'loader1'=='loader2'].
|
static void |
setHome(URI[] newHomes)
Establish the applications home directory from where additional resources
can be found.
|
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResources, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
private Class<?> owner
private static URI[] homes
CWClassLoader(Class<?> resourceOwner)
resourceOwner
- is the owner of the resourceCWClassLoader()
public static CWClassLoader instance(Class<?> resourceOwner)
resourceOwner
- is the owner of the resourcepublic static CWClassLoader instance()
public URL findResource(String search)
findResource
in class ClassLoader
private String adjustPackageSearch(String aSearch)
aSearch
- the search to adjustprivate String adjustPathSearch(String aSearch)
aSearch
- the search to adjustpublic ClassLoader getClassLoader()
private static ClassLoader pickLoader(ClassLoader loader1, ClassLoader loader2)
loader1
- a class loader to considerloader2
- a class loader to considerpublic static URI getHome(int i)
i
- get the i-th homepublic static void setHome(URI[] newHomes)
newHomes
- The home to set.