1 34 package groovy.util; 35 36 import groovy.lang.GroovyObjectSupport; 37 import groovy.lang.MissingMethodException; 38 import org.codehaus.groovy.runtime.InvokerHelper; 39 40 48 public class Proxy extends GroovyObjectSupport { 49 50 private Object adaptee = null; 51 52 57 public Proxy wrap(Object adaptee){ 58 setAdaptee(adaptee); 59 return this; 60 } 61 62 public Object getAdaptee() { 63 return adaptee; 64 } 65 66 public void setAdaptee(Object adaptee) { 67 this.adaptee = adaptee; 68 } 69 70 public Object invokeMethod(String name, Object args) { 71 try { 72 return super.invokeMethod(name, args); 73 } 74 catch (MissingMethodException e) { 75 return InvokerHelper.getMetaClass(adaptee).invokeMethod(adaptee, name, args); 76 } 77 } 78 79 } 80 | Popular Tags |