Results 1 to 4 of 4

Thread: how to add interceptor to mixin class

  1. #1
    Join Date
    Sep 2004
    Posts
    18

    Default 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. #2
    Join Date
    Sep 2004
    Posts
    18

    Default

    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?

  3. #3
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    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.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  4. #4
    Join Date
    Sep 2004
    Posts
    18

    Default

    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?

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. Replies: 3
    Last Post: Sep 4th, 2005, 11:11 PM
  5. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •