Human Resources Example - Create the POJO
Procedure 5.1. Creating the POJO The constructor checks for the presence of a log directory in the current working directory, and creates one if not found. Next, an advice is defined. This advice is called whenever the constructor of the target class is called. This creates a new log file within the log directory to record method calls made on different instances of the target class in separate files. Finally, another advice is defined. This advice applies to each method call made on the target class.The method name and arguments are stored, along with the return value. This information is used to construct an audit record and write it to the current log file. Each advice calls inv.invokeNext(), which chains the advices together if more than one cross-cutting concern has been applied, or to call the target constructor/method. Note Each advice is implemented using a method that takes an invocation object as a parameter, throws Throwable and returns Object. At design time you don't know which constructors or methods these advices will be applied to, so make the types as generic as possible. To compile the class and create an auditAspect.jar file that can be used by other examples, type mvn install from the auditAspect directory.