Package org.apache.commons.vfs2.impl
Class VFSClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
org.apache.commons.vfs2.impl.VFSClassLoader
A class loader that can load classes and resources from a search path.
 
The search path can consist of VFS FileObjects referring both to folders and JAR files. Any FileObject of type FileType.FILE is assumed to be a JAR and is opened by creating a layered file system with the "jar" scheme.
TODO - Test this with signed Jars and a SecurityManager.
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionVFSClassLoader(FileObject[] files, FileSystemManager manager) Constructors a new VFSClassLoader for the given files.VFSClassLoader(FileObject[] files, FileSystemManager manager, ClassLoader parent) Constructors a new VFSClassLoader for the given FileObjects.VFSClassLoader(FileObject file, FileSystemManager manager) Constructors a new VFSClassLoader for the given file.VFSClassLoader(FileObject file, FileSystemManager manager, ClassLoader parent) Constructors a new VFSClassLoader for the given file.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidCopies the permissions from src to dest.protected Class<?> Finds and loads the class with the specified name from the search path.protected URLfindResource(String name) Finds the resource with the specified name from the search path.protected Enumeration<URL> findResources(String name) Returns an Enumeration of all the resources in the search path with the specified name.Provide access to the file objects this class loader represents.protected PermissionCollectionCalls super.getPermissions both for the code source and also adds the permissions granted to the parent layers.Methods inherited from class java.security.SecureClassLoaderdefineClass, defineClassMethods inherited from class java.lang.ClassLoaderclearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
- 
Constructor Details- 
VFSClassLoaderConstructors a new VFSClassLoader for the given file.- Parameters:
- file- the file to load the classes and resources from.
- manager- the FileManager to use when trying to create a layered Jar file system.
- Throws:
- FileSystemException- if an error occurs.
 
- 
VFSClassLoaderpublic VFSClassLoader(FileObject file, FileSystemManager manager, ClassLoader parent) throws FileSystemException Constructors a new VFSClassLoader for the given file.- Parameters:
- file- the file to load the classes and resources from.
- manager- the FileManager to use when trying to create a layered Jar file system.
- parent- the parent class loader for delegation.
- Throws:
- FileSystemException- if an error occurs.
 
- 
VFSClassLoaderConstructors a new VFSClassLoader for the given files. The files will be searched in the order specified.- Parameters:
- files- the files to load the classes and resources from.
- manager- the FileManager to use when trying to create a layered Jar file system.
- Throws:
- FileSystemException- if an error occurs.
 
- 
VFSClassLoaderpublic VFSClassLoader(FileObject[] files, FileSystemManager manager, ClassLoader parent) throws FileSystemException Constructors a new VFSClassLoader for the given FileObjects. The FileObjects will be searched in the order specified.- Parameters:
- files- the FileObjects to load the classes and resources from.
- manager- the FileManager to use when trying to create a layered Jar file system.
- parent- the parent class loader for delegation.
- Throws:
- FileSystemException- if an error occurs.
 
 
- 
- 
Method Details- 
copyPermissionsCopies the permissions from src to dest.- Parameters:
- src- The source PermissionCollection.
- dest- The destination PermissionCollection.
 
- 
findClassFinds and loads the class with the specified name from the search path.- Overrides:
- findClassin class- ClassLoader
- Throws:
- ClassNotFoundException- if the class is not found.
 
- 
findResourceFinds the resource with the specified name from the search path. This returns null if the resource is not found.- Overrides:
- findResourcein class- ClassLoader
- Parameters:
- name- The resource name.
- Returns:
- The URL that matches the resource.
 
- 
findResourcesReturns an Enumeration of all the resources in the search path with the specified name.Gets called from ClassLoader.getResources(String)after parent class loader was questioned.- Overrides:
- findResourcesin class- ClassLoader
- Parameters:
- name- The resources to find.
- Returns:
- An Enumeration of the resources associated with the name.
- Throws:
- FileSystemException- if an error occurs.
- IOException
 
- 
getFileObjectsProvide access to the file objects this class loader represents.- Returns:
- An array of FileObjects.
- Since:
- 2.0
 
- 
getPermissionsCalls super.getPermissions both for the code source and also adds the permissions granted to the parent layers.- Overrides:
- getPermissionsin class- SecureClassLoader
- Parameters:
- cs- the CodeSource.
- Returns:
- The PermissionCollections.
 
 
-