What are the possible AOP use cases?

前端 未结 11 2034
孤街浪徒
孤街浪徒 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:54
    • Read/write locks. Instead of replicating the same snippet, I used an aspect to define the methods that needed a read lock or an exclusive lock.
    0 讨论(0)
  • 2020-12-23 16:56

    Method level caching,if your method is stateless(I mean returns same value when invoked repeatedly with same parameter values). This is more effective in case of DAO methods because it avoids database hit.

    0 讨论(0)
  • 2020-12-23 16:56

    I will also recommend aspects for:

    • Async method calls
    • Monitoring

    With Spring and tcServer (developer), you can easily monitor all your Spring beans with @Component annotation. You can see time used, the input and return data including exceptions.

    0 讨论(0)
  • 2020-12-23 16:57

    To see the coverage of AOP in terms of applicability I really recommend you to read the book Aspect-Oriented-Software-Development-Use-Cases. This book elaborates use cases of functional and non-functional requirements using AOP. After that you will see that aspects can be used to more requirements than logging, tracing, security, etc.

    0 讨论(0)
  • 2020-12-23 16:57

    We use AspectJ to accomplish AOP. Use cases apart from the above mentioned ones are as follows:

    • Restricting access to method calls to only few classes.
    • Automatically annotating selected methods/classes/fields.
    0 讨论(0)
提交回复
热议问题