Spring AOP切入点有一个特定的参数
我需要创建一个我难以描述的方面,所以让我指出这些想法:
- com.xy的包(或任何子包)中的任何方法..
- 一个方法参数是接口javax.portlet.PortletRequest的实现
- 这个方法可能有更多的争论
- 他们可能是任何顺序
我需要一个切入点和给出的PortletRequest的“around”建议
目前我有点像:
@Pointcut("execution(* com.xy.*.*(PortletRequest,..)) && args(request,..)") public void thePointcut(PortletRequest request) { } @Around("thePointcut(request)") public Object theAdvice(ProceedingJoinPoint joinPoint, PortletRequest request) { ...
并收到错误:
错误10:47:27.159 [ContainerBackgroundProcessor [StandardEngine [Catalina]]] osweb.portlet.DispatcherPortlet – 上下文初始化失败org.springframework.beans.factory.BeanCreationException:创建名为’org.springframework.web.servlet的bean时出错。 mvc.HttpRequestHandlerAdapter’:bean的初始化失败; 嵌套exception是java.lang.IllegalArgumentException:w arning此类型名称不匹配:PortletRequest [Xlint:invalidAbsoluteTypeName]
任何帮助高度赞赏
亲切的问候,丹
更新我试图拦截的方法是:
在公共类com.xyMainClass中 :
public String mainRender(Model model, RenderRequest request) throws SystemException
在公共类com.xyasd.HelpClass中 :
public final void helpAction(ActionRequest request, ActionResponse response, Model model)
对于cource,我想获得实现PortletRequest的参数,即第一个方法的RenderRequest和第二个方法的ActionRequest。
问候,丹
由于错误建议您需要在切入点表达式中使用PortletRequest的完全限定名称 – 因为它是一个字符串,导致上下文在评估表达式时不可用。
@Pointcut("execution(* com.xy.*.*(javax.portlet.PortletRequest.PortletRequest,..)) && args(request,..)") public void thePointcut(PortletRequest request) { }
由于您已经在args构造中选择了类型,因此签名中不需要该类型。 以下也应该有效。
@Pointcut("execution(* com.xy.*.*(..)) && args(request,..)") public void thePointcut(PortletRequest request) { }
它是一个布尔运算 – 也就是说,它需要匹配方法模式以及args构造。