|
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
|
|
From: Colin S. <col...@ex...> - 2003-08-21 22:35:56
|
The current ending for the classname SQLExceptionTranslater is not correct; the name should really be SQLExceptionTranslator... |
|
From: Colin S. <col...@ex...> - 2003-08-22 03:44:15
|
AbstractJndiLocator right now looks at the jndi name it is given, and if it doesn't start with java:comp/env prepends this value automatically. This behaviour is not correct. Somebody using the bean should be able to look up resources anywhere, and currently you can't. For example, in jboss, the main datasource by default is bound to java:DefaultDS As well, you may want to look up something on JNDI using another scheme entirely... What the code should probably do is see if the is a scheme xxxxx: at the beginning of the jndi name. If there isn't, then it is probably reasonable to assume 'java:comp/env. or 'java:' If there is a scheme, it should leave the name alone. I would have supplied a patch, but the fix is trivial, and I don't know how exactly you want to handle this, but it's pretty critical to me. Right now with JBoss it's pretty nasty. I can not use JBoss's naming alias service to alias java:comp/env/DefaultDS to java:DefaultDS because it apparently doesn't let you alias stuff under comp/env. I can probably modify my resource entries in the war file I use to do a resource ref to the right location, but I would really rather not do that, since the war is fine the way it is. Regards, Colin |
|
From: Colin S. <col...@ex...> - 2003-08-22 03:50:11
|
There are in fact 6 classes which currently end in Translater. In case somebody is confused by what I'm complaining about, translater is actually a mispelling of the proper word, translator. Colin Sampaleanu wrote: > The current ending for the classname SQLExceptionTranslater is not > correct; the name should really be SQLExceptionTranslator... |