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 ClientMethodInterceptorHA extends Interceptor 36 implements Externalizable 37 { 38 41 private static final long serialVersionUID = 7633261444020820792L; 42 43 49 public Object invoke(Invocation mi) throws Throwable 50 { 51 Method m = mi.getMethod(); 52 String methodName = m.getName(); 53 HttpInvokerProxyHA proxy = (HttpInvokerProxyHA) mi.getInvocationContext().getInvoker(); 54 if( methodName.equals("toString") ) 56 { 57 return toString(proxy); 58 } 59 if( methodName.equals("equals") ) 60 { 61 Object [] args = mi.getArguments(); 62 String thisString = toString(proxy); 63 String argsString = args[0] == null ? "" : args[0].toString(); 64 return new Boolean (thisString.equals(argsString)); 65 } 66 if( methodName.equals("hashCode") ) 67 { 68 return (Integer ) mi.getObjectName(); 69 } 70 71 return getNext().invoke(mi); 72 } 73 74 private String toString(HttpInvokerProxyHA proxy) 75 { 76 StringBuffer tmp = new StringBuffer (proxy.toString()); 77 tmp.append('{'); 78 tmp.append("clusterInfo="+proxy.getClusterInfo()); 79 tmp.append('}'); 80 return tmp.toString(); 81 } 82 } 83 | Popular Tags |