What are the possible AOP use cases?

前端 未结 11 2056
孤街浪徒
孤街浪徒 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

    • Exception Handling: don't need to repeat the horrible list of try ... catch, catch, catch etc - also means the exception handling is guaranteed to be consistent.
    • Performance monitoring: Very useful as using an aspect is non intrusive and can be done after the fact and then turned off when no longer required.

    Wow... 10 years ago - didn't have much for AOP... Here are a few more

    • Be able to customise objects where you don't have access to their constructor (e.g. jpa entities)
    • Implementing security rules (security says user is not allowed to call this method - AOP can implement that)
    • Transaction manager (begin, commit, rollback)
    • Caching - want to cache the result of a method and not call it again

提交回复
热议问题