Announcement Announcement Module
Collapse
No announcement yet.
how to describe <aop:scoped-proxy /> using <aop:config> ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    You can use 'bean' pointcut designator for achieving exactly the same result.

    Comment


    • #3
      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.

      Comment


      • #4
        i found about proxy target class

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

        Comment


        • #5
          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.

          Comment


          • #6
            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?

            Comment


            • #7
              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.

              Comment


              • #8
                thank you, Denis. i'll try aspectj now.

                Comment

                Working...
                X