Results 1 to 3 of 3

Thread: how to define multiple target?

  1. #1
    Join Date
    Feb 2006
    Location
    Rome, Italy
    Posts
    77

    Default 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. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

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

  3. #3
    Join Date
    Feb 2006
    Location
    Rome, Italy
    Posts
    77

    Red face 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?

Posting Permissions

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