How it works...

The aspect class ManageNullsDao consists of two @Around advices which intercept the execution of getEmployees() and getEmployee() of EmployeeDaoImpl. It is not because of its before and after execution why this recipe chose @Around as the appropriate advice, but its capability to extract the return value of the adviced method. The @Around advice has an optional parameter, ProceedingJoinPoint, that controls the execution of the adviced method through its proceed() method. Calling proceed() is equivalent to executing getEmployees(), which will return a generic type Object. After the object has been retrieved, validation of whether it is null happens. Whatever the result of the validation is, the advice method aims to replace all null values so that any component executing getEmployes() or getEmployee() can avoid runtime exceptions.

The preceding diagram shows how @Around wraps the adviced method and provides some implementation before and after the adviced method is executed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.181.57