Announcement Announcement Module
Collapse
No announcement yet.
how to add interceptor to mixin class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to add interceptor to mixin class

    I have use BeanNameAutoProxyCreator to generate mixin proxy class, but how can I add interceptor to this class? Rod can you help me?

  • #2
    any body can help me? it's so urgent problem.
    and for example this is the my sample code from spring test suite

    <bean id="introductionBeanNameProxyCreator" class="org.springframework.aop.framework.autoproxy
    <property name="beanNames"><value>*testbean</value></property>
    <property name="interceptorNames">
    <list>
    <value>lockableAdvisor</value>
    </list>
    </property>
    </bean>

    <bean id="lockableAdvisor"
    class="org.springframework.aop.framework.LockMixin Advisor"
    singleton="false"
    >
    </bean>

    <bean id="testbean" class="org.springframework.beans.TestBean">
    </bean>

    public Class TestBean
    {
    public void doSomething(){
    }
    }

    So I want a interceptor to intercept when doSomthing() method in the testbean is called,
    this is part of interceptor code
    Object invoke(methodInvocation invocation){
    LockMixin mixin = (LockMixin)invocaton.getThis();
    ......
    }
    this show ClassCast error, why?

    Comment


    • #3
      Object invoke(methodInvocation invocation){
      LockMixin mixin = (LockMixin)invocaton.getThis();
      ......
      }
      this show ClassCast error, why?
      MethodInvocation.getThis() returns the target, which is of type TestBean. You want the getProxy() method, as the proxy implements the introduced interface. Please let me know if you need further help.

      Comment


      • #4
        Thanks for the reply,and I am wonder if I can use a ProxyFactoryBean in the applicationContext.xml that reference to the autoproxyed mixin class?this ProxyFactoryBean has some interceptor on the mixin class.
        if can,how can I write?

        Comment

        Working...
        X