org.perf4j.aop
Class AgnosticTimingAspect

java.lang.Object
  extended by org.perf4j.aop.AgnosticTimingAspect
Direct Known Subclasses:
AbstractEjbTimingAspect, AbstractTimingAspect

public class AgnosticTimingAspect
extends Object

This AgnosticTimingAspect class contains all the logic for executing a profiled method with appropriate timing calls, but in an AOP-framework-agnostic way. You may choose to either extend or wrap this class to create an aspect in your desired framework. For example, if you look at the AbstractTimingAspect, you can see that it delegates all functionality to this class - it just includes the necessary AspectJ annotations and wraps the AspectJ-specific ProceedingJoinPoint as an AbstractJoinPoint.

Author:
Marcin ZajƒÖczkowski, Alex Devine

Constructor Summary
AgnosticTimingAspect()
           
 
Method Summary
protected  String evaluateJexl(String text, Object[] args, Object annotatedObject, Object returnValue, Throwable exceptionThrown)
          Helper method is used to parse out {expressionLanguage} elements from the text and evaluate the strings using JEXL.
protected  org.apache.commons.jexl.Expression getJexlExpression(String expressionText)
          Helper method gets a compiled JEXL expression for the specified expression text, either from the cache or by creating a new compiled expression.
protected  String getStopWatchMessage(Profiled profiled, AbstractJoinPoint joinPoint, Object returnValue, Throwable exceptionThrown)
          Helper method get the message to use for StopWatch logging.
protected  String getStopWatchTag(Profiled profiled, AbstractJoinPoint joinPoint, Object returnValue, Throwable exceptionThrown)
          Helper method gets the tag to use for StopWatch logging.
 Object runProfiledMethod(AbstractJoinPoint joinPoint, Profiled profiled, LoggingStopWatch stopWatch)
          This method actually executes the profiled method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgnosticTimingAspect

public AgnosticTimingAspect()
Method Detail

runProfiledMethod

public Object runProfiledMethod(AbstractJoinPoint joinPoint,
                                Profiled profiled,
                                LoggingStopWatch stopWatch)
                         throws Throwable
This method actually executes the profiled method. Your AOP-framework-specific class should delegate to this method to proceed with execution.

Parameters:
joinPoint - The AOP join point - usually this will just be a simple wrapper around the AOP-framework-specific join point.
profiled - The Profiled annotation that was set on the method being profiled.
stopWatch - This LogginStopWatch should be started JUST before this method is called.
Returns:
The return value from the profiled method.
Throws:
Throwable - Exception thrown by the profiled method will bubble up.

getStopWatchTag

protected String getStopWatchTag(Profiled profiled,
                                 AbstractJoinPoint joinPoint,
                                 Object returnValue,
                                 Throwable exceptionThrown)
Helper method gets the tag to use for StopWatch logging. Performs JEXL evaluation if necessary.

Parameters:
profiled - The profiled annotation that was attached to the method.
joinPoint - The AbstractJoinPoint encapulates the method around which this aspect advice runs.
returnValue - The value returned from the execution of the profiled method, or null if the method returned void or an exception was thrown.
exceptionThrown - The exception thrown, if any, by the profiled method. Will be null if the method completed normally.
Returns:
The value to use as the StopWatch tag.

getStopWatchMessage

protected String getStopWatchMessage(Profiled profiled,
                                     AbstractJoinPoint joinPoint,
                                     Object returnValue,
                                     Throwable exceptionThrown)
Helper method get the message to use for StopWatch logging. Performs JEXL evaluation if necessary.

Parameters:
profiled - The profiled annotation that was attached to the method.
joinPoint - The AbstractJoinPoint encapulates the method around which this aspect advice runs.
returnValue - The value returned from the execution of the profiled method, or null if the method returned void or an exception was thrown.
exceptionThrown - The exception thrown, if any, by the profiled method. Will be null if the method completed normally.
Returns:
The value to use as the StopWatch message.

evaluateJexl

protected String evaluateJexl(String text,
                              Object[] args,
                              Object annotatedObject,
                              Object returnValue,
                              Throwable exceptionThrown)
Helper method is used to parse out {expressionLanguage} elements from the text and evaluate the strings using JEXL.

Parameters:
text - The text to be parsed.
args - The args that were passed to the method to be profiled.
annotatedObject - The value of the object whose method was profiled. Will be null if a class method was profiled.
returnValue - The value returned from the execution of the profiled method, or null if the method returned void or an exception was thrown.
exceptionThrown - The exception thrown, if any, by the profiled method. Will be null if the method completed normally.
Returns:
The evaluated string.
See Also:
Profiled.el()

getJexlExpression

protected org.apache.commons.jexl.Expression getJexlExpression(String expressionText)
                                                        throws Exception
Helper method gets a compiled JEXL expression for the specified expression text, either from the cache or by creating a new compiled expression.

Parameters:
expressionText - The JEXL expression text
Returns:
A compiled JEXL expression representing the expression text
Throws:
Exception - Thrown if there was an error compiling the expression text


Copyright © 2008-2011 perf4j.org. All Rights Reserved.