6.4. Writing a Complex Plug-in: The LogifierNow that you have written your first simple plug-in, try to write another plug-in, but this time you'll aim for something a bit more complex and useful. You are going to develop a plug-in that applies a Logging Aspect, which is defined using the AspectJ Aspect-Oriented Programming (AOP) implementation (http://www.eclipse.org/aspectj/) to any Maven project. This is a plug-in that will prove useful whenever you wish to automatically add debugging information to a Maven project's JAR. Once you've created this Logifier plug-in, you can modify it to do fancier Aspect-oriented magic, such as verifying that best practices are applied, writing a simple profiling tool, generating sequence diagrams automatically, benchmarking, etc. 6.4.1. How do I do that?The user of the Logifier plug-in is any Maven project that generates a JAR and wishes to add logging statements around all public methods. You'll create a plug-in with the logifier:logify goal, which will apply a Logging Aspect to the project's Java .class files. The Logging Aspect will instrument the Maven project's Java .class files, adding debug calls around all public methods. The Logifier will generate a "logified" JAR containing this instrumented code, and whenever the "logified" JAR is executed, the debugging information added by the Logging Aspect will appear on the console. Figure 6-3 illustrates the Logifier plug-in and the process which you will use to "logify" a project's JAR file. Figure 6-3. Architecture of the Logifier plug-in![]() To write the Logifier, you will need to complete the next few labs, which cover the following topics:
Let's get started! |