public class DefaultClassLoader extends ClassLoader implements ParallelClassLoader
BaseClassLoader
. This implementation extends
ClassLoader
.BaseClassLoader
,
ClasspathManager
Modifier and Type | Field and Description |
---|---|
protected static PermissionCollection |
ALLPERMISSIONS
A PermissionCollection for AllPermissions; shared across all ProtectionDomains when security is disabled
|
protected ClassLoaderDelegate |
delegate |
protected ProtectionDomain |
domain |
protected ClasspathManager |
manager |
Constructor and Description |
---|
DefaultClassLoader(ClassLoader parent,
ClassLoaderDelegate delegate,
ProtectionDomain domain,
BaseData bundledata,
String[] classpath)
Constructs a new DefaultClassLoader.
|
Modifier and Type | Method and Description |
---|---|
void |
attachFragment(BundleData sourcedata,
ProtectionDomain sourcedomain,
String[] sourceclasspath)
Attaches the BundleData for a fragment to this BundleClassLoader.
|
void |
close()
Closes this class loader.
|
ClasspathEntry |
createClassPathEntry(BundleFile bundlefile,
ProtectionDomain cpDomain)
Creates a classpath entry with the given bundle file and domain
|
static ProtectionDomain |
createProtectionDomain(BundleFile bundlefile,
ProtectionDomain baseDomain)
Creates a ProtectionDomain which uses specified BundleFile and the permissions of the baseDomain
|
Class<?> |
defineClass(String name,
byte[] classbytes,
ClasspathEntry classpathEntry,
BundleEntry entry)
Defines a Class.
|
List<URL> |
findEntries(String path,
String filePattern,
int options)
Returns resource entries for the bundle associated with this class loader.
|
protected String |
findLibrary(String libname)
Finds a library for this bundle.
|
Class<?> |
findLocalClass(String classname)
Finds a local class in the BundleClassLoader without
consulting the delegate.
|
URL |
findLocalResource(String resource)
Finds a local resource in the BundleClassLoader without
consulting the delegate.
|
Enumeration<URL> |
findLocalResources(String resource)
Finds all local resources in the BundleClassLoader with the specified
path without consulting the delegate.
|
protected Enumeration<URL> |
findResources(String name)
Finds all resources with the specified name.
|
Bundle |
getBundle()
Returns the
Bundle object associated with this
BundleReference . |
ClasspathManager |
getClasspathManager()
Returns the ClasspathManager for this BaseClassLoader
|
ClassLoaderDelegate |
getDelegate()
Returns the ClassLoaderDelegate used by this BundleClassLoader
|
ProtectionDomain |
getDomain()
Returns the domain for the host bundle of this class loader
|
URL |
getResource(String name)
Gets a resource for the bundle.
|
void |
initialize()
Initializes the ClassLoader.
|
boolean |
isParallelCapable()
Indicates if this class loader is parallel capable.
|
Collection<String> |
listLocalResources(String path,
String filePattern,
int options)
Returns the names of local resources visible to this bundle class loader.
|
Collection<String> |
listResources(String path,
String filePattern,
int options)
Returns the names of resources visible to this bundle class loader.
|
protected Class<?> |
loadClass(String name,
boolean resolve)
Loads a class for the bundle.
|
Object |
publicDefinePackage(String name,
String specTitle,
String specVersion,
String specVendor,
String implTitle,
String implVersion,
String implVendor,
URL sealBase)
A public version of the ClassLoader#definePackage(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.net.URL) method.
|
Class<?> |
publicFindLoaded(String classname)
A public version of the ClassLoader.findLoadedClass(java.lang.String) method.
|
Object |
publicGetPackage(String pkgname)
A public version of the ClassLoader#getPackage(java.lang.String) method.
|
String |
toString() |
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getParent, getResources, loadClass
protected static final PermissionCollection ALLPERMISSIONS
protected ClassLoaderDelegate delegate
protected ProtectionDomain domain
protected ClasspathManager manager
public DefaultClassLoader(ClassLoader parent, ClassLoaderDelegate delegate, ProtectionDomain domain, BaseData bundledata, String[] classpath)
parent
- the parent classloaderdelegate
- the delegate for this classloaderdomain
- the domain for this classloaderbundledata
- the bundledata for this classloaderclasspath
- the classpath for this classloaderprotected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
loadClass
in class ClassLoader
name
- the name of the class to load.resolve
- indicates whether to resolve the loaded class or not.ClassNotFoundException
- if the class is not found.public URL getResource(String name)
getResource
in interface BundleClassLoader
getResource
in class ClassLoader
name
- The resource path to get.protected Enumeration<URL> findResources(String name) throws IOException
findResources
in class ClassLoader
name
- The resource path to find.IOException
protected String findLibrary(String libname)
findLibrary
in class ClassLoader
libname
- The library to find.public ProtectionDomain getDomain()
BaseClassLoader
getDomain
in interface BaseClassLoader
public ClasspathEntry createClassPathEntry(BundleFile bundlefile, ProtectionDomain cpDomain)
BaseClassLoader
createClassPathEntry
in interface BaseClassLoader
bundlefile
- the source bundle file for a classpath entrycpDomain
- the source domain for a classpath entrypublic Class<?> defineClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry)
BaseClassLoader
defineClass
in interface BaseClassLoader
name
- the name of the class to defineclassbytes
- the bytes of the class to defineclasspathEntry
- the classpath entry used to load the class bytesentry
- the bundle entry used to load the class bytespublic Class<?> publicFindLoaded(String classname)
BaseClassLoader
publicFindLoaded
in interface BaseClassLoader
classname
- the class name to find.public Object publicGetPackage(String pkgname)
BaseClassLoader
publicGetPackage
in interface BaseClassLoader
pkgname
- the package name to get.public Object publicDefinePackage(String name, String specTitle, String specVersion, String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase)
BaseClassLoader
publicDefinePackage
in interface BaseClassLoader
public void initialize()
BundleClassLoader
initialize
in interface BundleClassLoader
public URL findLocalResource(String resource)
BundleClassLoader
findLocalResource
in interface BundleClassLoader
resource
- the resource path to find.public Enumeration<URL> findLocalResources(String resource)
BundleClassLoader
findLocalResources
in interface BundleClassLoader
resource
- the resource path to find.public Class<?> findLocalClass(String classname) throws ClassNotFoundException
BundleClassLoader
findLocalClass
in interface BundleClassLoader
classname
- the classname to find.ClassNotFoundException
- if the classname does not exist locally.public void close()
BundleClassLoader
close
in interface BundleClassLoader
public void attachFragment(BundleData sourcedata, ProtectionDomain sourcedomain, String[] sourceclasspath)
BundleClassLoader
attachFragment
in interface BundleClassLoader
sourcedata
- The BundleData of the fragment.sourcedomain
- The ProtectionDomain of the resources of the fragment.
Any classes loaded from the fragment's BundleData must belong to this
ProtectionDomain.sourceclasspath
- An array of Bundle-ClassPath entries to
use for loading classes and resources. This is specified by the
Bundle-ClassPath manifest entry of the fragment.public ClassLoaderDelegate getDelegate()
BundleClassLoader
getDelegate
in interface BundleClassLoader
public static ProtectionDomain createProtectionDomain(BundleFile bundlefile, ProtectionDomain baseDomain)
bundlefile
- The source bundlefile the domain is for.baseDomain
- The source domain.public ClasspathManager getClasspathManager()
BaseClassLoader
getClasspathManager
in interface BaseClassLoader
public Bundle getBundle()
BundleReference
Bundle
object associated with this
BundleReference
.getBundle
in interface BundleReference
Bundle
object associated with this
BundleReference
.public boolean isParallelCapable()
ParallelClassLoader
isParallelCapable
in interface ParallelClassLoader
public List<URL> findEntries(String path, String filePattern, int options)
BundleClassLoader
BundleWiring.findEntries(String, String, int)
method.findEntries
in interface BundleClassLoader
path
- The path name in which to look.filePattern
- The file name pattern for selecting resource names in
the specified path.options
- The options for listing resource names.BundleWiring#findEntries(String, String, int)}
public Collection<String> listResources(String path, String filePattern, int options)
BundleClassLoader
BundleWiring.listResources(String, String, int)
method.
This method should simply return the result of calling
ClassLoaderDelegate.listResources(String, String, int)
listResources
in interface BundleClassLoader
path
- The path name in which to look.filePattern
- The file name pattern for selecting resource names in
the specified path.options
- The options for listing resource names.BundleWiring#listResources(String, String, int)}
,
ClassLoaderDelegate#listResources(String, String, int)}
public Collection<String> listLocalResources(String path, String filePattern, int options)
BundleClassLoader
listLocalResources
in interface BundleClassLoader
path
- The path name in which to look.filePattern
- The file name pattern for selecting resource names in
the specified path.options
- The options for listing resource names.ClassLoaderDelegate#listResources(String, String, int)}
Copyright © 2007–2018 The Apache Software Foundation. All rights reserved.