How to make a method be called passive before invoke a method

前端 未结 2 731
暗喜
暗喜 2021-01-14 00:11

Like so : a class has a method called sayHello() . When a instance of the class call the sayHello(), a method in another class is called automatic before the sayHello() is

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-14 01:12

    I think you are looking for an aspect-oriented programming framework such as AspectJ, JBoss AOP or Spring AOP.

    The decoration of the Person method by the Robot method will happen during construction of the Person instance, but you will need to use a factory class provided by the AOP container instead of new.

提交回复
热议问题