Announcement Announcement Module
Collapse
No announcement yet.
how to define multiple target? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to define multiple target?

    hi, given this configuration:

    Code:
    <bean id="proxiedDao"
    		class="org.springframework.aop.framework.ProxyFactoryBean">
    		<property name="proxyInterfaces">
    			<value>it.chi.repubblica.persistence.GenericBaseDao</value>
    		</property>
    		<property name="target">
    			<ref bean="argManDaoTarget"/>
    		</property>
    		<property name="interceptorNames">
    			<list>
    				<value>theDaoUpdateAdvice</value>
    			</list>
    		</property>
    	</bean>


    as far as I can see, itsn't possible to advise multiple target objects. correct ?

  • #2
    Yes, ProxyFactoryBean is for individual proxying. Usually, however, you do want to proxy multiple objects, and Spring provides several approaches:

    1. BeanNameAutoProxyCreator: Most similar to PFB but can apply to multiple targets. There are examples in some of the Spring same apps.
    2. Auto proxying approaches. Please see the AOP chapter of the reference manual.

    Comment


    • #3
      got it working. how to use annotations then ?

      hi Rod,
      after I found this blog entry, i adapt my code to the following:

      Code:
      <bean id="proxyCreator"
      		class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
      		<!--create a wrapper proxy around all beans named *DaoImpl. in particular,
      			a dynamic proxy will be generated for model dao implementations -->
      		<property name="beanNames" value="*DaoImpl"/>
      		<property name="interceptorNames">
      			<list>
      				<value>theDaoUpdateAdvice</value>
      			</list>
      		</property>
      	</bean>
      	<!-- Advisor pointcut definition for after advice -->
      	<bean id="theDaoUpdateAdvice"
      		class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
      		<property name="advice">
      			<ref local="daoUpdateAdvice"/>
      		</property>
      		<property name="patterns">
      			<list>
      				<value>.*saveOrUpdate</value>
      				<value>.*remove</value>
      				<value>.*update</value>
      			</list>
      		</property>
      	</bean>
      it would be interesting to know if it is possible to define pointcut using for example annotations (ala aspectj5) instead of method signature. is this possible?

      Comment

      Working...
      X