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