Call a method any time other methods are called

后端 未结 5 501
傲寒
傲寒 2021-01-04 11:19

Is there any way to make a sort of \"supermethod\" that is called every time a method is called, even for non-defined methods? Sort of like this:

public void         


        
5条回答
  •  滥情空心
    2021-01-04 11:48

    The Term behind this concept is called interceptor. You need a container that does this like a ApplicationServer, CDI Container, Spring or AOP. It works like this

    1. call your Method
    2. pause your Method
    3. call intercepter
    4. do interceptor stuff
    5. resume your Method inside the interceptor
    

提交回复
热议问题