pointcuts

Trying to match an AspectJ pointcut signature for any methods containing a variable

南楼画角 提交于 2020-01-03 17:12:26
问题 I want to create a pointcut that matches any method in my Web controller that contains a ModelMap: pointcut addMenu(ModelMap modelMap) : execution (public String example.web.MyController.*(..)) && args (modelMap); before(ModelMap modelMap) : addMenu(modelMap) { // Do stuff with modelMap... } My problem is that this only matches methods with ONLY the ModelMap parameter, others are not matched because they contain too many parameters. For example, this is not intercepted, due to the "req"

AspectJ Pointcut call on JAX-RS annotated Interface method

北慕城南 提交于 2019-12-14 03:17:14
问题 I'm trying to intercept a method of an interface annoted with a JAX-RS @POST. My Pointcut works for all non-interface methods and if the @POST-Annotation is directly at the called method. The interface method to intercept: @POST Response postToConnector(@Context CallContext callContext, String contentStream) throws Exception; The Pointcut to match the method: @Pointcut("call(@(javax.ws.rs.DELETE || javax.ws.rs.GET || javax.ws.rs.HEAD || javax.ws.rs.OPTIONS || " + "javax.ws.rs.POST || javax.ws

UnsupportedPointcutPrimitiveException on simple AOP example

…衆ロ難τιáo~ 提交于 2019-12-11 03:27:25
问题 I try to run a simple aop example in this site. I have spring aop and aspectj, aspectjweaver jars: @Aspect public class StringAspect { @Pointcut("call(* String.toLowerCase())") public void toLowerCasePointcut() {} @Around("toLowerCasePointcut()") public String toLowerCaseAroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable { String text = ((String) joinPoint.getTarget()).toUpperCase(); return text; } } When I run this example in Test.java like "AaBbCc".toLowerCase(), I get this

About Policy Enforcement with AspectJ

倾然丶 夕夏残阳落幕 提交于 2019-12-11 03:13:16
问题 I am using Aspectj for project-wide policy enforcement. One thing I am trying to implement now is that there should be no logic in any setter methods except simple validation with Guava's Preconditions.check* methods. public pointcut withinSetter() : withincode(public void set*(*)); public pointcut inputValidation() : call(public void Preconditions.check*(*)); public pointcut setFieldValue() : set(* *); public pointcut entity() : within(com.mycompany.BaseEntity+); declare warning : entity() &

Spring aop pointcut expression to access method return type

☆樱花仙子☆ 提交于 2019-12-04 11:03:01
问题 I have a service interface with many methods, all of which take a Request object and return a Response object. All request objects have a common ancestor and all response objects have a different common ancestor (which has a success flag and a message field). Now I want to have an around aspect that checks permissions etc, performs the service call and returns a Response object with a failure code if anything fails. The problem is: I need to know what type of Response object to create. Is

Spring aop pointcut expression to access method return type

痴心易碎 提交于 2019-12-03 06:48:31
I have a service interface with many methods, all of which take a Request object and return a Response object. All request objects have a common ancestor and all response objects have a different common ancestor (which has a success flag and a message field). Now I want to have an around aspect that checks permissions etc, performs the service call and returns a Response object with a failure code if anything fails. The problem is: I need to know what type of Response object to create. Is there a pointcut expression that gives me access to the return type? Something like this, perhaps? @Around

@AspectJ pointcut for methods that override an interface method with an annotation

徘徊边缘 提交于 2019-11-29 00:58:52
问题 How can I write an aspectj pointcut that applies to method executions which override an interface method with an annotation? For example: interface A { @MyAnnotation void method(); } class B implements A { void method(); } The pointcut execution(@MyAnnotation * *.*(..)) does only match if B.method() carries the annotation itself. Is there another way to do this? 回答1: As Nicholas pointed out, this is not possible in AspectJ. Here is more proof of why it is not possible (taken from http://www