FastAOP framework: User guide

Unlike in AspectJ where pointcuts are defined as language constructs, in FastAOP a developer has to define pointcuts programmatically using a Pointcut builder pattern:

Pointcut.classPattern("javax.ejb.SessionBean+").
                .or("com.fastaop..*AbstractBean")
                .or("com.fastaop..*Bean*")
                .method("*").andNot("*SessionContext").andNot("create")
                .andNot("destroy").andNot("create").andNot("ejb*").compile();

This pointcut matches all methods in all classes implementing the 'javax.ejb.SessionBean' interface or in the ‘com.fastaop’ ending with 'AbstractBean' or 'Bean', but not the ejb live cycle methods like get-, setSessionContext (ending with SessionContext), destroy, create, ejb (stringWith). To see more pointcut examples read the Pointcut Guide

FastAOP was developed for performance monitoring. On our website you can find a framework called ‘Perfmon’ which is published as separate module in the fastAOP open source project.With Perfmon it is possible to map architectural layers of the architecture to classes (e.g. a DAO layer is mapped to PatientRecordDAO.class... end so on ) and define work-flows. A workflow in this case is simply a number of consecutive method calls starting with a defined entry method. Such workflow specification starts the report generation for all executions of methods occurring until the entry method is finished. Once this method is finished the report will be written to the file system. Perfmon generates automatically reports for all specified workflows and highlights the performance issues. Perfmon also generates high level reports like: 30% time is spent in the database layer, 10% in the UI for the workflow XY. If a layer is making calls to other layers, the time spent in these layers is automatically subtracted from the time for the caller. This behavior is very important to detect the performance.

Not subtracting the time spend in other layers the SessionBean call would seem very slow. In reality the call has to wait for the execution of Data Access Objects (DAO’s). Perfmon will in this example report that DAO2 is slow. If a class like a SessionBean is making calls to classes which are not part of any architectural layer (like helper classes) this calls are counted as part of the execution time of a SessionBean. This approach has the advantage to identify the performance is-sues on a course grained basis and use this results as input for further more focused analysis (e.g. using a profiler).

An architecture layer mapping to classes in can be defined as a fastAOP aspect (e.g. DAOPerf.java), which forwards the calls the central class of Perfmon-framework called Monitor:

@Aspect
public class DAOPerf extends AbstractAdvice {

private final Monitor monitor = 
new Monitor(Layer.DAO);

public void before(String clazz, String method, 
                   Object onObject) {
        monitor.before(clazz, method, onObject);
}

public void after(String clazz, String method, 
                  Object onObject) {
        monitor.after(clazz, method, onObject);

}

public Pointcut getPointcuts() {
        return Poincut.classPattern(
        "com.fastaop..*DAO")
        orClassPattern(
      "com.fastaop..*DAOImpl")
      .compile();
}}

The class DAOPerf is a concrete aspect which can be deployed in the deploy directory (inside a jar file). The aspect inter-cepts the start and end of all methods in the DAO layer. The class Monitor is the entry class for the Perfmon frame-work. A Monitor is instantiated with a layer definition (here a Java5 Enum, representing a DAO layer) and the aspect forwards all calls to this monitor instance. In this case, all calls on classes belonging to the DAO layer are forwarded to this monitor in-stance. If a method call is part of a Workflow, the Perfmon framework monitors the execution time of this method. Workflows are defines in a property file named ‘workflow-def.properties’ which has the following format:

workflow.1.name=Get Flowsheet
workflow.1.class=com.fastaop.TestBusinessDelegate
workflow.1.method=getFlowsheetConfiguration

In the example the report data collection is started when the method ‘getFlowsheetConfiguration’ is executed. After the method competes the report is written to the hard disk, as an Excel file named GetFlowsheet_mmddyyy.xsl. Using fastAOP and Perfmon we are able to continuously measure and report performance issues for all critical workflows and use these reports for further actions and optimization efforts. Using the load time approach provided by fastAOP, aspects are woven only in the performance testing environment and the productive application has no performance measurement aspects deployed.