public class ClasspathManager extends Object
BaseClassLoader
implementations. This class will keep track of
ClasspathEntry
objects for the host bundle and any attached fragment bundles. This
class takes care of searching the ClasspathEntry
objects for a base class loader
implementation. Additional behavior may be added to a classpath manager by configuring
ClassLoadingHook
and ClassLoadingStatsHook
.BaseClassLoader
,
ClassLoadingHook
,
ClassLoadingStatsHook
Constructor and Description |
---|
ClasspathManager(BaseData data,
String[] classpath,
BaseClassLoader classloader)
Constructs a classpath manager for the given host base data, classpath and base class loader
|
Modifier and Type | Method and Description |
---|---|
static boolean |
addClassPathEntry(ArrayList<ClasspathEntry> result,
String cp,
ClasspathManager hostloader,
BaseData sourcedata,
ProtectionDomain sourcedomain)
Adds a ClasspathEntry for the requested classpath to the result.
|
void |
attachFragment(BundleData sourcedata,
ProtectionDomain sourcedomain,
String[] sourceclasspath)
Attaches the specified sourcedata, sourcedomain and sourceclasspath to this classpath manager
|
void |
close()
Closes all the classpath entry resources for this classpath manager.
|
static void |
findClassPathEntry(ArrayList<ClasspathEntry> result,
String cp,
ClasspathManager hostloader,
BaseData sourcedata,
ProtectionDomain sourcedomain)
Finds all the ClasspathEntry objects for the requested classpath.
|
List<URL> |
findEntries(String path,
String filePattern,
int options) |
String |
findLibrary(String libname)
Finds a library for the bundle represented by this class path managert
|
Class<?> |
findLocalClass(String classname)
Finds a local class by searching the ClasspathEntry objects of the classpath manager.
|
Enumeration<BundleEntry> |
findLocalEntries(String path)
Finds the local entries by searching the ClasspathEntry objects of the classpath manager.
|
BundleEntry |
findLocalEntry(String path)
Finds a local entry by searching the ClasspathEntry objects of the classpath manager.
|
BundleEntry |
findLocalEntry(String path,
int classPathIndex)
Finds a local entry by searching the ClasspathEntry with the specified
class path index.
|
URL |
findLocalResource(String resource)
Finds a local resource by searching the ClasspathEntry objects of the classpath manager.
|
Enumeration<URL> |
findLocalResources(String resource)
Finds the local resources by searching the ClasspathEntry objects of the classpath manager.
|
BaseClassLoader |
getBaseClassLoader()
Returns the base class loader used by this classpath manager
|
BaseData |
getBaseData()
Returns the host base data for this classpath manager
|
ClasspathEntry |
getClasspath(String cp,
BaseData sourcedata,
ProtectionDomain sourcedomain)
Creates a new ClasspathEntry object for the requested classpath if the source exists.
|
ClasspathEntry |
getExternalClassPath(String cp,
BaseData sourcedata,
ProtectionDomain sourcedomain)
Uses the requested classpath as an absolute path to locate a source for a new ClasspathEntry.
|
FragmentClasspath[] |
getFragmentClasspaths()
Returns the fragment classpaths of this classpath manager
|
ClasspathEntry[] |
getHostClasspathEntries()
Returns the host classpath entries for this classpath manager
|
void |
initialize()
initializes this classpath manager.
|
Collection<String> |
listLocalResources(String path,
String filePattern,
int options) |
public ClasspathManager(BaseData data, String[] classpath, BaseClassLoader classloader)
data
- the host base data for this classpath managerclasspath
- the host classpath for this classpath managerclassloader
- the BaseClassLoader for this classpath managerpublic void initialize()
After the classpath manager is initialized all configured class loading hooks
ClassLoadingHook.initializedClassLoader(BaseClassLoader, BaseData)
methods are called.
public void close()
public void attachFragment(BundleData sourcedata, ProtectionDomain sourcedomain, String[] sourceclasspath)
sourcedata
- the source fragment BundleData that should be attached.sourcedomain
- the source fragment domain that should be attached.sourceclasspath
- the source fragment classpath that should be attached.public static void findClassPathEntry(ArrayList<ClasspathEntry> result, String cp, ClasspathManager hostloader, BaseData sourcedata, ProtectionDomain sourcedomain)
ClassLoadingHook.addClassPathEntry(ArrayList, String, ClasspathManager, BaseData, ProtectionDomain)
methods. This allows class loading hooks to add additional ClasspathEntry objects to the result for the
requested classpath. Then the local host classpath entries and attached fragment classpath entries are
searched.result
- a list of ClasspathEntry objects. This list is used to add new ClasspathEntry objects to.cp
- the requested classpath.hostloader
- the host classpath manager for the classpathsourcedata
- the source EquionoxData to search for the classpathsourcedomain
- the source domain to used by the new ClasspathEntrypublic static boolean addClassPathEntry(ArrayList<ClasspathEntry> result, String cp, ClasspathManager hostloader, BaseData sourcedata, ProtectionDomain sourcedomain)
result
- a list of ClasspathEntry objects. This list is used to add new ClasspathEntry objects to.cp
- the requested classpath.hostloader
- the host classpath manager for the classpathsourcedata
- the source EquionoxData to search for the classpathsourcedomain
- the source domain to used by the new ClasspathEntrypublic ClasspathEntry getClasspath(String cp, BaseData sourcedata, ProtectionDomain sourcedomain)
cp
- the requested classpath.sourcedata
- the source EquionoxData to search for the classpathsourcedomain
- the source domain to used by the new ClasspathEntrypublic ClasspathEntry getExternalClassPath(String cp, BaseData sourcedata, ProtectionDomain sourcedomain)
cp
- the requested classpathsourcedata
- the source EquionoxData to search for the classpathsourcedomain
- the source domain to used by the new ClasspathEntrypublic URL findLocalResource(String resource)
ClassLoadingStatsHook.preFindLocalResource(String, ClasspathManager)
methods. Then it
will search for the resource. Finally it will call all the configured class loading stats hooks
ClassLoadingStatsHook.postFindLocalResource(String, URL, ClasspathManager)
methods.resource
- the requested resource name.public Enumeration<URL> findLocalResources(String resource)
resource
- the requested resource name.public BundleEntry findLocalEntry(String path)
path
- the requested entry path.public BundleEntry findLocalEntry(String path, int classPathIndex)
path
- the requested entry path.classPathIndex
- the index of the ClasspathEntry to searchpublic Enumeration<BundleEntry> findLocalEntries(String path)
path
- the requested entry path.public Class<?> findLocalClass(String classname) throws ClassNotFoundException
ClassLoadingStatsHook.preFindLocalClass(String, ClasspathManager)
methods. Then it
will search for the class. If a class is found then
ClassLoadingHook.processClass(String, byte[], ClasspathEntry, BundleEntry, ClasspathManager)
methods will be called.ClassLoadingStatsHook.recordClassDefine(String, Class, byte[], ClasspathEntry, BundleEntry, ClasspathManager)
methods are called.ClassLoadingStatsHook.postFindLocalClass(String, Class, ClasspathManager)
methods are called.classname
- the requested class name.ClassNotFoundException
- if the class does not existpublic BaseData getBaseData()
public FragmentClasspath[] getFragmentClasspaths()
public ClasspathEntry[] getHostClasspathEntries()
public BaseClassLoader getBaseClassLoader()
public String findLibrary(String libname)
libname
- the library namepublic Collection<String> listLocalResources(String path, String filePattern, int options)
Copyright © 2007–2018 The Apache Software Foundation. All rights reserved.