import org.aspectwerkz.aspect.Aspect; import org.aspectwerkz.AspectContext; import java.lang.reflect.Method; public class LoggingAspect implements Aspect { public void invoke(Method joinpoint, AspectContext context) throws Throwable { System.out.println("Before method execution: " + joinpoint.getName()); context.invokeNext(joinpoint); System.out.println("After method execution: " + joinpoint.getName()); } } public class MyService { public void doSomething() { System.out.println("Doing something..."); } } public class Main { public static void main(String[] args) { MyService service = new MyService(); service.doSomething(); } }


上一篇:
下一篇:
切换中文