What are the possible AOP use cases?

前端 未结 11 2036
孤街浪徒
孤街浪徒 2020-12-23 16:27

I\'d like to make a picture of what are the possible cases for effective involvement of AOP in application design. All I have met so far is:

  • logging-related
11条回答
  •  感情败类
    2020-12-23 16:44

    I can give you two examples where we use it:

    • Automatically registering objects in JMX for remote management. If a class is annotated with our @AutoRegister annotation, we have an aspect that watches for new instantiations of that class and registers them in JMX automatically.

    • Audit logging (the gold standard AOP use case). Its a bit coarse but the general approach is to annotate methods that represent some auditable action. Combined with something like Spring Security, we can get a pretty good idea of:

      • who the user is
      • what method they're invoking
      • what data they're providing
      • what time the method was invoked
      • whether the invocation was successful or not (i.e., if an exception was thrown)

提交回复
热议问题