Results 1 to 4 of 4

Thread: how can I remove property duplication?

  1. #1

    Default how can I remove property duplication?

    I would like to have default aop setting for all my beans, putting the properties in only one place, like this:
    Code:
    	<bean id="baseProxy"  abstract="true" 
    			class="org.springframework.beans.factory.FactoryBean">
    		<property name="frozen"><value>$&#123;spring.aop.advice.frozen&#125;</value></property>
    		<property name="optimize"><value>$&#123;spring.aop.doCGLibProxies&#125;</value></property>	
    		<property name="opaque"><value>$&#123;spring.aop.opaqueProxies&#125;</value></property>	
    	</bean>		
    
    	<bean id="baseTransactionProxy"  abstract="true" 
    			parent="baseProxy">
    		<property name="transactionManager"><ref bean="transactionManager"/></property>
    	</bean>	
    
    	<bean id="baseNonTransactionalProxy"  abstract="true" 	
    		parent="baseProxy">
            <!--Include some properties that are specific to beans
                that do not themselves control transactions.
             -->   
    	</bean>
    But I get an error saying '"org.springframework.beans.FatalBeanException: Class [org.springframework.beans.factory.FactoryBean] cannot be instantiated: it is an interface.'

    So I have to settle for putting the properties in two places, like this:
    Code:
    	<bean id="baseTransactionProxy"  abstract="true" 
    			class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager"><ref bean="transactionManager"/></property>
    		<property name="frozen"><value>$&#123;spring.aop.advice.frozen&#125;</value></property>
    		<property name="optimize"><value>$&#123;spring.aop.doCGLibProxies&#125;</value></property>	
    		<property name="opaque"><value>$&#123;spring.aop.opaqueProxies&#125;</value></property>	
    	</bean>	
    
    	<bean id="baseNonTransactionalProxy"  abstract="true" 	
    		class="org.springframework.aop.framework.ProxyFactoryBean">
    		<property name="frozen"><value>$&#123;spring.aop.advice.frozen&#125;</value></property>
    		<property name="optimize"><value>$&#123;spring.aop.doCGLibProxies&#125;</value></property>	
    		<property name="opaque"><value>$&#123;spring.aop.opaqueProxies&#125;</value></property>	
    	</bean>
    Is there some way I can put those properties in just one place?

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    Shouldn't
    Code:
    <bean id="baseTransactionProxy"  abstract="true"
             parent="baseProxy">
          <property name="transactionManager"><ref bean="transactionManager"/></property>
       </bean>
    be
    Code:
    <bean id="baseTransactionProxy"  abstract="true"
             parent="baseProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
          <property name="transactionManager"><ref bean="transactionManager"/></property>
       </bean>

  3. #3

    Default duplication

    Yep. Sorry about that. And of course the non-transactional bean should be class="org.springframework.aop.framework.ProxyFact oryBean">.

    I'm away from my Spring setup at the moment, but I think that correcton won't completely solve the problem. That is, I'll still be informed that "org.springframework.beans.FatalBeanException: Class [org.springframework.beans.factory.FactoryBean] cannot be instantiated: it is an interface.'

    I'll check that when I get in to work on Monday.

  4. #4

    Default duplication removed

    I was wrong. The correct configuration removes all duplication. Thanks.

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Unit testing with JOTM and JtaTransactionManager
    By lalle in forum Architecture
    Replies: 1
    Last Post: Oct 15th, 2005, 09:05 AM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. Replies: 4
    Last Post: Aug 17th, 2005, 04:42 AM
  5. Replies: 2
    Last Post: May 13th, 2005, 05:42 AM

Posting Permissions

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