1 16 package net.sf.cglib.proxysample; 17 18 import java.lang.reflect.InvocationHandler ; 19 import java.lang.reflect.UndeclaredThrowableException ; 20 21 public final class ProxySample implements ProxySampleInterface_ReturnsObject, ProxySampleInterface_ReturnsBasic { 22 23 private InvocationHandler handler = null; 24 25 protected ProxySample(InvocationHandler handler) { 26 this.handler = handler; 27 } 28 29 public String getKala(String kalamees) throws Exception { 30 String result = null; 31 try { 32 result = (String ) handler.invoke(this, ProxySampleInterface_ReturnsObject.class.getMethod("getKala", new Class [] {String .class}), new Object [] {kalamees}); 34 } catch (ClassCastException e) { 35 throw e; 36 } catch (NoSuchMethodException e) { 37 throw new Error (e.getMessage()); 38 } catch (RuntimeException e) { 39 throw e; 40 } catch (Exception e) { 41 throw e; 43 } catch (Error e) { 44 throw e; 45 } catch (Throwable e) { 46 throw new UndeclaredThrowableException (e); 47 } 48 return result; 49 } 50 51 public int getKala(float kalamees) { 52 Integer result = null; 53 try { 54 result = (Integer ) handler.invoke(this, ProxySampleInterface_ReturnsBasic.class.getMethod("getKala", new Class [] {Float.TYPE}), new Object [] {new Float (kalamees)}); 56 } catch (ClassCastException e) { 57 throw e; 58 } catch (NoSuchMethodException e) { 59 } catch (RuntimeException e) { 61 throw e; 62 } catch (Error e) { 63 throw e; 64 } catch (Throwable e) { 65 throw new UndeclaredThrowableException (e); 66 } 67 return result.intValue(); 68 } 69 70 73 public String toString() { 74 String result = null; 75 try { 76 result = (String ) handler.invoke(this, Object .class.getMethod("toString", null), null); 78 } catch (ClassCastException e) { 79 throw e; 80 } catch (NoSuchMethodException e) { 81 } catch (RuntimeException e) { 83 throw e; 84 } catch (Error e) { 85 throw e; 86 } catch (Throwable e) { 87 throw new UndeclaredThrowableException (e); 88 } 89 return result; 90 } 91 92 } 93 | Popular Tags |