diff --git a/sandbox/src/itest/java/conf/ldapAndJdbcTransactionTestContext.xml b/sandbox/src/itest/java/conf/ldapAndJdbcTransactionTestContext.xml new file mode 100644 index 00000000..316e8826 --- /dev/null +++ b/sandbox/src/itest/java/conf/ldapAndJdbcTransactionTestContext.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PROPAGATION_REQUIRES_NEW + + + + + diff --git a/sandbox/src/itest/java/conf/ldapTemplateTransactionTestContext.xml b/sandbox/src/itest/java/conf/ldapTemplateTransactionTestContext.xml index 316e8826..fef551bf 100644 --- a/sandbox/src/itest/java/conf/ldapTemplateTransactionTestContext.xml +++ b/sandbox/src/itest/java/conf/ldapTemplateTransactionTestContext.xml @@ -22,14 +22,6 @@ value="org.springframework.ldap.core.DefaultDirObjectFactory" /> - - - - - - - @@ -40,30 +32,15 @@ - - - - - - - + class="org.springframework.ldap.transaction.core.ContextSourceTransactionManager"> + class="org.springframework.ldap.transaction.core.LdapDummyDaoImpl"> - - diff --git a/sandbox/src/itest/java/org/springframework/ldap/transaction/core/ContextSourceAndDataSourceTransactionManagerIntegrationTest.java b/sandbox/src/itest/java/org/springframework/ldap/transaction/core/ContextSourceAndDataSourceTransactionManagerIntegrationTest.java index 11281cad..89348ea6 100644 --- a/sandbox/src/itest/java/org/springframework/ldap/transaction/core/ContextSourceAndDataSourceTransactionManagerIntegrationTest.java +++ b/sandbox/src/itest/java/org/springframework/ldap/transaction/core/ContextSourceAndDataSourceTransactionManagerIntegrationTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.ldap.transaction.core; import java.sql.ResultSet; @@ -54,7 +69,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends } protected String[] getConfigLocations() { - return new String[] { "conf/ldapTemplateTransactionTestContext.xml" }; + return new String[] { "conf/ldapAndJdbcTransactionTestContext.xml" }; } protected void onSetUp() throws Exception { diff --git a/sandbox/src/itest/java/org/springframework/ldap/transaction/core/ContextSourceTransactionManagerIntegrationTest.java b/sandbox/src/itest/java/org/springframework/ldap/transaction/core/ContextSourceTransactionManagerIntegrationTest.java new file mode 100644 index 00000000..3a5d4290 --- /dev/null +++ b/sandbox/src/itest/java/org/springframework/ldap/transaction/core/ContextSourceTransactionManagerIntegrationTest.java @@ -0,0 +1,284 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.ldap.transaction.core; + +import javax.naming.NamingException; +import javax.naming.directory.Attributes; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.ldap.LdapServerManager; +import org.springframework.ldap.NameNotFoundException; +import org.springframework.ldap.core.AttributesMapper; +import org.springframework.ldap.core.LdapTemplate; +import org.springframework.test.AbstractDependencyInjectionSpringContextTests; +import org.springframework.transaction.support.TransactionSynchronizationManager; + +/** + * Integration tests for {@link ContextSourceAndDataSourceTransactionManager}. + * + * @author Mattias Arthursson + */ +public class ContextSourceTransactionManagerIntegrationTest extends + AbstractDependencyInjectionSpringContextTests { + + private static Log log = LogFactory + .getLog(ContextSourceTransactionManagerIntegrationTest.class); + + public ContextSourceTransactionManagerIntegrationTest() { + setAutowireMode(AbstractDependencyInjectionSpringContextTests.AUTOWIRE_BY_NAME); + } + + private DummyDao dummyDao; + + private LdapTemplate ldapTemplate; + + private LdapServerManager ldapServerManager; + + public void setLdapServerManager(LdapServerManager ldapServerManager) { + this.ldapServerManager = ldapServerManager; + } + + public void setLdapTemplate(LdapTemplate ldapTemplate) { + this.ldapTemplate = ldapTemplate; + } + + public void setDummyDao(DummyDao dummyDaoImpl) { + this.dummyDao = dummyDaoImpl; + } + + protected String[] getConfigLocations() { + return new String[] { "conf/ldapTemplateTransactionTestContext.xml" }; + } + + protected void onSetUp() throws Exception { + if (TransactionSynchronizationManager.isSynchronizationActive()) { + TransactionSynchronizationManager.clearSynchronization(); + } + + ldapServerManager.cleanAndSetup("setup_data.ldif"); + } + + protected void onTearDown() throws Exception { + } + + public void testCreateWithException() { + try { + dummyDao.createWithException("Sweden", "company1", + "some testperson", "testperson", "some description"); + fail("DummyException expected"); + } catch (DummyException expected) { + assertTrue(true); + } + + log.debug("Verifying result"); + + // Verify that no entry was created + try { + ldapTemplate.lookup("cn=some testperson, ou=company1, c=Sweden"); + fail("NameNotFoundException expected"); + } catch (NameNotFoundException expected) { + assertTrue(true); + } + } + + public void testCreate() { + dummyDao.create("Sweden", "company1", "some testperson", "testperson", + "some description"); + + log.debug("Verifying result"); + Object ldapResult = ldapTemplate + .lookup("cn=some testperson, ou=company1, c=Sweden"); + assertNotNull(ldapResult); + } + + public void testUpdateWithException() { + String dn = "cn=Some Person,ou=company1,c=Sweden"; + try { + dummyDao.updateWithException(dn, "Some Person", "Updated Person", + "Updated description"); + fail("DummyException expected"); + } catch (DummyException expected) { + assertTrue(true); + } + + log.debug("Verifying result"); + + Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() { + public Object mapFromAttributes(Attributes attributes) + throws NamingException { + assertEquals("Person", attributes.get("sn").get()); + assertEquals("Sweden, Company1, Some Person", attributes.get( + "description").get()); + return new Object(); + } + }); + + assertNotNull(ldapResult); + } + + public void testUpdate() { + String dn = "cn=Some Person,ou=company1,c=Sweden"; + dummyDao.update(dn, "Some Person", "Updated Person", + "Updated description"); + + log.debug("Verifying result"); + Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() { + public Object mapFromAttributes(Attributes attributes) + throws NamingException { + assertEquals("Updated Person", attributes.get("sn").get()); + assertEquals("Updated description", attributes.get( + "description").get()); + return new Object(); + } + }); + + assertNotNull(ldapResult); + } + + public void testUpdateAndRenameWithException() { + String dn = "cn=Some Person2,ou=company1,c=Sweden"; + String newDn = "cn=Some Person2,ou=company2,c=Sweden"; + try { + // Perform test + dummyDao.updateAndRenameWithException(dn, newDn, + "Updated description"); + fail("DummyException expected"); + } catch (DummyException expected) { + assertTrue(true); + } + + // Verify that entry was not moved. + try { + ldapTemplate.lookup(newDn); + fail("NameNotFoundException expected"); + } catch (NameNotFoundException expected) { + assertTrue(true); + } + + // Verify that original entry was not updated. + Object object = ldapTemplate.lookup(dn, new AttributesMapper() { + public Object mapFromAttributes(Attributes attributes) + throws NamingException { + assertEquals("Sweden, Company1, Some Person2", attributes.get( + "description").get()); + return new Object(); + } + }); + assertNotNull(object); + } + + public void testUpdateAndRename() { + String dn = "cn=Some Person2,ou=company1,c=Sweden"; + String newDn = "cn=Some Person2,ou=company2,c=Sweden"; + // Perform test + dummyDao.updateAndRename(dn, newDn, "Updated description"); + + // Verify that entry was moved and updated. + Object object = ldapTemplate.lookup(newDn, new AttributesMapper() { + public Object mapFromAttributes(Attributes attributes) + throws NamingException { + assertEquals("Updated description", attributes.get( + "description").get()); + return new Object(); + } + }); + + assertNotNull(object); + } + + public void testModifyAttributesWithException() { + String dn = "cn=Some Person,ou=company1,c=Sweden"; + try { + // Perform test + dummyDao.modifyAttributesWithException(dn, "Updated lastname", + "Updated description"); + fail("DummyException expected"); + } catch (DummyException expected) { + assertTrue(true); + } + + // Verify result - check that the operation was properly rolled back + Object result = ldapTemplate.lookup(dn, new AttributesMapper() { + public Object mapFromAttributes(Attributes attributes) + throws NamingException { + assertEquals("Person", attributes.get("sn").get()); + assertEquals("Sweden, Company1, Some Person", attributes.get( + "description").get()); + return new Object(); + } + }); + + assertNotNull(result); + } + + public void testModifyAttributes() { + String dn = "cn=Some Person,ou=company1,c=Sweden"; + // Perform test + dummyDao + .modifyAttributes(dn, "Updated lastname", "Updated description"); + + // Verify result - check that the operation was not rolled back + Object result = ldapTemplate.lookup(dn, new AttributesMapper() { + public Object mapFromAttributes(Attributes attributes) + throws NamingException { + assertEquals("Updated lastname", attributes.get("sn").get()); + assertEquals("Updated description", attributes.get( + "description").get()); + return new Object(); + } + }); + + assertNotNull(result); + } + + public void testUnbindWithException() { + String dn = "cn=Some Person,ou=company1,c=Sweden"; + try { + // Perform test + dummyDao.unbindWithException(dn, "Some Person"); + fail("DummyException expected"); + } catch (DummyException expected) { + assertTrue(true); + } + + // Verify result - check that the operation was properly rolled back + Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() { + public Object mapFromAttributes(Attributes attributes) + throws NamingException { + // Just verify that the entry still exists. + return new Object(); + } + }); + + assertNotNull(ldapResult); + } + + public void testUnbind() { + String dn = "cn=Some Person,ou=company1,c=Sweden"; + // Perform test + dummyDao.unbind(dn, "Some Person"); + + try { + // Verify result - check that the operation was not rolled back + ldapTemplate.lookup(dn); + fail("NameNotFoundException expected"); + } catch (NameNotFoundException expected) { + assertTrue(true); + } + + } +} diff --git a/sandbox/src/itest/java/org/springframework/ldap/transaction/core/DummyDao.java b/sandbox/src/itest/java/org/springframework/ldap/transaction/core/DummyDao.java index 77e8e274..c6fd53b9 100644 --- a/sandbox/src/itest/java/org/springframework/ldap/transaction/core/DummyDao.java +++ b/sandbox/src/itest/java/org/springframework/ldap/transaction/core/DummyDao.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.ldap.transaction.core; public interface DummyDao { diff --git a/sandbox/src/itest/java/org/springframework/ldap/transaction/core/DummyException.java b/sandbox/src/itest/java/org/springframework/ldap/transaction/core/DummyException.java index 525688f7..4637e5d8 100644 --- a/sandbox/src/itest/java/org/springframework/ldap/transaction/core/DummyException.java +++ b/sandbox/src/itest/java/org/springframework/ldap/transaction/core/DummyException.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.ldap.transaction.core; public class DummyException extends RuntimeException { diff --git a/sandbox/src/itest/java/org/springframework/ldap/transaction/core/DummyServiceImpl.java b/sandbox/src/itest/java/org/springframework/ldap/transaction/core/DummyServiceImpl.java index b791db69..272d630e 100644 --- a/sandbox/src/itest/java/org/springframework/ldap/transaction/core/DummyServiceImpl.java +++ b/sandbox/src/itest/java/org/springframework/ldap/transaction/core/DummyServiceImpl.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.ldap.transaction.core; public class DummyServiceImpl { diff --git a/sandbox/src/itest/java/org/springframework/ldap/transaction/core/LdapAndJdbcDummyDaoImpl.java b/sandbox/src/itest/java/org/springframework/ldap/transaction/core/LdapAndJdbcDummyDaoImpl.java index 98f99e90..0b897d5b 100644 --- a/sandbox/src/itest/java/org/springframework/ldap/transaction/core/LdapAndJdbcDummyDaoImpl.java +++ b/sandbox/src/itest/java/org/springframework/ldap/transaction/core/LdapAndJdbcDummyDaoImpl.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.ldap.transaction.core; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/sandbox/src/itest/java/org/springframework/ldap/transaction/core/LdapDummyDaoImpl.java b/sandbox/src/itest/java/org/springframework/ldap/transaction/core/LdapDummyDaoImpl.java new file mode 100644 index 00000000..b7570b68 --- /dev/null +++ b/sandbox/src/itest/java/org/springframework/ldap/transaction/core/LdapDummyDaoImpl.java @@ -0,0 +1,163 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.ldap.transaction.core; + +import org.springframework.ldap.core.DirContextAdapter; +import org.springframework.ldap.core.DistinguishedName; +import org.springframework.ldap.core.LdapTemplate; + +public class LdapDummyDaoImpl implements DummyDao { + private LdapTemplate ldapTemplate; + + public void setLdapTemplate(LdapTemplate ldapTemplate) { + this.ldapTemplate = ldapTemplate; + } + + /* + * (non-Javadoc) + * + * @see org.springframework.ldap.transaction.core.DummyDao#createWithException(java.lang.String, + * java.lang.String, java.lang.String, java.lang.String, + * java.lang.String) + */ + public void createWithException(String country, String company, + String fullname, String lastname, String description) { + create(country, company, fullname, lastname, description); + throw new DummyException("This method failed"); + } + + /* + * (non-Javadoc) + * + * @see org.springframework.ldap.transaction.core.DummyDao#create(java.lang.String, + * java.lang.String, java.lang.String, java.lang.String, + * java.lang.String) + */ + public void create(String country, String company, String fullname, + String lastname, String description) { + DistinguishedName dn = new DistinguishedName(); + dn.add("c", country); + dn.add("ou", company); + dn.add("cn", fullname); + + DirContextAdapter ctx = new DirContextAdapter(); + ctx.setAttributeValues("objectclass", new String[] { "top", "person" }); + ctx.setAttributeValue("cn", fullname); + ctx.setAttributeValue("sn", lastname); + ctx.setAttributeValue("description", description); + ldapTemplate.bind(dn, ctx, null); + } + + /* + * (non-Javadoc) + * + * @see org.springframework.ldap.transaction.core.DummyDao#update(java.lang.String, + * java.lang.String, java.lang.String) + */ + public void update(String dn, String fullname, String lastname, + String description) { + DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn); + ctx.setAttributeValue("sn", lastname); + ctx.setAttributeValue("description", description); + ctx.update(); + + ldapTemplate.rebind(dn, ctx, null); + } + + /* + * (non-Javadoc) + * + * @see org.springframework.ldap.transaction.core.DummyDao#updateWithException(java.lang.String, + * java.lang.String, java.lang.String) + */ + public void updateWithException(String dn, String fullname, + String lastname, String description) { + update(dn, fullname, lastname, description); + throw new DummyException("This method failed."); + } + + /* + * (non-Javadoc) + * + * @see org.springframework.ldap.transaction.core.DummyDao#updateAndRename(java.lang.String, + * java.lang.String, java.lang.String) + */ + public void updateAndRename(String dn, String newDn, String description) { + DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn); + ctx.setAttributeValue("description", description); + ctx.update(); + + ldapTemplate.rebind(dn, ctx, null); + ldapTemplate.rename(dn, newDn); + } + + /* + * (non-Javadoc) + * + * @see org.springframework.ldap.transaction.core.DummyDao#updateAndRenameWithException(java.lang.String, + * java.lang.String, java.lang.String) + */ + public void updateAndRenameWithException(String dn, String newDn, + String description) { + updateAndRename(dn, newDn, description); + throw new DummyException("This method failed."); + } + + /* + * (non-Javadoc) + * + * @see org.springframework.ldap.transaction.core.DummyDao#modifyAttributes(java.lang.String, + * java.lang.String, java.lang.String) + */ + public void modifyAttributes(String dn, String lastName, String description) { + DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn); + ctx.setAttributeValue("sn", lastName); + ctx.setAttributeValue("description", description); + + ldapTemplate.modifyAttributes(dn, ctx.getModificationItems()); + } + + /* + * (non-Javadoc) + * + * @see org.springframework.ldap.transaction.core.DummyDao#modifyAttributesWithException(java.lang.String, + * java.lang.String, java.lang.String) + */ + public void modifyAttributesWithException(String dn, String lastName, + String description) { + modifyAttributes(dn, lastName, description); + throw new DummyException("This method failed."); + } + + /* + * (non-Javadoc) + * + * @see org.springframework.ldap.transaction.core.DummyDao#unbind(java.lang.String) + */ + public void unbind(String dn, String fullname) { + ldapTemplate.unbind(dn); + } + + /* + * (non-Javadoc) + * + * @see org.springframework.ldap.transaction.core.DummyDao#unbindWithException(java.lang.String) + */ + public void unbindWithException(String dn, String fullname) { + unbind(dn, fullname); + throw new DummyException("This operation failed."); + } +} diff --git a/sandbox/src/main/java/org/springframework/ldap/transaction/CompensatingTransactionOperationFactory.java b/sandbox/src/main/java/org/springframework/ldap/transaction/CompensatingTransactionOperationFactory.java index 5f558cbb..2864776d 100644 --- a/sandbox/src/main/java/org/springframework/ldap/transaction/CompensatingTransactionOperationFactory.java +++ b/sandbox/src/main/java/org/springframework/ldap/transaction/CompensatingTransactionOperationFactory.java @@ -1,6 +1,38 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.ldap.transaction; +/** + * Factory interface for creating + * {@link CompensatingTransactionOperationRecorder} objects based on operation + * method names. + * + * @author Mattias Arthursson + * @see DefaultCompensatingTransactionOperationManager + */ public interface CompensatingTransactionOperationFactory { + /** + * Create an appropriate {@link CompensatingTransactionOperationRecorder} + * instance corresponding to the supplied method name. + * + * @param method + * the method name to create a + * {@link CompensatingTransactionOperationRecorder} for. + * @return a new {@link CompensatingTransactionOperationRecorder} instance. + */ public CompensatingTransactionOperationRecorder createRecordingOperation( String method); } diff --git a/sandbox/src/main/java/org/springframework/ldap/transaction/CompensatingTransactionOperationRecorder.java b/sandbox/src/main/java/org/springframework/ldap/transaction/CompensatingTransactionOperationRecorder.java index 151605b9..3c715f39 100644 --- a/sandbox/src/main/java/org/springframework/ldap/transaction/CompensatingTransactionOperationRecorder.java +++ b/sandbox/src/main/java/org/springframework/ldap/transaction/CompensatingTransactionOperationRecorder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.ldap.transaction; /** diff --git a/sandbox/src/main/java/org/springframework/ldap/transaction/DefaultCompensatingTransactionOperationManager.java b/sandbox/src/main/java/org/springframework/ldap/transaction/DefaultCompensatingTransactionOperationManager.java index 74344d44..16af2734 100644 --- a/sandbox/src/main/java/org/springframework/ldap/transaction/DefaultCompensatingTransactionOperationManager.java +++ b/sandbox/src/main/java/org/springframework/ldap/transaction/DefaultCompensatingTransactionOperationManager.java @@ -37,6 +37,12 @@ public class DefaultCompensatingTransactionOperationManager implements private CompensatingTransactionOperationFactory operationFactory; + /** + * Set the {@link CompensatingTransactionOperationFactory} to use. + * + * @param operationFactory + * the {@link CompensatingTransactionOperationFactory}. + */ public DefaultCompensatingTransactionOperationManager( CompensatingTransactionOperationFactory operationFactory) { this.operationFactory = operationFactory; diff --git a/sandbox/src/main/java/org/springframework/ldap/transaction/core/ContextSourceAndDataSourceTransactionManager.java b/sandbox/src/main/java/org/springframework/ldap/transaction/core/ContextSourceAndDataSourceTransactionManager.java index fe103dfd..5f1720b4 100644 --- a/sandbox/src/main/java/org/springframework/ldap/transaction/core/ContextSourceAndDataSourceTransactionManager.java +++ b/sandbox/src/main/java/org/springframework/ldap/transaction/core/ContextSourceAndDataSourceTransactionManager.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.ldap.transaction.core; import org.springframework.jdbc.datasource.DataSourceTransactionManager; @@ -187,32 +202,4 @@ public class ContextSourceAndDataSourceTransactionManager extends "Transaction manager [" + getClass().getName() + "] does not support transaction suspension"); } - - private class DataSourceTransactionStatus extends DefaultTransactionStatus { - - public DataSourceTransactionStatus(Object transaction, - boolean newTransaction, boolean newSynchronization, - boolean readOnly, boolean debug, Object suspendedResources) { - - super(((ContextSourceAndDataSourceTransactionObject) transaction) - .getDataSourceTransactionObject(), newTransaction, - newSynchronization, readOnly, debug, suspendedResources); - } - - } - - private class ContextSourceTransactionStatus extends - DefaultTransactionStatus { - - public ContextSourceTransactionStatus(Object transaction, - boolean newTransaction, boolean newSynchronization, - boolean readOnly, boolean debug, Object suspendedResources) { - - super(((ContextSourceAndDataSourceTransactionObject) transaction) - .getLdapTransactionObject(), newTransaction, - newSynchronization, readOnly, debug, suspendedResources); - } - - } - } diff --git a/sandbox/src/main/java/org/springframework/ldap/transaction/core/ContextSourceTransactionManagerDelegate.java b/sandbox/src/main/java/org/springframework/ldap/transaction/core/ContextSourceTransactionManagerDelegate.java index 0d1f5d90..c96f436c 100644 --- a/sandbox/src/main/java/org/springframework/ldap/transaction/core/ContextSourceTransactionManagerDelegate.java +++ b/sandbox/src/main/java/org/springframework/ldap/transaction/core/ContextSourceTransactionManagerDelegate.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.ldap.transaction.core; import javax.naming.NamingException; diff --git a/sandbox/src/main/java/org/springframework/ldap/transaction/core/ContextSourceTransactionObject.java b/sandbox/src/main/java/org/springframework/ldap/transaction/core/ContextSourceTransactionObject.java index 92f538b7..3dac7d5b 100644 --- a/sandbox/src/main/java/org/springframework/ldap/transaction/core/ContextSourceTransactionObject.java +++ b/sandbox/src/main/java/org/springframework/ldap/transaction/core/ContextSourceTransactionObject.java @@ -12,7 +12,8 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */package org.springframework.ldap.transaction.core; + */ +package org.springframework.ldap.transaction.core; /** * Transaction object for ContextSourceTransactionManager. Keeps a reference to diff --git a/sandbox/src/main/java/org/springframework/ldap/transaction/core/DifferentSubtreeTempEntryRenamingStrategy.java b/sandbox/src/main/java/org/springframework/ldap/transaction/core/DifferentSubtreeTempEntryRenamingStrategy.java index 05a545c7..2191b50a 100644 --- a/sandbox/src/main/java/org/springframework/ldap/transaction/core/DifferentSubtreeTempEntryRenamingStrategy.java +++ b/sandbox/src/main/java/org/springframework/ldap/transaction/core/DifferentSubtreeTempEntryRenamingStrategy.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.ldap.transaction.core; import java.util.List; diff --git a/sandbox/src/main/java/org/springframework/ldap/transaction/core/LdapCompensatingTransactionOperationFactory.java b/sandbox/src/main/java/org/springframework/ldap/transaction/core/LdapCompensatingTransactionOperationFactory.java index 3ad98cf7..527bfa3e 100644 --- a/sandbox/src/main/java/org/springframework/ldap/transaction/core/LdapCompensatingTransactionOperationFactory.java +++ b/sandbox/src/main/java/org/springframework/ldap/transaction/core/LdapCompensatingTransactionOperationFactory.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.ldap.transaction.core; import java.lang.reflect.InvocationHandler; @@ -17,6 +32,12 @@ import org.springframework.ldap.core.LdapTemplate; import org.springframework.ldap.transaction.CompensatingTransactionOperationFactory; import org.springframework.ldap.transaction.CompensatingTransactionOperationRecorder; +/** + * {@link CompensatingTransactionOperationRecorder} implementation for LDAP + * operations. + * + * @author Mattias Arthursson + */ public class LdapCompensatingTransactionOperationFactory implements CompensatingTransactionOperationFactory { private static Log log = LogFactory