final AspectWerkzDefinition definition) {
// get all aspects definitions
for (Iterator it1 = definition.getAspectDefinitions().iterator(); it1.hasNext();) {
AspectDefinition aspectDefinition = (AspectDefinition)it1.next();
Aspect aspect = AspectWerkz.getSystem(uuid).getAspect(aspectDefinition.getName());
try {
// get all advice weaving rules defined in this aspect
List adviceWeavingRules = aspectDefinition.getAdviceWeavingRules();
for (Iterator it2 = adviceWeavingRules.iterator(); it2.hasNext();) {
AdviceWeavingRule weavingRule = (AdviceWeavingRule)it2.next();
String cflowExpression = weavingRule.getCFlowExpression();
if (cflowExpression == null) {
continue;
}
// get the referenced cflow poincut definition
PointcutDefinition cflowPointcutDef =
aspectDefinition.getPointcutDef(cflowExpression);
// create caller side pointcut
CallerSidePointcut callerSidePointcut =
new CallerSidePointcut(uuid, cflowExpression);
if (!(cflowPointcutDef != null && cflowPointcutDef.getType().
equalsIgnoreCase(PointcutDefinition.CFLOW))) {
continue;
}
// register the cflow advices in the system (if they does not already exist)
if (!AspectWerkz.getSystem(uuid).hasAspect(CFlowPreAdvice.NAME)) {
AdviceDefinition adviceDef = CFlowPreAdvice.getDefinition();
// add the advice to the aspectwerkz definition
definition.addAdvice(adviceDef);
// add the advice to the aspectwerkz system
registerAdvice(uuid, adviceDef);
}
if (!AspectWerkz.getSystem(uuid).hasAspect(CFlowPostAdvice.NAME)) {
AdviceDefinition adviceDef = CFlowPostAdvice.getDefinition();
// add the advice to the aspectwerkz definition
definition.addAdvice(adviceDef);
// add the advice to the aspectwerkz system
registerAdvice(uuid, adviceDef);
}
// add the pointcut definition to the method pointcut
callerSidePointcut.addPointcutDef(cflowPointcutDef);
// add references to the cflow advices to the cflow pointcut
callerSidePointcut.addPreAdvice(CFlowPreAdvice.NAME);
callerSidePointcut.addPostAdvice(CFlowPostAdvice.NAME);
// add the method pointcut
aspect.addCallerSidePointcut(callerSidePointcut);
// add a mapping between the cflow pattern and the method patterns affected
for (Iterator it3 = weavingRule.getPointcutRefs().iterator(); it3.hasNext();) {
PointcutDefinition pointcutDef =
aspectDefinition.getPointcutDef((String)it3.next());
if (pointcutDef != null && pointcutDef.getType().
equalsIgnoreCase(PointcutDefinition.METHOD)) {
aspect.addMethodToCFlowMethodMap(
pointcutDef.getPointcutPatternTuple(),
cflowPointcutDef.getPointcutPatternTuple());
}
}
}
}
catch (NullPointerException e) {
throw new DefinitionException("method pointcuts in aspect <" + aspect.getName() + "> are not properly defined");
}
catch (Exception e) {
throw new WrappedRuntimeException(e);
}
}