Announcement Announcement Module
Collapse
No announcement yet.
Inheritance of proxied beans Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Inheritance of proxied beans

    Hello there,

    I have a bean that is already proxing all my service objects so that I can manage transaction´s configuration transparently. The code below shows its configuration.
    Code:
    <!-- Transaction template for Managers, from:
    		http://blog.exis.com/colin/archives/...ons-spring-11/ -->
    	<bean id="txProxyTemplate" abstract="true"
    		class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager" ref="transactionManager" />
    		<property name="transactionAttributes">
    			<props>
    				<prop key="save*">PROPAGATION_REQUIRED</prop>
    				<prop key="remove*">PROPAGATION_REQUIRED</prop>
     				<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
    				<prop key="delete*">PROPAGATION_REQUIRED</prop> 
    			</props>
    		</property>
    	</bean>

    I also have a service class, called BaseManager which has some generic methods, that many use cases use. The code below is the definition of the BaseManager class.

    Code:
    	<!-- Generic manager that can be used to do basic CRUD operations on any objects  -->
    	<bean id="baseManager" abstract="true" parent="txProxyTemplate">
    		<property name="target">
    			<bean class="br.gov.mps.souweb.service.impl.BaseManagerImpl">
    				<property name="baseDAO" ref="baseDAO" />
    			</bean>
    		</property>
    	</bean>
    The problem is sometimes it is necessary to create some specificUseCaseManagers and I would like to make them inherit from BaseManager bean AND also be proxied by my transaction bean.

    How can I accomplish this?

    I tried the following below, but the properties defined on the superclass, i.e., on the BaseManager class are not setted by Spring.

    Code:
    <bean id="specificUseCaseManager" parent="baseManager">
    		<property name="target">
    			<bean class="br.gov.mps.souweb.service.impl.specificUseCaseManagerImpl">
                            <bean>
    				<property name="buscaDAO" ref="buscaDAO" />
    			</bean>
    		</property>
    		<property name="transactionAttributes">
    			<props>
    				<prop key="*">PROPAGATION_REQUIRED</prop>
    			</props>
    		</property>
    	</bean>
Working...
X