Aspect Oriented Programming

Cross Cutting Concerns

  • Things which are not part of your problem but still are required, maybe because of security, infrastructure etc.
  • They are required in a lot of objects but are not really part of your business logic
  • Examples:
    • Logging
    • Transactions
    • Security

Steps in AOP

  • Identify cross cutting concerns and write Aspects
  • Configure where the aspects apply
    • example: enable logging for some methods

AOP Annotations

  • @Aspect (Class Level)
  • Advice (Method Level):
    • @Before
    • @After
    • @Around

How AOP works

  • It uses Proxy design pattern internally

What is AspectJ??