diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndDataSourceTransactionManager.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndDataSourceTransactionManager.java
index 954de962..2e021301 100644
--- a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndDataSourceTransactionManager.java
+++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndDataSourceTransactionManager.java
@@ -162,7 +162,7 @@ public class ContextSourceAndDataSourceTransactionManager extends
ldapManagerDelegate.setContextSource(contextSource);
}
- protected void setRenamingStrategy(
+ public void setRenamingStrategy(
TempEntryRenamingStrategy renamingStrategy) {
ldapManagerDelegate.setRenamingStrategy(renamingStrategy);
}
diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java
index 69060d7f..406d29fd 100755
--- a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java
+++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java
@@ -161,7 +161,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
ldapManagerDelegate.setContextSource(contextSource);
}
- protected void setRenamingStrategy(
+ public void setRenamingStrategy(
TempEntryRenamingStrategy renamingStrategy) {
ldapManagerDelegate.setRenamingStrategy(renamingStrategy);
}
diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerDelegate.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerDelegate.java
index e39de8d0..6f19f1a7 100644
--- a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerDelegate.java
+++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerDelegate.java
@@ -25,6 +25,7 @@ import org.springframework.ldap.transaction.compensating.support.DefaultTempEntr
import org.springframework.transaction.compensating.support.AbstractCompensatingTransactionManagerDelegate;
import org.springframework.transaction.compensating.support.CompensatingTransactionHolderSupport;
import org.springframework.transaction.compensating.support.DefaultCompensatingTransactionOperationManager;
+import org.springframework.util.Assert;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
@@ -48,7 +49,7 @@ public class ContextSourceTransactionManagerDelegate extends
private ContextSource contextSource;
- private TempEntryRenamingStrategy renamingStrategy = new DefaultTempEntryRenamingStrategy();
+ private TempEntryRenamingStrategy renamingStrategy;
/**
* Set the ContextSource to work on. Even though the actual ContextSource
@@ -120,9 +121,6 @@ public class ContextSourceTransactionManagerDelegate extends
}
void checkRenamingStrategy() {
- if(renamingStrategy instanceof DefaultTempEntryRenamingStrategy) {
- log.warn("Using DefaultTempEntryRenamingStrategy. This is not advised for more complex use; " +
- "see reference documentation for additional information on how to configure TempEntryRenamingStrategy.");
- }
+ Assert.notNull(renamingStrategy, "RenamingStrategy must be specified");
}
}
diff --git a/src/docbkx/transactions.xml b/src/docbkx/transactions.xml
index ef23e9c4..0f04c4c3 100644
--- a/src/docbkx/transactions.xml
+++ b/src/docbkx/transactions.xml
@@ -34,10 +34,6 @@
transaction (e.g. a modifyAttributes followed by a rebind), 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.
- 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 TempEntryRenamingStrategy, as described
- in below
@@ -45,9 +41,10 @@
Configuration
Configuring Spring LDAP transactions should look very familiar if you're used to configuring Spring transactions.
- You will create a TransactionManager instance and wrap your target object using a
- TransactionProxyFactoryBean. In addition to this, you will also need to wrap your
- ContextSource in a TransactionAwareContextSourceProxy.
+ You will annotate your transacted classes with @Transactional, create a
+ TransactionManager instance and include a <tx:annotation-driven>
+ tag in your bean configuraion. In addition to this, you will also need to wrap your ContextSource
+ in a TransactionAwareContextSourceProxy.
<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>
+
...
+ 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 TempEntryRenamingStrategy, as described
+ in below
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.
- You'll notice that the actual ContextSource 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; contextSource and myDataAccessObject
+ You'll notice that the actual ContextSource instance gets an id with a
+ "Target" suffix. The bean you will actually refer to is the Proxy that are created
+ around the target; contextSource.
diff --git a/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/LdapAndJdbcDummyDaoImpl.java b/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/LdapAndJdbcDummyDaoImpl.java
index 4839af97..c77c9909 100644
--- a/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/LdapAndJdbcDummyDaoImpl.java
+++ b/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/LdapAndJdbcDummyDaoImpl.java
@@ -20,7 +20,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.ldap.core.DirContextAdapter;
import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.core.LdapTemplate;
+import org.springframework.transaction.annotation.Transactional;
+@Transactional
public class LdapAndJdbcDummyDaoImpl implements DummyDao {
private LdapTemplate ldapTemplate;
diff --git a/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/LdapDummyDaoImpl.java b/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/LdapDummyDaoImpl.java
index a79ba781..8bc512dd 100644
--- a/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/LdapDummyDaoImpl.java
+++ b/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/LdapDummyDaoImpl.java
@@ -19,7 +19,9 @@ package org.springframework.ldap.itest.transaction.compensating.manager;
import org.springframework.ldap.core.DirContextAdapter;
import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.core.LdapTemplate;
+import org.springframework.transaction.annotation.Transactional;
+@Transactional
public class LdapDummyDaoImpl implements DummyDao {
private static final boolean RECURSIVE = true;
private LdapTemplate ldapTemplate;
diff --git a/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/DummyDaoLdapAndHibernateImpl.java b/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/DummyDaoLdapAndHibernateImpl.java
index c714c328..30ca2ac3 100755
--- a/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/DummyDaoLdapAndHibernateImpl.java
+++ b/test/integration-tests/src/main/java/org/springframework/ldap/itest/transaction/compensating/manager/hibernate/DummyDaoLdapAndHibernateImpl.java
@@ -5,9 +5,12 @@ import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.itest.transaction.compensating.manager.DummyException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+import org.springframework.transaction.annotation.Transactional;
+
/**
* @author Hans Westerbeek
*/
+@Transactional
public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements OrgPersonDao {
private LdapTemplate ldapTemplate;
diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerIntegrationTest.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerIntegrationTest.java
index 057afe50..8c2ffbb4 100644
--- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerIntegrationTest.java
+++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerIntegrationTest.java
@@ -45,7 +45,7 @@ import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
/**
- * Integration tests for {@link ContextSourceAndDataSourceTransactionManager}.
+ * Integration tests for {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager}.
*
* @author Mattias Hellborg Arthursson
*/
diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceTransactionManagerIntegrationTest.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceTransactionManagerIntegrationTest.java
index 6a340819..b0e0096a 100644
--- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceTransactionManagerIntegrationTest.java
+++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceTransactionManagerIntegrationTest.java
@@ -39,7 +39,7 @@ import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
/**
- * Integration tests for {@link ContextSourceAndDataSourceTransactionManager}.
+ * Integration tests for {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceTransactionManager}.
*
* @author Mattias Hellborg Arthursson
*/
diff --git a/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionTestContext.xml b/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionTestContext.xml
index 23819be6..02c3a9fc 100755
--- a/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionTestContext.xml
+++ b/test/integration-tests/src/test/resources/conf/ldapAndHibernateTransactionTestContext.xml
@@ -1,8 +1,8 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
@@ -57,24 +57,17 @@
class="org.springframework.ldap.transaction.compensating.manager.ContextSourceAndHibernateTransactionManager">
-
+
+
+
+
-
-
-
-
-
-
- PROPAGATION_REQUIRES_NEW
-
-
-
+
diff --git a/test/integration-tests/src/test/resources/conf/ldapAndJdbcTransactionTestContext.xml b/test/integration-tests/src/test/resources/conf/ldapAndJdbcTransactionTestContext.xml
index 68b084a4..232ba1e3 100644
--- a/test/integration-tests/src/test/resources/conf/ldapAndJdbcTransactionTestContext.xml
+++ b/test/integration-tests/src/test/resources/conf/ldapAndJdbcTransactionTestContext.xml
@@ -1,8 +1,8 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
+
+
+
-
-
-
-
-
-
- PROPAGATION_REQUIRES_NEW
-
-
-
+
diff --git a/test/integration-tests/src/test/resources/conf/ldapTemplateTransactionTestContext.xml b/test/integration-tests/src/test/resources/conf/ldapTemplateTransactionTestContext.xml
index 6ea54f03..f2cbedeb 100644
--- a/test/integration-tests/src/test/resources/conf/ldapTemplateTransactionTestContext.xml
+++ b/test/integration-tests/src/test/resources/conf/ldapTemplateTransactionTestContext.xml
@@ -1,8 +1,8 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
@@ -30,23 +30,15 @@
+
+
+
-
-
-
-
-
-
-
- PROPAGATION_REQUIRES_NEW
-
-
-
+
diff --git a/test/integration-tests/src/test/resources/conf/missingLdapAndHibernateTransactionTestContext.xml b/test/integration-tests/src/test/resources/conf/missingLdapAndHibernateTransactionTestContext.xml
index fcef7e06..289e4427 100755
--- a/test/integration-tests/src/test/resources/conf/missingLdapAndHibernateTransactionTestContext.xml
+++ b/test/integration-tests/src/test/resources/conf/missingLdapAndHibernateTransactionTestContext.xml
@@ -54,6 +54,9 @@
class="org.springframework.ldap.transaction.compensating.manager.ContextSourceAndHibernateTransactionManager">
+
+
+
diff --git a/test/integration-tests/src/test/resources/conf/missingLdapAndJdbcTransactionTestContext.xml b/test/integration-tests/src/test/resources/conf/missingLdapAndJdbcTransactionTestContext.xml
index 5ece78e9..7462ca28 100644
--- a/test/integration-tests/src/test/resources/conf/missingLdapAndJdbcTransactionTestContext.xml
+++ b/test/integration-tests/src/test/resources/conf/missingLdapAndJdbcTransactionTestContext.xml
@@ -40,6 +40,9 @@
class="org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager">
+
+
+