after() throwing, around(), .
void around(): execution(* MainClass.main(*)) {
try {
proceed();
} catch (Exception e) {
System.out.println("Suppressed an exception: "
+ e + "Joinpoint: " + thisJoinPoint.getSignature().toString());
}
}
after() throwing , - , , ( , ):
after() throwing(Exception e): execution(* MainClass.main(*)) {
System.out.println("Threw an exception: " + e + "Joinpoint: "
+ thisJoinPoint.getSignature().toString());
throw new RuntimeException("Another exception", e);
}
EDIT. , before(), after() returning, after() throwing after() around() advice, .
void around(): execution(* MainClass.main(*)) {
try {
System.out.println("Before main started.");
proceed();
System.out.println("Main exited normally.");
} catch (Exception e) {
System.out.println("Suppressed an exception: " + e + "Joinpoint: "
+ thisJoinPoint.getSignature().toString());
} finally {
System.out.println("After main executed.");
}
}
:
Before main started.
Main started.
Suppressed an exception: java.lang.RuntimeException: errorJoinpoint: void MainClass.main(String[])
After main executed
, after() returning , , , after() returning .