Results 1 to 8 of 8

Thread: how to describe <aop:scoped-proxy /> using <aop:config> ?

  1. #1
    Join Date
    Jul 2009
    Posts
    17

    Default how to describe <aop:scoped-proxy /> using <aop:config> ?

    Hello

    related to this topic small problem with oval and spring aop

    I found in spring manual 6.3 this warning
    The <aop:config> style of configuration makes heavy use of Spring's auto-proxying mechanism. This can cause issues (such as advice not being woven) if you are already using explicit auto-proxying via the use of BeanNameAutoProxyCreator or suchlike. The recommended usage pattern is to use either just the <aop:config> style, or just the AutoProxyCreator style.
    I'm using BeanNameAutoProxyCreator and <aop:scoped-proxy /> . I think that could be my problem.

    To solve it, i think i need to describe both my configs for oap:
    Code:
    <bean id="account" factory-bean="accountDao" factory-method="getAccount" scope="request">
        <constructor-arg value="1" />
        <aop:scoped-proxy />
    </bean>
    and

    Code:
    <bean id="ovalGuardInterceptor" class="net.sf.oval.guard.GuardInterceptor" />
    	
      <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
        <property name="proxyTargetClass" value="true" />
        <property name="beanNames" value="account" />
        <property name="interceptorNames"><list><value>ovalGuardInterceptor</value></list></property>
      </bean>
    using <aop:config>

    Only question.. how to do it?

    Any ideas?

  2. #2
    Join Date
    May 2007
    Location
    Saint Petersburg, Russian Federation
    Posts
    1,189

    Default

    You can use 'bean' pointcut designator for achieving exactly the same result.

  3. #3
    Join Date
    Jul 2009
    Posts
    17

    Default

    Quote Originally Posted by denis.zhdanov View Post
    You can use 'bean' pointcut designator for achieving exactly the same result.
    Hello Denis

    Thank you for your answer.

    Yes, i found 'bean' pointcut designator too. I'm using it for describe ovalGuardInterceptor. Now my configuration code looks like this:

    Code:
    	<bean id="account" factory-bean="accountDao" factory-method="getAccount">
    		<constructor-arg value="1" /> 
    	</bean>
    	
      <bean id="ovalGuardInterceptor" class="net.sf.oval.guard.GuardInterceptor" />
      
      <aop:config>
    	  <aop:advisor pointcut="bean(account)" advice-ref="ovalGuardInterceptor" />
      </aop:config>
    but i'm not sure how to create scoped-proxy in <oap:config .

    Aso, by the way, how to have spring do something like "proxyTargetClass" for <aop:advisor pointcut="bean(account)" advice-ref="ovalGuardInterceptor" /> ? Right now i removed interface from my Account class and now it automatically using class-based proxy. But i'm not sure how to have code to do it if my class still realize any interfaces.

  4. #4
    Join Date
    Jul 2009
    Posts
    17

    Default

    i found about proxy target class

    <aop:config proxy-target-class="false" />

  5. #5
    Join Date
    May 2007
    Location
    Saint Petersburg, Russian Federation
    Posts
    1,189

    Default

    Quote Originally Posted by andreykl View Post
    but i'm not sure how to create scoped-proxy in <oap:config .
    You shouldn't declare 'scoped-proxy' element inside <aop:config> your initial scoped proxy setup is fine with spring2 aop.

  6. #6
    Join Date
    Jul 2009
    Posts
    17

    Default

    i see, thanks. My configuration now is like this:

    Code:
    	<bean id="account" factory-bean="accountDao" factory-method="getAccount" scope="request">
    		<constructor-arg value="1" />
    		<aop:scoped-proxy proxy-target-class="true" />
    	</bean>
    	
      <bean id="ovalGuardInterceptor" class="net.sf.oval.guard.GuardInterceptor" />
      
      <aop:config proxy-target-class="true">
    	  <aop:advisor pointcut="bean(account)" advice-ref="ovalGuardInterceptor" />
      </aop:config>
    but problem is still here. While <aop:scoped-proxy /> enabled in config, ovalGuardInterceptor settings does not affect. If i'll remove <aop:scoped-proxy /> ovalGuardInterceptor configuration starts work perfect. It is absolutly the same problem which was with configuration which used BeanNameAutoProxyCreator. That looks like settings do not apply at all if i'm using scoped-proxy.

    I tryed also make interface for Account and use <aop:scoped-proxy proxy-target-class="false" />, but effect is exactly the same - while "scoped-proxy" is here, ovalGuardInterceptor's settings looks like ignored...

    Any ideas?

  7. #7
    Join Date
    May 2007
    Location
    Saint Petersburg, Russian Federation
    Posts
    1,189

    Default

    Quote Originally Posted by andreykl View Post
    ...
    problem is still here. While <aop:scoped-proxy /> enabled in config, ovalGuardInterceptor settings does not affect. If i'll remove <aop:scoped-proxy /> ovalGuardInterceptor configuration starts work perfect. It is absolutly the same problem which was with configuration which used BeanNameAutoProxyCreator. That looks like settings do not apply at all if i'm using scoped-proxy.

    I tryed also make interface for Account and use <aop:scoped-proxy proxy-target-class="false" />, but effect is exactly the same - while "scoped-proxy" is here, ovalGuardInterceptor's settings looks like ignored...

    Any ideas?
    Interesting. I'll try to check that when I have free time.

    Anyway, aspectj weaving for oval aspects should resolve the problem.

  8. #8
    Join Date
    Jul 2009
    Posts
    17

    Default

    thank you, Denis. i'll try aspectj now.

Posting Permissions

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