|
From: <jue...@we...> - 2003-08-21 17:25:40
|
Hi everybody,
I've introduced a proxy factory bean for simplified declarative =
transaction demarcation, as an alternative to a standard =
ProxyFactoryBean plus TransactionInterceptor combo. The definition =
syntax is as follows:
<bean id=3D"myBusinessService" =
class=3D"org.springframework.transaction.interceptor.TransactionProxyFact=
oryBean">
<property name=3D"transactionManager"><ref =
bean=3D"myTransactionManager"/></property>
<property name=3D"target"><ref =
bean=3D"myBusinessServiceTarget"/></property>
<property name=3D"proxyInterfacesOnly"><value>true</value><property>
<property name=3D"transactionAttributes">
<props>
<prop key=3D"myBusiness*">PROPAGATION_REQUIRED</prop>
<prop key=3D"myBusinessMethod">PROPAGATION_MANDATORY</prop>
</props>
</property>
</bean>
Note that the transaction attributes are specified as properties here, =
with the method name as key. No need for a separate =
TransactionInterceptor bean that defines the attributes for all proxies =
in the application context, with the need for fully qualified class plus =
method names.
The advantages, as I see them, are:
- The transaction attributes for the methods of a target are defined in =
the proxy for the target. That keeps related things close together.
- The target can be specified as bean reference, no need to care about a =
chain of interceptor names. A bean reference is an easier, i.e. better =
known, concept.
- The proxy interfaces are determined automatically from the target. =
proxyInterfacesOnly=3Dtrue is the default, setting it to false will =
create a CGLIB proxy.
- All things considered, it covers the typical use case of declarative =
transactions.
The disadvantage is, of course, the loss of configuration options - that =
can be an advantage too, as it makes the whole issue less complex. =
Anyway, for full control like including arbitrary interceptors, proxying =
specific interfaces, etc, the standard ProxyFactoryBean has to be used.
BTW, notice the "*" mapping for method names. This is available with =
both TransactionInterceptor and TransactionProxyFactoryBean: It's a =
simple way of applying an attribute to a set of methods. The more =
specific definition will win, so myBusinessMethod will have "mandatory" =
but myBusinessSomething and myBusinessWhatever will have "required". In =
case of overloaded methods, all methods that match the given name will =
be registered. There is no support for addressing a specific overloaded =
method yet.
Juergen
DI J=FCrgen H=F6ller
Senior System Architect
______________________________________
werk3ATS - division systementwicklung
part of werk3AT internetmedien oeg
europaplatz 4
A - 4020 linz
t. +43 (0) 732 71 65 29 502
f. +43 (0) 732 71 65 29 3
mailto:jue...@we...
http://www.werk3at.com
______________________________________
werk3ATS - WIR ENTWICKELN ERFOLG
|