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:
Mattias Hellborg Arthursson
2013-09-09 13:37:09 +02:00
parent a2cb44e4d4
commit 14bf8b48a2
14 changed files with 67 additions and 78 deletions

View File

@@ -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>&lt;tx:annotation-driven&gt;</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>&lt;beans&gt;
...
@@ -70,29 +67,32 @@
&lt;bean id="transactionManager"
class="org.springframework.ldap.transaction.compensating.manager.ContextSourceTransactionManager"&gt;
&lt;property name="contextSource" ref="contextSource" /&gt;
&lt;property name="renamingStrategy"&gt;
&lt;!--
Note this default configuration will not work for more complex scenarios, see below for more information on RenamingStrategies.
--&gt;
&lt;bean class="org.springframework.ldap.transaction.compensating.support.DefaultTempEntryRenamingStrategy" /&gt;
&lt;/property&gt;
&lt;/bean&gt;
&lt;bean id="myDataAccessObjectTarget" class="com.example.MyDataAccessObject"&gt;
&lt;bean id="myDataAccessObject" class="com.example.MyDataAccessObject"&gt;
&lt;property name="ldapTemplate" ref="ldapTemplate" /&gt;
&lt;/bean&gt;
&lt;bean id="myDataAccessObject"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"&gt;
&lt;property name="transactionManager" ref="transactionManager" /&gt;
&lt;property name="target" ref="myDataAccessObjectTarget" /&gt;
&lt;property name="transactionAttributes"&gt;
&lt;props&gt;
&lt;prop key="*"&gt;PROPAGATION_REQUIRES_NEW&lt;/prop&gt;
&lt;/props&gt;
&lt;/property&gt;
&lt;/bean&gt;
&lt;tx:annotation-driven&gt;
...</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
&quot;Target&quot; 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
&quot;Target&quot; 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">