Hi, everyone.
I want to add a listener on an invoked method by calling like this :
myClass.myMethod(...);
In runtime, it will be something like :
listenerClass.beforeMethod(...);
myClass.myMethod(...);
listenerClass.beforeMethod(...);
I wanted to override Method.invoke(...)
:
public Object invoke(Object obj, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
doBefore(...);
super.invoke(...);
doAfter(...);
}
Class.java and Method.java are final and I tried with my own ClassLoader.
Perhaps a factory or annotation can do the work.
Thanks for your answer.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…