|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.ClassLoader
java.security.SecureClassLoader
org.apache.sling.jcr.classloader.internal.DynamicRepositoryClassLoader
public final class DynamicRepositoryClassLoader
The DynamicRepositoryClassLoader
class provides the
functionality to load classes and resources from the JCR Repository.
Additionally, this class supports the notion of getting 'dirty', which means,
that if a resource loaded through this class loader has been modified in the
Repository, this class loader marks itself dirty, which flag can get
retrieved. This helps the user of this class loader to decide on whether to
reinstantiate
it or continue
using this class loader.
When a user of the class loader recognizes an instance to be dirty, it can
easily be reinstantiated with the reinstantiate(javax.jcr.Session, java.lang.ClassLoader)
method. This
reinstantiation will also rebuild the internal real class path from the same
list of path patterns as was used to create the internal class path for the
original class loader. The resulting internal class path need not be the
same, though.
Nested Class Summary | |
---|---|
protected static class |
DynamicRepositoryClassLoader.ProxyEventListener
|
Constructor Summary | |
---|---|
DynamicRepositoryClassLoader(javax.jcr.Session session,
String[] classPath,
ClassLoader parent)
Creates a DynamicRepositoryClassLoader from a list of item
path strings containing globbing pattens for the paths defining the
class path. |
Method Summary | |
---|---|
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<URL> |
findResources(String name)
Returns an Enumeration of URLs representing all of the resources on the search path having the specified name. |
boolean |
isDirty()
Returns whether the class loader is dirty. |
boolean |
isLive()
Is this class loader still alive/valid? |
void |
onEvent(javax.jcr.observation.EventIterator events)
Handles a repository item modifcation events checking whether a class needs to be expired. |
DynamicRepositoryClassLoader |
reinstantiate(javax.jcr.Session session,
ClassLoader parent)
Reinstantiates this class loader. |
String |
toString()
Returns a string representation of this class loader. |
Methods inherited from class java.security.SecureClassLoader |
---|
defineClass, defineClass, getPermissions |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DynamicRepositoryClassLoader(javax.jcr.Session session, String[] classPath, ClassLoader parent)
DynamicRepositoryClassLoader
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 |
---|
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 ClassLoader
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 ClassLoader
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<URL> findResources(String name)
findResources
in class ClassLoader
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 boolean isDirty()
This method may also return true
if the Session
associated with this class loader is not valid anymore.
Finally the method always returns true
if the class loader
has already been destroyed. Note, however, that a destroyed class loader
cannot be reinstantiated. See reinstantiate(Session, ClassLoader)
.
If the class loader is dirty, it should be reinstantiated through the
reinstantiate(javax.jcr.Session, java.lang.ClassLoader)
method.
true
if the class loader is dirty and needs
reinstantiation.public boolean isLive()
DynamicClassLoader
isLive
in interface DynamicClassLoader
DynamicClassLoader.isLive()
public DynamicRepositoryClassLoader reinstantiate(javax.jcr.Session session, ClassLoader parent)
When the new class loader is returned, this class loader has been destroyed and may not be used any more.
parent
- The parent ClassLoader
for the reinstantiated
DynamicRepositoryClassLoader
, which may be
null
.
IllegalStateException
- if this
DynamicRepositoryClassLoader
has already been destroyed
through the destroy()
method.public void onEvent(javax.jcr.observation.EventIterator events)
onEvent
in interface javax.jcr.observation.EventListener
events
- The iterator of repository events to be handled.public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |