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
In Spring AOP, a join point always represents a method execution. A pointcut is a predicate that matches the join points, and the pointcut expression language is a way of describing pointcuts programmatically.
JoinPoint: Joinpoint are points in your program execution where flow of execution got changed like Exception catching, Calling other method. PointCut: PointCut are basically those Joinpoints where you can put your advice(or call aspect). So basically PointCuts are the subset of JoinPoints.
Spring AOP currently supports only method execution join points (advising the execution of methods on Spring beans). Field interception is not implemented, although support for field interception could be added without breaking the core Spring AOP APIs.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With