+++ /dev/null
-
-public interface IService {
- void method(long l) throws Exception;
-}
+++ /dev/null
-
-public class Main {
-
- public static void main(String[] args) throws Exception {
- IService service = new Service();
- service.method(42L);
- }
-}
+++ /dev/null
-
-public class Service implements IService {
-
- public void method(long l) throws Exception {
- System.err.println("Original impl of service method, arg " + l);
- }
-}
+++ /dev/null
-
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-
-@Aspect
-public class ServiceInterceptor {
-
- @Around("execution(void test.Service.method(long))")
- public void method(ProceedingJoinPoint pjp) throws Throwable {
- Object[] args = pjp.getArgs();
- long id = (Long) args[0];
- System.out.println("in advice, arg = " + id + " (before proceed)");
- pjp.proceed(pjp.getArgs());
- System.out.println("in advice (after proceed)");
- }
-}
+++ /dev/null
-
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-
-public aspect ServiceInterceptorCodeStyle {
-
- void around(): execution(void Service.method(long)) {
- Object[] args = thisJoinPoint.getArgs();
- long id = (Long) args[0];
- System.out.println("in advice, arg = " + id + " (before proceed)");
- proceed();
- System.out.println("in advice (after proceed)");
- }
-}