final AspectWerkzDefinitionImpl definition,
final String className,
final QDoxParser qdoxParser) {
String pointcutName = METHOD_POINTCUT_NAME + Strings.replaceSubString(className, ".", "_");
AspectDefinition aspectDef = definition.getAspectDefinition(AspectWerkzDefinition.SYSTEM_ASPECT);
int counter = 0;
final JavaMethod[] javaMethods = qdoxParser.getJavaMethods();
for (int i = 0; i < javaMethods.length; i++) {
DocletTag[] methodTags = javaMethods[i].getTagsByName(AttributeTag.METHOD);
for (int j = 0; j < methodTags.length; j++) {
if (methodTags[j] == null) {
continue;
}
String cflowRef = methodTags[j].getNamedParameter("cflow");
String isNonReentrant = methodTags[j].getNamedParameter("non-reentrant");
String[] attributes = methodTags[j].getParameters();
for (int k = 0; k < attributes.length; k++) {
String attribute = attributes[k];
if (attribute.startsWith("cflow=") || attribute.startsWith("non-reentrant=")) {
continue;
}
for (Iterator it2 = definition.getAdviceDefinitions().iterator(); it2.hasNext();) {
String expression = pointcutName + counter;
// create and add a new pointcut def
PointcutDefinition pointcutDef = new PointcutDefinition();
pointcutDef.setName(pointcutName);
pointcutDef.setExpression(expression);
pointcutDef.setType(PointcutType.EXECUTION);
pointcutDef.setNonReentrant(isNonReentrant);
aspectDef.addPointcutDef(pointcutDef);
String adviceAttribute = ((AdviceDefinition)it2.next()).getAttribute();
if (adviceAttribute == null) {
continue;
}
if (adviceAttribute.equals(attribute)) {
// get the advice ref
String adviceRef = definition.getAdviceNameByAttribute(adviceAttribute);
if (adviceRef == null) {
// TODO: log a warning
continue; // attribute not mapped to an advice
}
// create and add a new rule
BindAdviceRule bindAdviceRule = new BindAdviceRule();
bindAdviceRule.setExpression(
Expression.createExecutionExpression(
aspectDef.getName(),
expression,
"",
pointcutName
));
// TODO: how to handle cflow?
// bindAdviceRule.setCFlowExpression(cflowRef);
bindAdviceRule.addAdviceRef(adviceRef);
aspectDef.addBindAdviceRule(bindAdviceRule);
counter++;
break;
}
}