Kirk Rader  1.0-SNAPSHOT
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
us.rader.logging.tracing.Trace Class Referenceabstract

Inject tracing output into all constructors and methods. More...

Inheritance diagram for us.rader.logging.tracing.Trace:
Inheritance graph

Public Member Functions

final void afterConstructor (final JoinPoint thisJoinPoint)
 Insert tracing after each constructor invocation. More...
 
final void afterFieldGet (final JoinPoint thisJoinPoint, final Object value)
 Insert tracing around each field get access. More...
 
final void afterFieldSet (final JoinPoint thisJoinPoint, final Object newValue)
 Insert tracing after each field set access. More...
 
final void afterMethod (final JoinPoint thisJoinPoint, final Object value)
 Insert tracing after each method invocation. More...
 
final void beforeConstructor (final JoinPoint thisJoinPoint)
 Insert tracing before each constructor invocation. More...
 
final void beforeMethod (final JoinPoint thisJoinPoint)
 Insert tracing before each method invocation. More...
 

Protected Member Functions

abstract void pointcutClasses ()
 Select all Java classes except this Trace aspect. More...
 
void traceExecution (final JoinPoint joinPoint, final String formatString, final Object... formatArguments)
 Trace program progress. More...
 

Private Member Functions

void pointcutConstructors ()
 Select all the constructors for the selected classes. More...
 
void pointcutFieldGet ()
 Select all field "get" accesses. More...
 
void pointcutFieldSet ()
 Select all field "set" accesses. More...
 
void pointcutMethods ()
 Select all the methods for the selected classes. More...
 

Detailed Description

Inject tracing output into all constructors and methods.

Definition at line 43 of file Trace.java.

Member Function Documentation

◆ afterConstructor()

final void us.rader.logging.tracing.Trace.afterConstructor ( final JoinPoint  thisJoinPoint)

Insert tracing after each constructor invocation.

Parameters
thisJoinPointThe JoinPoint.

Definition at line 52 of file Trace.java.

References us.rader.logging.tracing.Trace.traceExecution().

52  {
53 
54  traceExecution(thisJoinPoint, "constructed");
55 
56  }
void traceExecution(final JoinPoint joinPoint, final String formatString, final Object... formatArguments)
Trace program progress.
Definition: Trace.java:190

◆ afterFieldGet()

final void us.rader.logging.tracing.Trace.afterFieldGet ( final JoinPoint  thisJoinPoint,
final Object  value 
)

Insert tracing around each field get access.

Parameters
thisJoinPointThe JoinPoint
valueThe value returned

Definition at line 68 of file Trace.java.

References us.rader.logging.tracing.Trace.traceExecution().

68  {
69 
70  traceExecution(thisJoinPoint, "got {0}", value);
71 
72  }
void traceExecution(final JoinPoint joinPoint, final String formatString, final Object... formatArguments)
Trace program progress.
Definition: Trace.java:190

◆ afterFieldSet()

final void us.rader.logging.tracing.Trace.afterFieldSet ( final JoinPoint  thisJoinPoint,
final Object  newValue 
)

Insert tracing after each field set access.

Parameters
thisJoinPointThe JoinPoint
newValueThe new value for the field.

Definition at line 84 of file Trace.java.

References us.rader.logging.tracing.Trace.traceExecution().

84  {
85 
86  traceExecution(thisJoinPoint, "set to {0}", newValue);
87 
88  }
void traceExecution(final JoinPoint joinPoint, final String formatString, final Object... formatArguments)
Trace program progress.
Definition: Trace.java:190

◆ afterMethod()

final void us.rader.logging.tracing.Trace.afterMethod ( final JoinPoint  thisJoinPoint,
final Object  value 
)

Insert tracing after each method invocation.

Parameters
thisJoinPointThe JoinPoint
valueThe method's return value

Definition at line 100 of file Trace.java.

References us.rader.logging.tracing.Trace.traceExecution().

