I actually found a good pattern to use for what I wanted to do. Since, I'm using Webwork it was pretty easy to have a transaction start and close and the beginning and ending of the processing of each of my action invocations.
I actually found a good pattern to use for what I wanted to do. Since, I'm using Webwork it was pretty easy to have a transaction start and close and the beginning and ending of the processing of each of my action invocations.
I've been using WebWork 2 and Spring in conjunction in a project that started in December 2003. At that time nobody had published a really compelling and simple integration between the two, so I made a home-grown solution that basically replaced WebWork's action factory with a simple factory that basically just autowires the WW actions via their constructors (PicoContainer -style). It's worked very well.Originally Posted by ehauser
In my project, I also considered WebWork actions to be natural units-of-work (like adding a user, creating a news article etc), so I made my transaction handling work so that each action invocation occured in a single transaction.
My actions interact with different services and domain objects and all db access calls are executed in the same tx context. Spring works great for stuff like this (already back then, and 'tis maturing all the time).
I'm having same issue. Any resolution on this?
I eventually found a solution that works pretty well for me. I have an interceptor in Webwork's stack that doesn't do anything, but it allows for every action to execute under a single transaction.Originally Posted by garpinc2
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
<property name="transactionManager">
<ref local="transactionManager" />
</property>
<property name="target">
<ref local="transactionInterceptorTarget" />
</property>
<property name="transactionAttributes">
<props>
<prop key="intercept">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="transactionInterceptorTarget" class="ii.webwork.interceptor.TransactionIntercept or" />
Then, I use the following for all of my DAO managers:
<bean id="mentorManager" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
<property name="transactionManager">
<ref local="transactionManager" />
</property>
<property name="target">
<ref local="mentorManagerTarget" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_MANDATORY</prop>
</props>
</property>
</bean>
This works like a charm. I'm using the xwork-spring integration library. It's available at https://xwork-optional.dev.java.net/
Can't find that class. Please advise. ii.webwork.interceptor.TransactionInterceptor
Also any ideas about how I could adapt this for Struts
That class is specific to my individual project. It doesn't really apply to Struts because interceptors do not exist in the Struts framework. There is a sample chapter for Spring Live which discusses Spring integration with Struts. I'm assuming that there is a probably a method in the Spring controller for Struts that you could use for transaction demarcation, and achieve the similar affect.Originally Posted by garpinc2
A little while ago we created ServletWrappingController which supports Spring interceptors for Struts. Maybe posting the code here would help me out.
I'm still waiting on your posting...
Thanks,
Garry