|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.sape.carbon.core.util.reflection.GenericProxy
This generic implementation of a DynamicProxy
invocation handler will provide the basics of object method handling
for the methods hashCode, equals and toString. Any other method calls
will be forwarded to subclasses for implementation.
Invocation handlers wishing to provide specialized implementations of
the follow methods: { hashCode, toString, equals} should override those
versions of the methods defined in this class that start with the
key proxy
.
Copyright 2002 Sapient
Field Summary | |
private static Method |
equalsMethod
Preloaded Method object for the equals method of java.lang.Object |
private static Method |
hashCodeMethod
Preloaded Method object for the hashCode method of java.lang.Object |
private static Method |
toStringMethod
Preloaded Method object for the toString method of java.lang.Object |
Constructor Summary | |
GenericProxy()
|
Method Summary | |
protected abstract Object |
handleInvoke(Object proxy,
Method m,
Object[] args)
This abstract method should be implemented to handle the specific functionality for an invocation handler. |
Object |
invoke(Object proxy,
Method m,
Object[] args)
This method is called through by the JVM generated DynamicProxy for all calls to the represented object. |
protected Boolean |
proxyEquals(Object proxy,
Object other)
This method implements the standard proxyEquals method for subclassed invocation handler dynamic proxies. |
protected Integer |
proxyHashCode(Object proxy)
Implements the standard hashCode method with a simple call to System.identityHashCode(). |
protected String |
proxyToString(Object proxy)
Prints out a string representation of the proxy object in the standard Java Object toString format of <classname>@<hashcode> |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static Method hashCodeMethod
private static Method equalsMethod
private static Method toStringMethod
Constructor Detail |
public GenericProxy()
Method Detail |
public Object invoke(Object proxy, Method m, Object[] args) throws Throwable
Object
class methods and forwards all other method calls to
the abstract handleInvoke
method.
invoke
in interface InvocationHandler
proxy
- the object that is being representedm
- the method descriptor for the method calledargs
- an array of arguments passed to that method
Throwable
- when there is an exception thrown from the
delegated method. This may be a Checked
exception if the implemented interface declares
the exception. Otherwise checked exceptions will
be automatically wrapped in an
UndeclaredThrowableException
.
Runtime exceptions are thrown as is.protected abstract Object handleInvoke(Object proxy, Method m, Object[] args) throws Throwable
proxy
- the object that is being representedm
- the method descriptor for the method calledargs
- an array of arguments passed to that method
Throwable
- when there is an exception thrown from the
delegated method. This may be a Checked
exception if the implemented interface declares
the exception. Otherwise checked exceptions will
be automatically wrapped in an
UndeclaredThrowableException
.
Runtime exceptions are thrown as is.protected Integer proxyHashCode(Object proxy)
proxy
- the object for which a hashcode should
be returned
protected Boolean proxyEquals(Object proxy, Object other)
proxy
- the proxy object for which equals is
being handledother
- the other object being compared too
protected String proxyToString(Object proxy)
proxy
- the proxy object to toString
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |