Spring AOP point with one specific argument

I need to create an aspect that is hard for me to describe, so let me point out ideas:

  • any method inside the package (or any subpackage) com.xy ..
  • one argument of the method is an implementation of the javax.portlet.PortletRequest interface
  • there may be more arguments in the method
  • they can be in any order

I need a pointcut and "around" tip with the PortletRequest parameter specified

I currently have smt like:

@Pointcut("execution(* com.xy.*.*(PortletRequest,..)) && args(request,..)") public void thePointcut(PortletRequest request) { } @Around("thePointcut(request)") public Object theAdvice(ProceedingJoinPoint joinPoint, PortletRequest request) { ... 

and get an error message:

ERROR 10: 47: 27.159 [ContainerBackgroundProcessor [StandardEngine [Catalina]]] osweb.portlet.DispatcherPortlet - Context Initialization error org.springframework.beans.factory.BeanCreationException: Error creating bean named org.springframework.web.servlet. mvc.HttpRequestHandlerAdapter ': Bean initialization failed; The nested exception is java.lang.IllegalArgumentException: w arning no match for this type name: PortletRequest [Xlint: invalidAbsoluteTypeName]

Any help is much appreciated

Regards, Dan

The UPDATE method I'm trying to intercept:

in the public class com.xyMainClass :

public String mainRender(Model model, RenderRequest request) throws SystemException

in the public class com.xyasd.HelpClass :

public final void helpAction(ActionRequest request, ActionResponse response, Model model)

In the course, I want to get an argument that implements PortletRequest, that is, RenderRequest from the first method, and ActionRequest from the second.

Regards, Dan

+7
source share
1 answer

As this error implies, you need to use the full name PortletRequest in the point abbreviation expression - since this is a string, the import context is not available during the evaluation of the expression.

 @Pointcut("execution(* com.xy.*.*(javax.portlet.PortletRequest.PortletRequest,..)) && args(request,..)") public void thePointcut(PortletRequest request) { } 

Since you already select the type in the args construct, you do not need this in the signature. The following should also work.

 @Pointcut("execution(* com.xy.*.*(..)) && args(request,..)") public void thePointcut(PortletRequest request) { } 

This operation a and boolean, that is, it must match the template of the method, as well as the construction of args.

+8
source

All Articles