1 23 package org.hammurapi.results; 24 25 import java.lang.reflect.InvocationHandler ; 26 import java.lang.reflect.Method ; 27 import java.lang.reflect.Proxy ; 28 29 import com.pavelvlasov.wrap.WrapperHandler; 30 31 37 public class ReportMixer { 38 39 public static Report mix(final CompositeResults cr, final String description) { 40 Class [] cri=WrapperHandler.getClassInterfaces(cr.getClass()); 41 Class [] interfaces=new Class [cri.length+1]; 42 System.arraycopy(cri,0,interfaces,0,cri.length); 43 interfaces[cri.length]=Report.class; 44 45 return (Report) Proxy.newProxyInstance( 46 cr.getClass().getClassLoader(), 47 interfaces, 48 new InvocationHandler () { 49 50 public Object invoke(Object proxy, Method method, Object [] args) throws Throwable { 51 if ("getDescription".equals(method.getName()) && method.getParameterTypes().length==0) { 52 return description; 53 } 54 55 return method.invoke(cr, args); 56 } 57 58 } 59 ); 60 } 61 } 62 | Popular Tags |