cflowPointcutDef.setType(PointcutType.CFLOW);
cflowPointcutDef.setExpression(value.getExpression());
}
// create call pointcut
CallPointcut pointcut = new CallPointcut(uuid, value);
// register the cflow advices in the system and create the cflow system aspect
// (if it does not already exist)
if (!SystemLoader.getSystem(uuid).getAspectManager().hasAspect(CFlowSystemAspect.NAME)) {
AspectDefinition cflowAspect = new AspectDefinition(
CFlowSystemAspect.NAME,
CFlowSystemAspect.CLASS_NAME,
CFlowSystemAspect.DEPLOYMENT_MODEL
);
cflowAspect.addPointcut(cflowPointcutDef);
Class cflowAspectClass = CFlowSystemAspect.class;
try {
// add the cflow pre advice
cflowAspect.addBeforeAdvice(
new AdviceDefinition(
CFlowSystemAspect.PRE_ADVICE,
cflowAspect.getName(),
cflowAspect.getClassName(),
value,
cflowAspectClass.getDeclaredMethod(
CFlowSystemAspect.PRE_ADVICE,
new Class[]{JoinPoint.class}
),
CFlowSystemAspect.PRE_ADVICE_INDEX,
cflowAspect
)
);
// add the cflow post advice
cflowAspect.addAfterAdvice(
new AdviceDefinition(
CFlowSystemAspect.POST_ADVICE,
cflowAspect.getName(),
cflowAspect.getClassName(),
value,
cflowAspectClass.getDeclaredMethod(
CFlowSystemAspect.POST_ADVICE,
new Class[]{JoinPoint.class}
),
CFlowSystemAspect.POST_ADVICE_INDEX,
cflowAspect
)
);
}
catch (NoSuchMethodException e) {
;
}
// add the advice to the aspectwerkz definition
definition.addAspect(cflowAspect);
// add the advice to the aspectwerkz system
registerAspect(uuid, cflowAspect, new HashMap());
}
// add the pointcut definition to the method pointcut
pointcut.addPointcutDef(cflowPointcutDef);
// add references to the cflow advices to the cflow pointcut
pointcut.addBeforeAdvice(CFlowSystemAspect.PRE_ADVICE);
pointcut.addAfterAdvice(CFlowSystemAspect.POST_ADVICE);
// add the method pointcut
aspect.addCallPointcut(pointcut);