LDAP-256: Now requiring TempEntryRenamingStrategy to be explicitly configured. Updated transaction documentation to reflect this and use tx:annotation-config syntax.
This commit is contained in:
@@ -34,10 +34,6 @@
|
||||
transaction (e.g. a <literal>modifyAttributes</literal> followed by a <literal>rebind</literal>), or
|
||||
if transaction synchronization with a JDBC data source is not required (see below) there will be nothing to gain
|
||||
by using the LDAP transaction support.</note>
|
||||
<note>While the default setup will work fine for most simple use cases, some more complex scenarios will
|
||||
require additional configuration; more specifically if you will be creating or deleting subtrees within
|
||||
transactions, you will need to use an alternative <literal>TempEntryRenamingStrategy</literal>, as described
|
||||
in <xref linkend="renaming-strategies"/> below</note>
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
@@ -45,9 +41,10 @@
|
||||
<title>Configuration</title>
|
||||
<para>
|
||||
Configuring Spring LDAP transactions should look very familiar if you're used to configuring Spring transactions.
|
||||
You will create a <literal>TransactionManager</literal> instance and wrap your target object using a
|
||||
<literal>TransactionProxyFactoryBean</literal>. In addition to this, you will also need to wrap your
|
||||
<literal>ContextSource</literal> in a <literal>TransactionAwareContextSourceProxy</literal>.
|
||||
You will annotate your transacted classes with <literal>@Transactional</literal>, create a
|
||||
<literal>TransactionManager</literal> instance and include a <literal><tx:annotation-driven></literal>
|
||||
tag in your bean configuraion. In addition to this, you will also need to wrap your <literal>ContextSource</literal>
|
||||
in a <literal>TransactionAwareContextSourceProxy</literal>.
|
||||
<informalexample>
|
||||
<programlisting><beans>
|
||||
...
|
||||
@@ -70,29 +67,32 @@
|
||||
<bean id="transactionManager"
|
||||
class="org.springframework.ldap.transaction.compensating.manager.ContextSourceTransactionManager">
|
||||
<property name="contextSource" ref="contextSource" />
|
||||
<property name="renamingStrategy">
|
||||
<!--
|
||||
Note this default configuration will not work for more complex scenarios, see below for more information on RenamingStrategies.
|
||||
-->
|
||||
<bean class="org.springframework.ldap.transaction.compensating.support.DefaultTempEntryRenamingStrategy" />
|
||||
</property>
|
||||
|
||||
</bean>
|
||||
|
||||
<bean id="myDataAccessObjectTarget" class="com.example.MyDataAccessObject">
|
||||
<bean id="myDataAccessObject" class="com.example.MyDataAccessObject">
|
||||
<property name="ldapTemplate" ref="ldapTemplate" />
|
||||
</bean>
|
||||
|
||||
<bean id="myDataAccessObject"
|
||||
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
<property name="target" ref="myDataAccessObjectTarget" />
|
||||
<property name="transactionAttributes">
|
||||
<props>
|
||||
<prop key="*">PROPAGATION_REQUIRES_NEW</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<tx:annotation-driven>
|
||||
|
||||
...</programlisting>
|
||||
<note>While the this setup will work fine for most simple use cases, some more complex scenarios will
|
||||
require additional configuration; more specifically if you will be creating or deleting subtrees within
|
||||
transactions, you will need to use an alternative <literal>TempEntryRenamingStrategy</literal>, as described
|
||||
in <xref linkend="renaming-strategies"/> below</note>
|
||||
</informalexample>
|
||||
In a real world example you would probably apply the transactions on the service object level
|
||||
rather than the DAO level; the above serves as an example to demonstrate the general idea.
|
||||
<note>You'll notice that the actual <literal>ContextSource</literal> and DAO instances get ids with a
|
||||
"Target" suffix. The beans you will actually refer to are the Proxies that are created
|
||||
around the targets; <literal>contextSource</literal> and <literal>myDataAccessObject</literal></note>
|
||||
<note>You'll notice that the actual <literal>ContextSource</literal> instance gets an id with a
|
||||
"Target" suffix. The bean you will actually refer to is the Proxy that are created
|
||||
around the target; <literal>contextSource</literal>.</note>
|
||||
</para>
|
||||
</sect1>
|
||||
<sect1 id="jdbc-transaction-integration">
|
||||
|
||||
Reference in New Issue
Block a user