diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareProxyFactory.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareProxyFactory.java index 5d7b40a38..bf7e9e115 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareProxyFactory.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/transaction/TransactionAwareProxyFactory.java @@ -125,16 +125,16 @@ public class TransactionAwareProxyFactory { return factory.getProxy(); } - public static Map createTransactionalMap() { - return (Map) new TransactionAwareProxyFactory(new HashMap()).createInstance(); + public static Map createTransactionalMap() { + return (Map) new TransactionAwareProxyFactory(new HashMap()).createInstance(); } - public static Set createTransactionalSet() { - return (Set) new TransactionAwareProxyFactory(new HashSet()).createInstance(); + public static Set createTransactionalSet() { + return (Set) new TransactionAwareProxyFactory(new HashSet()).createInstance(); } - public static List createTransactionalList() { - return (List) new TransactionAwareProxyFactory(new ArrayList()).createInstance(); + public static List createTransactionalList() { + return (List) new TransactionAwareProxyFactory(new ArrayList()).createInstance(); } private class TargetSynchronization extends TransactionSynchronizationAdapter { diff --git a/spring-batch-samples/.springBeans b/spring-batch-samples/.springBeans index 1e12db2d3..3e09ee3a0 100644 --- a/spring-batch-samples/.springBeans +++ b/spring-batch-samples/.springBeans @@ -28,7 +28,6 @@ src/main/resources/jobs/retrySample.xml src/main/resources/simple-job-launcher-context.xml src/main/resources/jobs/batchUpdateJob.xml - src/test/resources/org/springframework/batch/sample/item/writer/staging-test-context.xml src/main/resources/adhoc-job-launcher-context.xml src/main/resources/alt-data-source-context.xml src/main/resources/quartz-job-launcher-context.xml @@ -40,6 +39,8 @@ src/main/resources/jobs/multiResourceJob.xml src/main/resources/jobs/jobExecutionContextSample.xml src/main/resources/hibernate-context.xml + src/main/resources/staging-test-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -50,17 +51,6 @@ src/main/resources/data-source-context.xml - - - true - false - - src/main/resources/jobs/adhocLoopJob.xml - src/main/resources/data-source-context.xml - src/main/resources/data-source-context-init.xml - src/main/resources/simple-job-launcher-context.xml - - true @@ -70,6 +60,7 @@ src/main/resources/data-source-context.xml src/main/resources/data-source-context-init.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -80,6 +71,7 @@ src/main/resources/data-source-context.xml src/main/resources/jobs/delegatingJob.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -91,6 +83,7 @@ src/main/resources/data-source-context.xml src/main/resources/data-source-context-init.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -101,6 +94,7 @@ src/main/resources/data-source-context.xml src/main/resources/jobs/footballJob.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -111,6 +105,7 @@ src/main/resources/data-source-context.xml src/main/resources/jobs/ibatisJob.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -122,6 +117,7 @@ src/main/resources/data-source-context.xml src/main/resources/data-source-context-init.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -133,6 +129,7 @@ src/main/resources/data-source-context-init.xml src/main/resources/jobs/multilineJob.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -143,6 +140,7 @@ src/main/resources/data-source-context.xml src/main/resources/jobs/parallelJob.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -154,6 +152,7 @@ src/main/resources/data-source-context-init.xml src/main/resources/jobs/restartSample.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -165,6 +164,7 @@ src/main/resources/data-source-context.xml src/main/resources/data-source-context-init.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -174,6 +174,7 @@ src/main/resources/data-source-context.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -186,6 +187,7 @@ src/main/resources/jobs/tradeJob.xml src/main/resources/jobs/tradeJobIo.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -197,6 +199,7 @@ src/main/resources/data-source-context-init.xml src/main/resources/jobs/xmlStaxJob.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -208,6 +211,7 @@ src/main/resources/data-source-context-init.xml src/main/resources/jobs/batchUpdateJob.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -216,7 +220,6 @@ false src/main/resources/data-source-context.xml - src/test/resources/org/springframework/batch/sample/item/writer/staging-test-context.xml @@ -227,6 +230,7 @@ src/main/resources/data-source-context.xml src/main/resources/quartz-job-launcher-context.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -237,6 +241,7 @@ src/main/resources/adhoc-job-launcher-context.xml src/main/resources/data-source-context.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -247,6 +252,7 @@ src/main/resources/data-source-context.xml src/main/resources/jobs/skipSampleJob.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml src/main/resources/data-source-context-init.xml src/main/resources/jobs/tradeJobIo.xml @@ -261,6 +267,7 @@ src/main/resources/jobs/multilineOrderIo.xml src/main/resources/jobs/multilineOrderJob.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml src/main/resources/jobs/multilineOrderInputTokenizers.xml src/main/resources/jobs/multilineOrderOutputAggregators.xml @@ -274,6 +281,7 @@ src/main/resources/data-source-context-init.xml src/main/resources/jobs/taskletJob.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -284,6 +292,7 @@ src/main/resources/data-source-context.xml src/main/resources/data-source-context-init.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml src/main/resources/jobs/compositeItemWriterSampleJob.xml @@ -296,6 +305,7 @@ src/main/resources/data-source-context-init.xml src/main/resources/jobs/multiResourceJob.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -307,6 +317,7 @@ src/main/resources/data-source-context-init.xml src/main/resources/jobs/jobExecutionContextSample.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml @@ -317,8 +328,21 @@ src/main/resources/data-source-context.xml src/main/resources/jobs/hibernateJob.xml src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml src/main/resources/hibernate-context.xml + + + true + false + + src/main/resources/jobs/adhocLoopJob.xml + src/main/resources/data-source-context.xml + src/main/resources/data-source-context-init.xml + src/main/resources/simple-job-launcher-context.xml + src/main/resources/org/springframework/batch/sample/config/common-context.xml + + diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/GeneratingItemReader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/GeneratingItemReader.java index 3dbd88b75..0dd67f28d 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/GeneratingItemReader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/reader/GeneratingItemReader.java @@ -3,7 +3,6 @@ package org.springframework.batch.sample.item.reader; import java.math.BigDecimal; import org.springframework.batch.item.ItemReader; -import org.springframework.batch.item.ItemRecoverer; import org.springframework.batch.item.MarkFailedException; import org.springframework.batch.item.ResetFailedException; import org.springframework.batch.sample.domain.Trade; @@ -13,7 +12,7 @@ import org.springframework.batch.sample.domain.Trade; * * @author Robert Kasanicky */ -public class GeneratingItemReader implements ItemReader, ItemRecoverer { +public class GeneratingItemReader implements ItemReader { private int limit = 1; @@ -49,13 +48,6 @@ public class GeneratingItemReader implements ItemReader, ItemRecoverer { return limit; } - /* (non-Javadoc) - * @see org.springframework.batch.item.ItemRecoverer#recover(java.lang.Object, java.lang.Throwable) - */ - public Object recover(Object data, Throwable cause) { - return data; - } - /* (non-Javadoc) * @see org.springframework.batch.item.ItemStream#mark() */ diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/writer/BatchSqlCustomerCreditIncreaseWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/writer/BatchSqlCustomerCreditIncreaseWriter.java deleted file mode 100644 index 41026b0af..000000000 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/writer/BatchSqlCustomerCreditIncreaseWriter.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.springframework.batch.sample.item.writer; - -import java.math.BigDecimal; - -import org.springframework.batch.item.ClearFailedException; -import org.springframework.batch.item.FlushFailedException; -import org.springframework.batch.item.ItemWriter; -import org.springframework.batch.item.database.BatchSqlUpdateItemWriter; -import org.springframework.batch.sample.domain.CustomerCredit; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.util.Assert; - -/** - * Increases customer's credit by fixed amount, delegating to a - * {@link BatchSqlUpdateItemWriter} to push the result out to persistent - * storage. - * - * @author Dave Syer - */ -public class BatchSqlCustomerCreditIncreaseWriter implements ItemWriter, InitializingBean { - - private ItemWriter delegate; - - public static final BigDecimal FIXED_AMOUNT = new BigDecimal(1000); - - /** - * Public setter for the {@link ItemWriter}, which must be an instance of - * {@link BatchSqlUpdateItemWriter}. - * @param delegate the delegate to set - */ - public void setDelegate(ItemWriter delegate) { - this.delegate = delegate; - } - - /* - * (non-Javadoc) - * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() - */ - public void afterPropertiesSet() throws Exception { - Assert.state(delegate instanceof BatchSqlUpdateItemWriter, "Delegate must be set and must be an instance of BatchSqlUpdateItemWriter"); - } - - /* - * (non-Javadoc) - * @see org.springframework.batch.item.processor.DelegatingItemWriter#doProcess(java.lang.Object) - */ - public void write(CustomerCredit customerCredit) throws Exception { - delegate.write(customerCredit); - } - - public void clear() throws ClearFailedException { - delegate.clear(); - } - - public void flush() throws FlushFailedException { - delegate.flush(); - } - -} diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/writer/CustomerCreditUpdatePreparedStatementSetter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/writer/CustomerCreditUpdatePreparedStatementSetter.java index 31378779d..2b9b6e2cf 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/writer/CustomerCreditUpdatePreparedStatementSetter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/item/writer/CustomerCreditUpdatePreparedStatementSetter.java @@ -15,6 +15,7 @@ */ package org.springframework.batch.sample.item.writer; +import java.math.BigDecimal; import java.sql.PreparedStatement; import java.sql.SQLException; @@ -27,12 +28,14 @@ import org.springframework.batch.sample.domain.CustomerCredit; */ public class CustomerCreditUpdatePreparedStatementSetter implements ItemPreparedStatementSetter { + public static final BigDecimal FIXED_AMOUNT = new BigDecimal(1000); + /* (non-Javadoc) * @see org.springframework.batch.io.support.ItemPreparedStatementSetter#setValues(java.lang.Object, java.sql.PreparedStatement) */ public void setValues(Object item, PreparedStatement ps) throws SQLException { CustomerCredit customerCredit = (CustomerCredit) item; - ps.setBigDecimal(1, customerCredit.getCredit()); + ps.setBigDecimal(1, customerCredit.getCredit().add(FIXED_AMOUNT)); ps.setLong(2, customerCredit.getId()); } diff --git a/spring-batch-samples/src/main/resources/jobs/batchUpdateJob.xml b/spring-batch-samples/src/main/resources/jobs/batchUpdateJob.xml index ad3e80568..aaf00bd63 100644 --- a/spring-batch-samples/src/main/resources/jobs/batchUpdateJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/batchUpdateJob.xml @@ -22,15 +22,13 @@ - - - - - - - - - + + + + + + + diff --git a/spring-batch-samples/src/main/resources/jobs/multilineOrderJob.xml b/spring-batch-samples/src/main/resources/jobs/multilineOrderJob.xml index 169f913c8..557c9c488 100644 --- a/spring-batch-samples/src/main/resources/jobs/multilineOrderJob.xml +++ b/spring-batch-samples/src/main/resources/jobs/multilineOrderJob.xml @@ -50,7 +50,7 @@ - @@ -61,7 +61,6 @@ - =0); - } - } - - /** - * Test method for - * {@link org.springframework.batch.sample.item.writer.BatchSqlCustomerCreditIncreaseWriter#write(CustomerCredit)}. - * @throws Exception - */ - @Test - public void testWrite() throws Exception { - delegate.write(customerCredit); - control.setVoidCallable(); - control.replay(); - writer.write(customerCredit); - control.verify(); - } - - /** - * Test method for - * {@link org.springframework.batch.sample.item.writer.BatchSqlCustomerCreditIncreaseWriter#clear()}. - */ - @Test - public void testClear() { - delegate.clear(); - control.setVoidCallable(); - control.replay(); - writer.clear(); - control.verify(); - } - - /** - * Test method for - * {@link org.springframework.batch.sample.item.writer.BatchSqlCustomerCreditIncreaseWriter#flush()}. - */ - @Test - public void testFlush() { - delegate.flush(); - control.setVoidCallable(); - control.replay(); - writer.flush(); - control.verify(); - } - -} diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/writer/CustomerCreditUpdatePreparedStatementSetterTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/writer/CustomerCreditUpdatePreparedStatementSetterTests.java index 3731d825c..8f98bf7a1 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/writer/CustomerCreditUpdatePreparedStatementSetterTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/item/writer/CustomerCreditUpdatePreparedStatementSetterTests.java @@ -19,10 +19,10 @@ import java.math.BigDecimal; import java.sql.PreparedStatement; import java.sql.SQLException; -import org.easymock.MockControl; -import org.springframework.batch.sample.domain.CustomerCredit; +import org.easymock.EasyMock; import org.junit.Before; import org.junit.Test; +import org.springframework.batch.sample.domain.CustomerCredit; /** * @author Dave Syer @@ -36,11 +36,9 @@ public class CustomerCreditUpdatePreparedStatementSetterTests { private PreparedStatement ps; - private MockControl control = MockControl.createControl(PreparedStatement.class); - @Before public void setUp() throws Exception { - ps = (PreparedStatement) control.getMock(); + ps = EasyMock.createMock(PreparedStatement.class); credit = new CustomerCredit(); credit.setId(13); credit.setCredit(new BigDecimal(12000)); @@ -52,13 +50,13 @@ public class CustomerCreditUpdatePreparedStatementSetterTests { */ @Test public void testSetValues() throws SQLException { - ps.setBigDecimal(1, credit.getCredit()); - control.setVoidCallable(); + ps.setBigDecimal(1, credit.getCredit().add(CustomerCreditUpdatePreparedStatementSetter.FIXED_AMOUNT)); + EasyMock.expectLastCall(); ps.setLong(2, credit.getId()); - control.setVoidCallable(); - control.replay(); + EasyMock.expectLastCall(); + EasyMock.replay(ps); setter.setValues(credit, ps); - control.verify(); + EasyMock.verify(ps); } }