1 22 23 package org.jboss.test.javassist.test.support; 24 25 import java.lang.reflect.Method ; 26 import java.lang.reflect.InvocationTargetException ; 27 import java.util.AbstractCollection ; 28 29 import javassist.util.proxy.MethodHandler; 30 import javassist.util.proxy.RuntimeSupport; 31 32 36 37 public class MyCollectionHandler implements MethodHandler 38 { 39 private AbstractCollection delegate; 40 41 public MyCollectionHandler(AbstractCollection delegate) 42 { 43 this.delegate = delegate; 44 } 45 46 public Object invoke(Object self, Method thisMethod, Method proceed, Object [] args) 47 throws Exception 48 { 49 Object result = null; 50 try 51 { 52 result = thisMethod.invoke(delegate, args); 53 } 54 catch (InvocationTargetException e) 55 { 56 Throwable t = e.getTargetException(); 57 if( t instanceof Exception ) 58 throw (Exception ) t; 59 else if( t instanceof Error ) 60 throw (Error ) t; 61 throw e; 63 } 64 65 return result; 66 } 67 68 } 69 | Popular Tags |