Announcement Announcement Module
Collapse
No announcement yet.
problem binding multiple params with @target and @within Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem binding multiple params with @target and @within

    I'm having trouble with @AspectJ parameter binding for more than one parameter.

    With this annotation:
    Code:
    @Retention(RetentionPolicy.RUNTIME)
    @Target( { ElementType.METHOD, ElementType.TYPE })
    public @interface Cached {
         int timeToLive() default 0;
    }
    on either methods or classes, and I'd like to access the annotation in the advice. It seems like this should work:
    Code:
    @Around("@annotation(methodAnnotation) || @within(classAnnotation)")
    public Object aroundAdvice(ProceedingJoinPoint joinPoint, Cached methodAnnotation, Cached classAnnotation) { ... }
    Both it gives the following error:
    Code:
    Caused by: java.lang.IllegalArgumentException: error at ::0 inconsistent binding
    	at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:317)
    	at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:206)
    	at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:193)
    	at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:174)
    	at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:195)
    	at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:250)
    	at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:284)
    	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:113)
    	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:85)
    	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:66)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:362)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:325)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:361)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1344)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
    	... 51 more
    I am compiling in debug mode (in Eclipse). Using argNames still produced the error. I can get something to work if I use reflection.

    I must be doing something wrong though. If I use two separate annotations, one for classes and one for methods, then have my advice take both in as parameters), I still get "error at ::0 inconsistent binding".

    How can I get binding to work with two parameters?

  • #2
    Is anybody can help?

    I got the same problem

    Comment


    • #3
      got it fixed

      I found a fix when I tried Load Time Weaving (rather than just Spring's built-in AOP). The error messages were much more helpful with Load Time Weaving, and allowed me to make some small fixes that eventually worked for both Load Time Weaving and Spring AOP.

      My final working version is open sourced. Here's the file that defines the aspect and pointcuts:
      http://code.google.com/p/easiest-cac...cheAspect.java
      Specifically, see lines 110 - 116 and 71 - 77

      Comment


      • #4
        Originally posted by bradcupit View Post
        I found a fix when I tried Load Time Weaving (rather than just Spring's built-in AOP). The error messages were much more helpful with Load Time Weaving, and allowed me to make some small fixes that eventually worked for both Load Time Weaving and Spring AOP.

        My final working version is open sourced. Here's the file that defines the aspect and pointcuts:
        http://code.google.com/p/easiest-cac...cheAspect.java
        Specifically, see lines 110 - 116 and 71 - 77
        So,with your Help,I also got my Problem fixed,
        but why we can't binding two params in the same time?
        You have mentioned the "Load Time Weaving", Maybe I should try it later

        Comment

        Working...
        X