JBoss.org Community Documentation

3.10.2. Context Values

According to the type of the joinpoint, there are specific context values available.

The context values are:

  • return value: joinpoints like a constructor execution or a non-void method call, have a return value.
  • arguments: the arguments of a constructor or method execution joinpoint are the arguments received by the constructor or method. Similarly, the arguments of a call are the arguments received by the method or constructor being called.
  • target: the target object of a joinpoint varies according to the joinpoint type. For method executions and calls, it refers to the object whose method is being executed (available only on non-static methods). For field reads and writes, it refers to the object that contains that field.
  • caller: the caller object is available only on call joinpoints, and it refers to the object whose method or constructor is performing the call (notice the caller object is not available if the call is inside a static method).

Table 3.1, “ Joinpoint Types Table ” shows what context values may be available depending on the joinpoint type.

Joinpoint Pointcut Construct Bean ContextValues
Invocation JoinpointBean Target Caller Arguments Return Value
field read read, field, all FieldReadInvocation FieldAccess Yes No No Yes
field write write, field, all FieldWriteInvocation FieldAccess Yes No Yes No
method execution execution, all MethodInvocation MethodExecution Yes No Yes Yes
constructor execution execution ConstructorInvocation ConstructorExecution No No Yes Yes
construction construction ConstructionInvocation ConstructorExecution Yes No Yes No
method call call, within, withincode CallerInvocation, MethodCalledByConstructorInvocation, MethodCalledByMethodInvocation MethodCall, MethodCallByConstructor, MethodCallByMethod Yes Yes Yes Yes
constructor call call, within, withincode CallerInvocation, ConstructorCalledByConstructorInvocation, ConstructorCalledByMethodInvocation ConstructorCall, ConstructorCallByConstructor, ConstructorCallByMethod Yes Yes Yes Yes
The first column shows the joinpoint type. The second column shows which pointcut constructs can identify a joinpoint of that type. has and hasfield are additional constructs, and therefore are not shown in this table. The third column shows the specific type of joinpoint bean class that is used to represent that joinpoint. This column is split into two: one for the Invocation beans, the other one for the JoinPointBean ones. The fourth column is composed of four subcolumns, and it shows the context values avaialble for each joinpoint type. Notice that, on some of these values, there are additional restrictions for their availability. Like, for example, there is no target on a static method execution.

Table 3.1.  Joinpoint Types Table