Announcement Announcement Module
Collapse
No announcement yet.
Non-singleton service objects with declative trasaction ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Non-singleton service objects with declative trasaction ?

    Hi,
    I want to create service objects with declative transaction,
    so I use TransactionProxyFactoryBean in applicationcontext.xml
    as following:

    Code:
    <bean id="myService" class="org.spring....TransactionProxyFactoryBean">
           ...
    		<property name="transactionAttributes">
    			<props>
    				<prop key="process*">PROPAGATION_REQUIRED</prop>
    			</props>
    		</property>
    	</bean>
    Thanks of Spring, it works well.
    But TransactionProxyFactoryBean looks like only create singleton objects.
    How can I create "myService" with declative trasction and without singleton ?

    Thanks!

  • #2
    in general, to create a protoype bean you use
    Code:
      <bean id="beanId" class="BeanClass" singleton="false">
      ...
      </bean>
    But TransactionProxyFactoryBean looks like only create singleton objects.
    How can I create "myService" with declative trasction and without singleton ?
    If your service is thread safe, there is no need to create multiple instances.
    HTH

    Comment


    • #3
      You can use ProxyFactoryBean to create a non-singleton bean with transaction interception. Or you can use one of the "autoproxy creators" like BeanNameAuotProxyCreator. Please see the AOP chapter of the Reference Manual.

      Comment

      Working...
      X