|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.neo4j.kernel.ha.DelegateInvocationHandler<T>
public class DelegateInvocationHandler<T>
InvocationHandler for dynamic proxies that delegate calls to a given backing implementation. This is mostly
used to present a single object to others, while being able to switch implementation at runtime.
There are concepts of snapshot(Object) and #cement(Object) in here, which serves different purposes:
snapshot(Object): acquire the actual delegate at this particular point in time, pulling it out
from the proxy and using it directly. This is used for acquiring a snapshot and keep using that particular
instance, even if a new delegate is assigned for this handler.#cement(Object): acquire a proxy that will have its delegate assigned the next call to
setDelegate(Object). This is useful if one DelegateInvocationHandler depends on
another which will have its delegate set later than this one.
| Constructor Summary | |
|---|---|
DelegateInvocationHandler(Class<T> interfaceClass)
|
|
| Method Summary | ||
|---|---|---|
T |
cement()
Cements this delegate, i.e. |
|
void |
harden()
Updates cemented delegates with the current delegate, making it concrete. |
|
Object |
invoke(Object proxy,
Method method,
Object[] args)
|
|
void |
setDelegate(T delegate)
Updates the delegate for this handler, also hardens instances
cemented from the last call to setDelegate(Object). |
|
static
|
snapshot(T proxiedInstance)
Takes a snapshot of the current delegate and returns that. |
|
String |
toString()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DelegateInvocationHandler(Class<T> interfaceClass)
| Method Detail |
|---|
public void setDelegate(T delegate)
hardens instances
cemented from the last call to setDelegate(Object).
This call will also dereference the Concrete, such that future calls to harden()
cannot affect any reference received from cement() prior to this call.
delegate - the new delegate to set.public void harden()
cemented delegates with the current delegate, making it concrete.
Callers of #cement(Object) in between this call and the previous call to setDelegate(Object)
will see the current delegate.
public Object invoke(Object proxy,
Method method,
Object[] args)
throws Throwable
invoke in interface InvocationHandlerThrowablepublic T cement()
public static <T> T snapshot(T proxiedInstance)
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||