JBoss.org Community Documentation
To create a CFlow stack, you annotate a field with
@CFlowDef
in a class anotated with
@Aspect
or
@InterceptorDef
.
The declaration of
org.jboss.aop.CFlowStackDef
is:
package org.jboss.aop; @Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface CFlowStackDef { CFlowDef[] cflows(); }
In turn the declaration of
org.jboss.aop.CFlowDef
is:
package org.jboss.aop; public @interface CFlowDef { boolean called(); String expr(); }
The parameters of
@CFlowDef
are:
called
, whether the corresponding expr should appear
in the stack trace or not.
expr
, a string matching stack a trace element
The name of the CFlowStackDef used for reference and internally is:
<name of @Aspect/@InterceptorDef annotated class>.<name of @CFlowStackDef annotated field>
CFlowStackDef is used like the following example:
package com.mypackage; import org.jboss.aop.CFlowStackDef; import org.jboss.aop.pointcut.CFlowStack; @Aspect (scope=org.jboss.aop.advice.Scope.PER_VM) public class CFlowAspect { @CFlowStackDef (cflows={@CFlowDef(expr= "void com.blah.POJO->cflowMethod1()", \ called=false), @CFlowDef(expr = "void com.blah.POJO->cflowMethod2()", \ called=true)}) public static CFlowStack cfNot1And2Stack; @Bind (pointcut="execution(void com.blah.POJO*->privMethod())", \ cflow="com.mypackage.CFlowAspect.cfNot1And2Stack") public Object cflowAdvice(Invocation invocation) throws Throwable { return invocation.invokeNext(); } }
The above means the same as this XML:
<aop> <cflow-stack name="com.mypackage.CFlowAspect.cfNot1And2Stack"> <called expr="void com.blah.POJO->cflowMethod1()"/> <not-called expr="void com.blah.POJO->cflowMethod2()"/> </cflow-stack> </aop>