1 22 package org.jboss.invocation.http.interfaces; 23 24 import java.io.Externalizable ; 25 import java.lang.reflect.Method ; 26 27 import org.jboss.invocation.Invocation; 28 import org.jboss.proxy.Interceptor; 29 30 35 public class ClientMethodInterceptor extends Interceptor 36 implements Externalizable 37 { 38 39 private static final long serialVersionUID = 3511654206312502958L; 40 41 47 public Object invoke(Invocation mi) throws Throwable 48 { 49 Method m = mi.getMethod(); 50 String methodName = m.getName(); 51 HttpInvokerProxy proxy = (HttpInvokerProxy) mi.getInvocationContext().getInvoker(); 52 if( methodName.equals("toString") ) 54 { 55 return toString(proxy); 56 } 57 if( methodName.equals("equals") ) 58 { 59 Object [] args = mi.getArguments(); 60 String thisString = toString(proxy); 61 String argsString = args[0] == null ? "" : args[0].toString(); 62 return new Boolean (thisString.equals(argsString)); 63 } 64 if( methodName.equals("hashCode") ) 65 { 66 return (Integer ) mi.getObjectName(); 67 } 68 69 return getNext().invoke(mi); 70 } 71 72 private String toString(HttpInvokerProxy proxy) 73 { 74 StringBuffer tmp = new StringBuffer (proxy.toString()); 75 tmp.append('{'); 76 tmp.append("externalURLValue="+proxy.getExternalURLValue()); 77 tmp.append(",externalURL="+proxy.getExternalURL()); 78 tmp.append('}'); 79 return tmp.toString(); 80 } 81 } 82 | Popular Tags |