aspect FileObserver {
private int opened = 0;
private int closed = 0;
pointcut doMethod(): execution(* *(..));
before(): doMethod(){
String result = "";
Object[] params = thisJoinPoint.getArgs();
for(int i=0; i< params.length; i++) {
if(!result.equals("")) result += ", ";
result += params[i].toString();
};
System.out.println("A method will be executed: " + thisJoinPointStaticPart.getSignature().getDeclaringType().getName() + "." + thisJoinPointStaticPart.getSignature().getName() + "(" + result + ")");
}
after(): doMethod(){
String result = "";
Object[] params = thisJoinPoint.getArgs();
for(int i=0; i< params.length; i++) {
if(!result.equals("")) result += ", ";
result += params[i].toString();
};
System.out.println("A method was executed: " + thisJoinPointStaticPart.getSignature().getDeclaringType().getName() + "." + thisJoinPointStaticPart.getSignature().getName() + "(" + result + ")");
}
}