Announcement Announcement Module
Collapse
No announcement yet.
Prototype Services with TransactionProxyFactoryBean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Prototype Services with TransactionProxyFactoryBean

    Spring version: 1.2

    I am currently trying to create prototype services using a TransactionProxyFactoryBean.
    The definition is according with the one described in Chapter 7.4 :

    Code:
    <bean id="txProxyTemplate" abstract="true" 
    class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
      <property name="transactionManager">
        <ref bean="transactionManager"/>
      </property>
      <property name="transactionAttributes">
        <props>
          <prop key="*">PROPAGATION_REQUIRED</prop>
        </props>
      </property>
    </bean>
    
    <bean id="simpleDelegateService" parent="txProxyTemplate">
      <property name="target">
    	<bean class="com.ez.ezrt.service.impl.SimpleDelegateServiceImpl"/>
      </property>
    </bean>
    but this seems to be able to return just singletons services.

    Is there a way to make it work for prototypes?

  • #2
    TransactionProxyFactoryBean isn't designed for prototypes. It's a convenience class for the usual case (transactional singleton). However, the generic ProxyFactoryBean does allow for prototype usage. Set the singleton property to true.

    Btw I don't see any singleton=false in your code.

    Comment

    Working...
    X