Can AOP proxy target multiple beans?

80 views
Skip to first unread message

marc

unread,
Sep 9, 2013, 12:25:45 PM9/9/13
to coldspri...@googlegroups.com
Hello,

I set up an AOP construct in coldspring.xml:

    <bean id="categoryService" class="coldspring.aop.framework.ProxyFactoryBean">
        <property name = "target">
            <ref bean = "categoryServiceTarget" />
        </property>
        <property name = "interceptorNames">
            <list>
                <value>jsonAdvisor</value>
            </list>
        </property>
    </bean>


This proxy targets one bean: categoryServiceTarget. If I want it to target another bean, do I have to add the same bean definition again, this time setting the property 'target' to the second bean instance? Or can I expand the current bean node to incorporate a refrence to second bean?

Thanks,

Marc

Tom Chiverton

unread,
Dec 3, 2013, 11:25:43 AM12/3/13
to coldspri...@googlegroups.com
I believe so. You can use abstract="true" on a bean, then refer to parent="abstractId" in another bean if you want to save retyping common properties across several beans.
We do this for our RemoteFactoryBeans so they all get the same interceptors.

<bean id="abstractRemote" abstract="true">  
  <property name="relativePath">
      <value>/com/ev/remote/</value>
  </property>
  <property name="remoteMethodNames">
      <value>*</value>
  </property>
  <property name="interceptorNames">
    <list>
      <value>remoteExceptionAdvisor</value>
  </list>
  </property>       
  <property name="advicePackage">
    <value>coldspring.metadata.advices</value>
  </property>
</bean>

<bean id="remoteClient" class="coldspring.metadata.MetadataAwareRemoteFactoryBean"
    parent="abstractRemote"
    >
    <property name="targetBeanId">
        <value>clientManager</value>
    </property>
    <property name="serviceName">
        <value>Client</value>
    </property>
</bean>


<bean id="remoteCampaign" class="coldspring.metadata.MetadataAwareRemoteFactoryBean"
    parent="abstractRemote"
    >
    <property name="targetBeanId">
        <value>campaignManager</value>
    </property>
    <property name="serviceName">
        <value>Campaign</value>
    </property>
</bean>



--
You received this message because you are subscribed to the Google Groups "ColdSpring-Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldspring-use...@googlegroups.com.
To post to this group, send email to coldspri...@googlegroups.com.
Visit this group at http://groups.google.com/group/coldspring-users.
For more options, visit https://groups.google.com/groups/opt_out.



--
Tom
Reply all
Reply to author
Forward
0 new messages