Aspect-Oriented Programming (AOP)

What is AOP?

“Aspect-oriented programming (AOP) is an approach to programming that allows global properties of a program to determine how it is compiled into an executable program. AOP is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns. It will mainly help for cross-cutting programming concerns. Typically, AOP techniques are used for logging, authorization, and authentication tasks.”

AOP with OpenMRS

OpenMRS uses AOP mainly for the module system to allow the core API (Services) to be extended in an infinite number of ways. Instead of only providing hooks at certain points in the code for specific uses, every service method within the API can be wrapped by a method in a module. Module services can be extended via AOP as well. There are three ways to wrap an API method in the OpenMRS,

  1. Before the API method called
  2. Around the API method called
  3. After the API method called
How I planned to use AOP in my project?

Actually, I need to store the accessLocation information for each user while they registering to the system. Since I am implementing this as a new module, I need to use the AOP techniques to wrap the OpenMRS core services.
The current plan for this implementation is,

  1. Store the accessLocation information as a personAttribute automatically.
  2. Wrap the saveUser() method in the personService class using AOP techniques to achieve this task.

Progress of the Project is given below,

  • Initial project structure was created and merged with the code repository.
  • Implemented the plan using the AOP techniques to wrap the saveUser method in the personService class to store the accessLocation person attribute automatically

Leave a Reply

Your email address will not be published. Required fields are marked *