Tag: 切入点

使用java.lang.reflection的构造函数的AspectJ切入点

以下示例是减少真正的问题,因为它尽可能地尝试简化。 我有一个java接口,以及几个实现该接口的对象,如: public interface Shape{ public void draw(); public void erase(); public boolean isDrawn(); } public class Square implements Shape{ @Override public void draw(){ //TODO: method implementation } @Override public void erase(){ //TODO: method implementation } Override public boolean isDrawn(){ //TODO: method implementation return false; } } public Triangle implements Shape{ //same as above } […]

Spring AOP – 带有注释的每个方法的切入点

我试图定义一个切入点,它将捕获每个使用(即) @CatchThis注释的方法。 这是我自己的注释。 此外,我想访问该方法的第一个参数,它将是Long类型。 可能还有其他争论,但我不关心它们。 编辑 这就是我现在所拥有的。 我不知道的是如何传递用@CatchThis注释的方法的第一个参数。 @Aspect public class MyAspect { @Pointcut(value = “execution(public * *(..))”) public void anyPublicMethod() { } @Around(“anyPublicMethod() && @annotation(catchThis)”) public Object logAction(ProceedingJoinPoint pjp, CatchThis catchThis) throws Throwable { return pjp.proceed(); } }

AspectJ切入点表达式匹配任何位置的参数注释

我正在尝试定义切入点表达式以匹配包含用特定注释注释的参数的方法,无论参数位于何处。在我的情况下,我正在寻找@Constraint注释。 例如: 匹配方法: public void method1(@Constraint Car car) public void method2(String id, @Constraint Plane plane) public void method3(Wheel wheel, @Constraint List trains, @Constraint Plane plane) public void method4(Motor motor, @Constraint Set trains, Bicycle bike, Wheel wheel) public void method5(Wing wing, Motorcycle moto, @Constraint Truck truck, Bicycle bike, Wheel wheel) 到目前为止,我已经尝试了以下表达式而没有运气: @Before(“execution(public * *.*(..)) and @args(com.example.Constraint)”) […]

Spring AOP切入点与接口上的注释匹配

我有一个在Java 6 / Spring 3中实现的服务类,它需要一个注释来限制角色访问。 我已经定义了一个名为RequiredPermission的注释,它具有一个名为OperationType的枚举中的一个或多个值作为其value属性: public @interface RequiredPermission { /** * One or more {@link OperationType}s that map to the permissions required * to execute this method. * * @return */ OperationType[] value();} public enum OperationType { TYPE1, TYPE2; } package com.mycompany.myservice; public interface MyService{ @RequiredPermission(OperationType.TYPE1) void myMethod( MyParameterObject obj ); } package com.mycompany.myserviceimpl; […]