Aspect Oriented Programming (AOP)

Week 2[May 22, 2018 — May 28, 2018]

This is the second week of the Google Summer of Code 2018, I am still working with my mentor to finalize the project design. This week, I totally played with Aspect Oriented Programming with OpenMRS.

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.

http://www.baeldung.com/spring-aop

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

I worked with my mentor to improve this part to support the access Location selection while registering the patients or users. Hope I can complete that part with in this week :-)