|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
org.apache.jackrabbit.classloader.RepositoryClassLoader
public class RepositoryClassLoader
The RepositoryClassLoader
class extends the
URLClassLoader
and provides the functionality to load classes
and resources from JCR Repository.
This class loader supports loading classes from the Repository hierarchy, such as a classes 'folder', but also from Jar and Zip files stored in the Repository.
For enhanced performance, this class loader keeps a list of resources and classes which have already been loaded through this class loader. If later requests ask for already cached resources, these are returned without checking whether the underlying repository actually still exists.
This class is not intended to be extended by clients.
Constructor Summary | |
---|---|
RepositoryClassLoader(Session session,
String[] classPath,
ClassLoader parent)
Creates a RepositoryClassLoader from a list of item path
strings containing globbing pattens for the paths defining the class
path. |
Method Summary | |
---|---|
protected void |
addClassPathEntry(org.apache.jackrabbit.classloader.ClassPathEntry cpe)
Adds the class path entry to the current class path list. |
protected org.apache.jackrabbit.classloader.ClassPathEntry[] |
addClassPathEntry(org.apache.jackrabbit.classloader.ClassPathEntry[] list,
org.apache.jackrabbit.classloader.ClassPathEntry newEntry)
Helper method for class path handling to a new entry to an existing list and return the new list. |
void |
addHandle(String path)
Appends the specified path to the list of handles to search for classes and resources. |
protected void |
addURL(URL url)
Appends the specified URL to the list of URLs to search for classes and resources. |
protected void |
buildRepository()
Builds the repository list from the list of path patterns and appends the path entries from any added handles. |
protected void |
cleanCache()
Removes all entries from the cache of loaded resources, which mark resources, which have not been found as of yet. |
void |
destroy()
Destroys this class loader. |
protected Class |
findClass(String name)
Finds and loads the class with the specified name from the class path. |
URL |
findResource(String name)
Finds the resource with the specified name on the search path. |
Enumeration |
findResources(String name)
Returns an Enumeration of URLs representing all of the resources on the search path having the specified name. |
protected org.apache.jackrabbit.classloader.ClassPathEntry[] |
getRepository()
Returns the current active class path entries list or null
if this class loader has already been destroyed. |
protected Session |
getSession()
Returns the session used by this class loader to access the repository. |
URL[] |
getURLs()
Returns the search path of URLs for loading classes and resources. |
protected boolean |
hasLoadedResources()
Returns true , if the cache is not empty. |
protected boolean |
isDestroyed()
Returns true if this class loader has already been destroyed
by calling destroy() . |
protected void |
setRepository(org.apache.jackrabbit.classloader.ClassPathEntry[] classPath)
Sets the current active class path to the list of class path entries. |
String |
toString()
Returns a string representation of this instance. |
Methods inherited from class java.net.URLClassLoader |
---|
definePackage, getPermissions, newInstance, newInstance |
Methods inherited from class java.security.SecureClassLoader |
---|
defineClass, defineClass |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public RepositoryClassLoader(Session session, String[] classPath, ClassLoader parent)
RepositoryClassLoader
from a list of item path
strings containing globbing pattens for the paths defining the class
path.
session
- The Session
to use to access the class items.classPath
- The list of path strings making up the (initial) class
path of this class loader. The strings may contain globbing
characters which will be resolved to build the actual class path.parent
- The parent ClassLoader
, which may be
null
.
NullPointerException
- if either the session or the handles list is
null
.Method Detail |
---|
protected boolean isDestroyed()
true
if this class loader has already been destroyed
by calling destroy()
.
public void destroy()
NOTE: This method just clears all internal fields and especially the class path to render this class loader unusable.
This implementation does not throw any exceptions.
protected Class findClass(String name) throws ClassNotFoundException
findClass
in class URLClassLoader
name
- the name of the class
ClassNotFoundException
- If the named class could not be found or
if this class loader has already been destroyed.public URL findResource(String name)
findResource
in class URLClassLoader
name
- the name of the resource
URL
for the resource, or null
if the resource could not be found or if the class loader has
already been destroyed.public Enumeration findResources(String name)
findResources
in class URLClassLoader
name
- the resource name
Enumeration
of URL
s. This is an
empty enumeration if no resources are found by this class loader
or if this class loader has already been destroyed.public URL[] getURLs()
addURL(URL)
and addHandle(String)
methods.
getURLs
in class URLClassLoader
protected void addURL(URL url)
JCR
are considered for addition. The system will find out
whether the URL points to a directory or a jar archive.
URLs added using this method will be preserved through reconfiguration and reinstantiation.
If this class loader has already been destroyed this method has no effect.
addURL
in class URLClassLoader
url
- the JCR
URL to be added to the search path of
URLs.public void addHandle(String path)
If this class loader has already been destroyed, this method has no effect.
path
- The path to be added to the search path.protected void cleanCache()
NullPointerException
- If this class loader has already been
destroyed.protected boolean hasLoadedResources()
true
, if the cache is not empty. If the
cleanCache()
method is not called before calling this method, a
false positive result may be returned.
NullPointerException
- If this class loader has already been
destroyed.protected Session getSession()
null
is returned.
protected void setRepository(org.apache.jackrabbit.classloader.ClassPathEntry[] classPath)
protected org.apache.jackrabbit.classloader.ClassPathEntry[] getRepository()
null
if this class loader has already been destroyed.
protected void addClassPathEntry(org.apache.jackrabbit.classloader.ClassPathEntry cpe)
protected org.apache.jackrabbit.classloader.ClassPathEntry[] addClassPathEntry(org.apache.jackrabbit.classloader.ClassPathEntry[] list, org.apache.jackrabbit.classloader.ClassPathEntry newEntry)
If list
is null
a new array is returned with
a single element newEntry
. Otherwise the array returned
contains all elements of list
and newEntry
at the last position.
list
- The array of class path entries, to which a new entry is
to be appended. This may be null
.newEntry
- The new entry to append to the class path list.
public String toString()
toString
in class Object
protected void buildRepository()
NullPointerException
- If this class loader has already been
destroyed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |