i have aspect class method clear().
@aspect public class clear { @after("@annotation(org.springframework.transaction.annotation.transactional)") public void clear() { // smth } } now want call aspect after each execution of method annotation @transactional readonly = true
@transactional(readonly = true) public void somemethod() { //... } is there way without custom annotations?
i think quite close.
in clear method, should take in parameter of type joinpoint. parameter auto populated spring @ runtime, , it, can details of specific joinpoint, including java.lang.reflect.method, contain annotation after.
i thinking this:
@aspect public class clear { @after("@annotation(org.springframework.transaction.annotation.transactional)") public void clear(final joinpoint joinpoint) { final method method = ((methodsignature) joinpoint.getsignature()).getmethod(); final transactional txannotation = methood.getannotation(transactional.class); final boolean isreadonly = txannotation.readonly(); //do conditional work based on isreadonly } }
Comments
Post a Comment