org.jboss.proxy
public class: ClientMethodInterceptor [javadoc |
source]
java.lang.Object
org.jboss.proxy.Interceptor
org.jboss.proxy.ClientMethodInterceptor
All Implemented Interfaces:
Externalizable
Handle toString, equals, hashCode locally on the client.
- author:
Scott.Stark - @jboss.org
- author:
adrian - @jboss.com
- version:
$ - Revision: 37459 $
| Method from org.jboss.proxy.ClientMethodInterceptor Summary: |
|---|
|
getObject, invoke |
| Method from org.jboss.proxy.ClientMethodInterceptor Detail: |
protected Object getObject(Invocation mi) {
Object cacheId = mi.getInvocationContext().getCacheId();
if (cacheId != null)
return cacheId;
else
return mi.getInvocationContext().getInvoker();
}
Get the object used in Object methods |
public Object invoke(Invocation mi) throws Throwable {
Method m = mi.getMethod();
String methodName = m.getName();
// Implement local methods
if (methodName.equals("toString"))
{
Object obj = getObject(mi);
return obj.toString();
}
if (methodName.equals("equals"))
{
Object obj = getObject(mi);
Object[] args = mi.getArguments();
String thisString = obj.toString();
String argsString = args[0] == null ? "" : args[0].toString();
return new Boolean(thisString.equals(argsString));
}
if( methodName.equals("hashCode") )
{
Object obj = getObject(mi);
return new Integer(obj.hashCode());
}
return getNext().invoke(mi);
}
Handle methods locally on the client |