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,
- Before the API method called
- Around the API method called
- 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,
- Store the accessLocation information as a personAttribute automatically.
- Wrap the saveUser() method in the personService class using AOP techniques to achieve this task.
Progress of the Project is given below,