I need to create an aspect that I find hard to describe, so let me point out the ideas:
I need a pointcut and an "around" advice with the PortletRequest given
Currently I have smt like:
@Pointcut("execution(* com.x.y..*.*(PortletRequest,..)) && args(request,..)")
public void thePointcut(PortletRequest request) {
}
@Around("thePointcut(request)")
public Object theAdvice(ProceedingJoinPoint joinPoint, PortletRequest request) {
...
and receive an error:
ERROR 10:47:27.159 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] o.s.web.portlet.DispatcherPortlet - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet. mvc.HttpRequestHandlerAdapter': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: w arning no match for this type name: PortletRequest [Xlint:invalidAbsoluteTypeName]
Any help highly appreciated
Kind regards, Dan
UPDATE the method i'm trying to intercept is:
in public class com.x.y.MainClass :
public String mainRender(Model model, RenderRequest request) throws SystemException
in public class com.x.y.asd.HelpClass:
public final void helpAction(ActionRequest request, ActionResponse response, Model model)
Of cource, I want to get the argument that implements PortletRequest, that is RenderRequest from the first method, and ActionRequest from the second.
Regards, Dan
As the error suggests you need to use the fully qualified name of the PortletRequest in the point cut expression - since it is a string the import context is not available during the time of evaluation of the expression.
@Pointcut("execution(* com.x.y..*.*(javax.portlet.PortletRequest.PortletRequest,..)) && args(request,..)")
public void thePointcut(PortletRequest request) {
}
Since you already are selecting the type in the args construct you don't need that in the signature. The following should also work.
@Pointcut("execution(* com.x.y..*.*(..)) && args(request,..)")
public void thePointcut(PortletRequest request) {
}
It is a and boolean operation - i.e., it needs to match the method pattern as well as the args construct.