* @param aspectDef the aspect definition
*/
private static void handlePointcutDefinitions(final Element aspectElement,
final AspectDefinition aspectDef) {
for (Iterator it2 = aspectDef.getPointcutDefs().iterator(); it2.hasNext();) {
PointcutDefinition pointcutDef = (PointcutDefinition)it2.next();
Element pointcutDefElement = aspectElement.addElement("pointcut-def");
pointcutDefElement.addAttribute("name", pointcutDef.getName());
pointcutDefElement.addAttribute("type", pointcutDef.getType());
pointcutDefElement.addAttribute("non-reentrant", pointcutDef.getNonReentrant());
StringBuffer fullPattern = new StringBuffer();
String type = pointcutDef.getType();
if (type.equalsIgnoreCase(PointcutDefinition.METHOD) ||
type.equalsIgnoreCase(PointcutDefinition.GET_FIELD) ||
type.equalsIgnoreCase(PointcutDefinition.SET_FIELD)) {
String classPattern = pointcutDef.getClassPattern();
String pattern = pointcutDef.getPattern();
int space = pattern.indexOf(' ');
String returnType = pattern.substring(0, space + 1);
String methodName = pattern.substring(space + 1);
fullPattern.append(returnType);
fullPattern.append(classPattern);
if (pointcutDef.isHierarchical()) {
fullPattern.append('+');
}
fullPattern.append('.');
fullPattern.append(methodName);
}
else if (type.equalsIgnoreCase(PointcutDefinition.THROWS)) {
String classPattern = pointcutDef.getClassPattern();
String pattern = pointcutDef.getPattern();
int delimiter = pattern.indexOf('#');
String methodPattern = pattern.substring(0, delimiter);
String exception = pattern.substring(delimiter + 1);
int space = methodPattern.indexOf(' ');
String returnType = methodPattern.substring(0, space + 1);
String methodName = methodPattern.substring(space + 1);
fullPattern.append(returnType);
fullPattern.append(classPattern);
fullPattern.append('.');
fullPattern.append(methodName);
fullPattern.append('#');
fullPattern.append(exception);
}
else if (type.equalsIgnoreCase(PointcutDefinition.CALLER_SIDE)) {
String callerClassPattern = pointcutDef.getClassPattern();
String pattern = pointcutDef.getPattern();
int delimiter = pattern.indexOf('#');
String calleeClassPattern = pattern.substring(0, delimiter);
String methodPattern = pattern.substring(delimiter + 1);
int space = methodPattern.indexOf(' ');
String returnType = methodPattern.substring(0, space + 1);
String methodName = methodPattern.substring(space + 1);
fullPattern.append(callerClassPattern);
fullPattern.append("->");
fullPattern.append(returnType);
fullPattern.append(calleeClassPattern);
fullPattern.append(".");
fullPattern.append(methodName);
;
}
else if (type.equals(PointcutDefinition.CFLOW)) {
String pattern = pointcutDef.getPattern();
int delimiter = pattern.indexOf('#');
String classPattern = pattern.substring(0, delimiter);
String methodPattern = pattern.substring(delimiter + 1);
int space = methodPattern.indexOf(' ');
String returnType = methodPattern.substring(0, space + 1);
String methodName = methodPattern.substring(space + 1);
fullPattern.append(returnType);
fullPattern.append(classPattern);
fullPattern.append(".");
fullPattern.append(methodName);
}
else {
throw new RuntimeException("invalid pointcut type: " + pointcutDef.getType());
}
pointcutDefElement.addAttribute("pattern", fullPattern.toString());
}
}