100  {
101 
102  traceExecution(thisJoinPoint, "returning {0}", value);
103 
104  }
void traceExecution(final JoinPoint joinPoint, final String formatString, final Object... formatArguments)
Trace program progress.
Definition: Trace.java:190

◆ beforeConstructor()

final void us.rader.logging.tracing.Trace.beforeConstructor ( final JoinPoint  thisJoinPoint)

Insert tracing before each constructor invocation.

Parameters
thisJoinPointThe JoinPoint

Definition at line 113 of file Trace.java.

References us.rader.logging.tracing.Trace.traceExecution().

113  {
114 
115  traceExecution(thisJoinPoint, "constructing");
116 
117  }
void traceExecution(final JoinPoint joinPoint, final String formatString, final Object... formatArguments)
Trace program progress.
Definition: Trace.java:190

◆ beforeMethod()

final void us.rader.logging.tracing.Trace.beforeMethod ( final JoinPoint  thisJoinPoint)

Insert tracing before each method invocation.

Parameters
thisJoinPointThe JoinPoint.

Definition at line 126 of file Trace.java.

References us.rader.logging.tracing.Trace.traceExecution().

126  {
127 
128  traceExecution(thisJoinPoint, "entering");
129 
130  }
void traceExecution(final JoinPoint joinPoint, final String formatString, final Object... formatArguments)
Trace program progress.
Definition: Trace.java:190

◆ pointcutClasses()

abstract void us.rader.logging.tracing.Trace.pointcutClasses ( )
abstractprotected

Select all Java classes except this Trace aspect.

Referenced by us.rader.logging.tracing.Trace.pointcutMethods().

◆ pointcutConstructors()

void us.rader.logging.tracing.Trace.pointcutConstructors ( )
private

Select all the constructors for the selected classes.

Definition at line 136 of file Trace.java.

136  { // NOSONAR
137 
138  // nothing to do here
139 
140  }

◆ pointcutFieldGet()

void us.rader.logging.tracing.Trace.pointcutFieldGet ( )
private

Select all field "get" accesses.

Definition at line 146 of file Trace.java.

146  { // NOSONAR
147 
148  // nothing to do here
149 
150  }

◆ pointcutFieldSet()

void us.rader.logging.tracing.Trace.pointcutFieldSet ( )
private

Select all field "set" accesses.

Definition at line 156 of file Trace.java.

156  { // NOSONAR
157 
158  // nothing to do here
159 
160  }

◆ pointcutMethods()

void us.rader.logging.tracing.Trace.pointcutMethods ( )
private

Select all the methods for the selected classes.

Definition at line 166 of file Trace.java.

References us.rader.logging.tracing.Trace.pointcutClasses().

166  { // NOSONAR
167 
168  // nothing to do here
169 
170  }

◆ traceExecution()

void us.rader.logging.tracing.Trace.traceExecution ( final JoinPoint  joinPoint,
final String  formatString,
final Object...  formatArguments 
)
protected

Trace program progress.

Parameters
joinPointThe JoinPoint.
formatStringMessageFormat.format() string
formatArgumentsMessageFormat.format() arguments

Definition at line 190 of file Trace.java.

Referenced by us.rader.logging.tracing.Trace.afterConstructor(), us.rader.logging.tracing.Trace.afterFieldGet(), us.rader.logging.tracing.Trace.afterFieldSet(), us.rader.logging.tracing.Trace.afterMethod(), us.rader.logging.tracing.Trace.beforeConstructor(), and us.rader.logging.tracing.Trace.beforeMethod().

191  {
192 
193  final Signature signature = joinPoint.getSignature();
194  final Logger logger = LoggerFactory.getLogger(signature.getDeclaringType());
195 
196  if (logger.isTraceEnabled()) {
197 
198  final String message = MessageFormat.format(formatString, formatArguments);
199  logger.trace("{} {}", signature.toLongString(), message);
200 
201  }
202  }

The documentation for this class was generated from the following file: