|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.dynalang.classtoken.ClassToken
public class ClassToken
The class token is used as a surrogate representation for a
Class
object in various contexts where it is undesirable
to keep a strong reference to the Class object itself. This class guarantees
that at most one ClassToken object exists for every loaded Class object.
Holding a reference to a ClassToken does not prevent the Class object from
unloading. There is an event listener mechanism to observe when a ClassToken
becomes invalid (its associated class becomes unloaded).
Constructor Summary | |
---|---|
ClassToken()
|
Method Summary | |
---|---|
static void |
addClassRefListener(ClassTokenListener listener)
Adds a ClassTokenListener that will get notified whenever a
ClassToken object gets invalidated. |
static ClassToken |
forClass(java.lang.Class<?> clazz)
Gets a class token for a given class. |
static void |
removeClassRefListener(ClassTokenListener listener)
Removes a ClassTokenListener previously registered with the
addClassRefListener(ClassTokenListener) method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClassToken()
Method Detail |
---|
public static ClassToken forClass(java.lang.Class<?> clazz)
clazz
- the class for which the token is requested
public static void addClassRefListener(ClassTokenListener listener)
ClassTokenListener
that will get notified whenever a
ClassToken
object gets invalidated.
listener
- the listenerpublic static void removeClassRefListener(ClassTokenListener listener)
ClassTokenListener
previously registered with the
addClassRefListener(ClassTokenListener)
method. It is not
strictly necessary to eagerly remove listeners, as this class references
its listeners weakly, and won't prevent a listener from getting garbage
collected.
listener
- the listener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |