1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| class LogHandler implements InvocationHandler { Tank tank;
public LogHandler(Tank tank) { this.tank = tank; } public void before(Method method){ System.out.println("Method:"+method.getName()+" start...."); } public void end(Method method){ System.out.println("Method:"+method.getName()+" end..."); } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { before(method); Object o = method.invoke(tank, args); end(method); return o;
} }
|