pointcut

Spring AOP pointcut that matches annotation on interface

徘徊边缘 提交于 2019-11-27 07:26:29
I have a service class implemented in Java 6 / Spring 3 that needs an annotation to restrict access by role. I have defined an annotation called RequiredPermission that has as its value attribute one or more values from an enum called OperationType: 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(

AspectJ pointcut on constructor object

坚强是说给别人听的谎言 提交于 2019-11-27 02:27:18
问题 I need to inject few methods to every initialized object using AspectJ. I thought using this : pointcut vistaInjection(Object o) : initialization(java.lang.Object.new() ) && target(o) && !within(objectAspect); before(Object o): methodInjection(o){System.err.println("INIT");} to pointcut initialization of object, so I can inject these methods directly into the object that is part of every other object. However, it does't work. Do you have any idea why? Or what may be an other way how to make

AspectJ pointcut expression match parameter annotations at any position

倾然丶 夕夏残阳落幕 提交于 2019-11-26 21:13:49
问题 I'm trying to define a pointcut expression to match methods which contain a parameter annotated with a specific annotation, regardless of what position the parameter is in. In my case I'm looking for the @Constraint annotation. For example: Matching methods: public void method1(@Constraint Car car) public void method2(String id, @Constraint Plane plane) public void method3(Wheel wheel, @Constraint List<Train> trains, @Constraint Plane plane) public void method4(Motor motor, @Constraint Set

Spring AOP pointcut that matches annotation on interface

那年仲夏 提交于 2019-11-26 13:09:46
问题 I have a service class implemented in Java 6 / Spring 3 that needs an annotation to restrict access by role. I have defined an annotation called RequiredPermission that has as its value attribute one or more values from an enum called OperationType: 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