@Override public void addTransactionCommitAdvice(MethodAdviceReceiver receiver) { for (final Method m : receiver.getInterface().getMethods()) { if (m.getAnnotation(CommitAfter.class) != null) { PersistenceContext annotation = receiver.getMethodAnnotation(m, PersistenceContext.class); MethodAdvice advice = annotation == null ? shared : new TransactionalUnitMethodAdvice(manager, annotation); receiver.adviseMethod(m, advice); } } }
private static void doAdvise(MethodAdviceReceiver receiver, final String id) { receiver.adviseAllMethods( new MethodAdvice() { public void advise(MethodInvocation invocation) { invocation.proceed(); Object result = invocation.getReturnValue(); invocation.setReturnValue(String.format("%s[%s]", id, result)); } }); }