|
Helping ordinary people create extraordinary websites! |
Using Aspects to Autonomic-Enable Legacy ApplicationsBy Brian Temple2005-05-13
How to use and extend the example Aspect framework When examining the set of correlated logs for a particular software solution, it might be very useful to understand what exactly is being executed during points of interest. A point of interest in this case might be an application crash or inappropriately high usage of a CPU. The CommonTraceLogger Aspect implements most of the action events defined in CommonBase and simply invokes the CommonEventHandler helper class to generate Common Base Events. To make your application generate these Common Base Event trace events, simply create a concrete Aspect that subclasses CommonTraceLogger, as shown in Listing 6 and recompile the application. Listing 6. Concrete Aspect that subclasses CommonTraceLogger import com.ibm.developerworks.autonomicenablement.aspect.CommonTraceLogger;Another point of interest that might exist is simply what the original application used to log or debug. In the context of the example application, no logs are ever written; all information is simply printed to the screen using System.out. One way to capture this information is to create a subclass of the CommonWrappingLogger Aspect that inspects every PrintStream.print command, ensures it is the System.out PrintStream, and then generates a Common Base Event. The implementation of this is shown in Listing 7. Listing 7. Capturing System.out calls package com.ibm.developerworks.autonomicenablement.aspect;After this new Aspect has been created, simply create another concrete Aspect as shown in Listing 8 and recompile the application. Listing 8. Concrete Aspect that subclasses SystemOutWrappingLogger import com.ibm.developerworks.autonomicenablement.aspect.SystemOutWrappingLogger; Tutorial Pages: » Using Aspects to autonomic-enable legacy applications » Introduction » Example legacy application » Incorporating Aspects » An example Aspect framework to generate Common Base Events » How to use and extend the example Aspect framework » Next steps » Resources First published by IBM DeveloperWorks |
|