From fad398f0690764f683512d1a6dc21f9ba2034306 Mon Sep 17 00:00:00 2001 From: dsyer Date: Tue, 5 Feb 2008 08:08:02 +0000 Subject: [PATCH] Build carnage - thank you Lucas --- .../batch/core/domain/StepInstanceTests.java | 2 -- .../SimpleExportedJobLauncherTests.java | 1 - .../repository/SimpleJobRepositoryTests.java | 1 - .../repository/dao/AbstractStepDaoTests.java | 1 - .../repository/dao/MapStepDaoTests.java | 1 - .../batch/io/cursor/JdbcCursorItemReader.java | 3 +- .../item/ExecutionAttributesProvider.java | 32 +++++++++++++++++++ .../item/stream/SimpleStreamManager.java | 3 +- .../driving/DrivingQueryItemReaderTests.java | 3 +- .../ColumnMapRestartDataRowMapperTests.java | 1 - ...olumnJdbcKeyGeneratorIntegrationTests.java | 1 - ...olumnJdbcKeyGeneratorIntegrationTests.java | 3 +- ...bstractJdbcItemReaderIntegrationTests.java | 1 - ...tDataSourceItemReaderIntegrationTests.java | 1 - .../item/stream/SimpleStreamManagerTests.java | 11 +++---- 15 files changed, 41 insertions(+), 24 deletions(-) create mode 100644 spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionAttributesProvider.java diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepInstanceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepInstanceTests.java index f8260eb91..11e9c912c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepInstanceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/domain/StepInstanceTests.java @@ -18,8 +18,6 @@ package org.springframework.batch.core.domain; import junit.framework.TestCase; import org.springframework.batch.item.ExecutionAttributes; -import org.springframework.batch.item.StreamContext; -import org.springframework.batch.support.PropertiesConverter; /** * @author Dave Syer diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleExportedJobLauncherTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleExportedJobLauncherTests.java index b18e419ae..2f2efe03e 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleExportedJobLauncherTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/bootstrap/support/SimpleExportedJobLauncherTests.java @@ -33,7 +33,6 @@ import org.springframework.batch.core.runtime.JobParametersFactory; import org.springframework.batch.execution.configuration.MapJobRegistry; import org.springframework.batch.execution.launch.JobLauncher; import org.springframework.batch.item.ExecutionAttributes; -import org.springframework.batch.item.StreamContext; import org.springframework.batch.support.PropertiesConverter; /** diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java index b45e3a207..0141ed2de 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/SimpleJobRepositoryTests.java @@ -38,7 +38,6 @@ import org.springframework.batch.core.repository.BatchRestartException; import org.springframework.batch.execution.repository.dao.JobDao; import org.springframework.batch.execution.repository.dao.StepDao; import org.springframework.batch.item.ExecutionAttributes; -import org.springframework.batch.item.StreamContext; /* * Test SimpleJobRepository. The majority of test cases are tested using EasyMock, diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java index ef5fcc5de..52b950459 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/AbstractStepDaoTests.java @@ -30,7 +30,6 @@ import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; import org.springframework.batch.core.runtime.ExitCodeExceptionClassifier; import org.springframework.batch.item.ExecutionAttributes; -import org.springframework.batch.item.stream.GenericStreamContext; import org.springframework.batch.repeat.ExitStatus; import org.springframework.batch.support.PropertiesConverter; import org.springframework.dao.OptimisticLockingFailureException; diff --git a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapStepDaoTests.java b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapStepDaoTests.java index 125b545e7..d9269906f 100644 --- a/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapStepDaoTests.java +++ b/spring-batch-execution/src/test/java/org/springframework/batch/execution/repository/dao/MapStepDaoTests.java @@ -28,7 +28,6 @@ import org.springframework.batch.core.domain.StepExecution; import org.springframework.batch.core.domain.StepInstance; import org.springframework.batch.execution.repository.dao.MapStepDao; import org.springframework.batch.item.ExecutionAttributes; -import org.springframework.batch.item.stream.GenericStreamContext; public class MapStepDaoTests extends TestCase { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/cursor/JdbcCursorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/cursor/JdbcCursorItemReader.java index b7fe7b3dd..b527c7a96 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/cursor/JdbcCursorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/io/cursor/JdbcCursorItemReader.java @@ -33,7 +33,6 @@ import org.springframework.batch.io.support.AbstractTransactionalIoSource; import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.KeyedItemReader; import org.springframework.batch.item.ExecutionAttributes; -import org.springframework.batch.item.stream.GenericStreamContext; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.dao.DataAccessException; @@ -393,7 +392,7 @@ public class JdbcCursorItemReader extends AbstractTransactionalIoSource implemen */ public ExecutionAttributes getStreamContext() { String skipped = skippedRows.toString(); - ExecutionAttributes context = new GenericStreamContext(); + ExecutionAttributes context = new ExecutionAttributes(); context.putString(SKIPPED_ROWS, skipped.substring(1, skipped.length() - 1)); context.putLong(CURRENT_PROCESSED_ROW, currentProcessedRow); context.putLong(SKIP_COUNT, skipCount); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionAttributesProvider.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionAttributesProvider.java new file mode 100644 index 000000000..d9991fd01 --- /dev/null +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionAttributesProvider.java @@ -0,0 +1,32 @@ +/* + * Copyright 2006-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.batch.item; + +/** + * @author Dave Syer + * + */ +public interface ExecutionAttributesProvider { + + /** + * Get {@link ExecutionAttributes} representing this object's current state. + * Should not return null even if there is no state. + * + * @return {@link ExecutionAttributes} representing current state. + */ + ExecutionAttributes getExecutionAttributes(); + +} diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/SimpleStreamManager.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/SimpleStreamManager.java index add7b6a90..f73ab1307 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/SimpleStreamManager.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/stream/SimpleStreamManager.java @@ -23,9 +23,8 @@ import java.util.Map; import java.util.Set; import java.util.Map.Entry; -import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.ExecutionAttributes; -import org.springframework.batch.item.StreamContext; +import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.StreamException; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionStatus; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/DrivingQueryItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/DrivingQueryItemReaderTests.java index f5c027de6..c59ef28e2 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/DrivingQueryItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/DrivingQueryItemReaderTests.java @@ -10,7 +10,6 @@ import org.springframework.batch.io.sample.domain.Foo; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.ExecutionAttributes; -import org.springframework.batch.item.stream.GenericStreamContext; import org.springframework.beans.factory.InitializingBean; import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.util.Assert; @@ -118,7 +117,7 @@ public class DrivingQueryItemReaderTests extends TestCase { * @throws Exception */ public void testRestoreFromEmptyData() throws Exception { - ExecutionAttributes streamContext = new GenericStreamContext(new Properties()); + ExecutionAttributes streamContext = new ExecutionAttributes(new Properties()); getAsRestartable(source).restoreFrom(streamContext); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/ColumnMapRestartDataRowMapperTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/ColumnMapRestartDataRowMapperTests.java index 43db8d3fc..6502a1372 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/ColumnMapRestartDataRowMapperTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/ColumnMapRestartDataRowMapperTests.java @@ -12,7 +12,6 @@ import junit.framework.TestCase; import org.easymock.MockControl; import org.springframework.batch.item.ExecutionAttributes; -import org.springframework.batch.item.stream.GenericStreamContext; import org.springframework.core.CollectionFactory; import org.springframework.jdbc.core.PreparedStatementSetter; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/MultipleColumnJdbcKeyGeneratorIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/MultipleColumnJdbcKeyGeneratorIntegrationTests.java index aa1a66f90..63dfdd3b7 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/MultipleColumnJdbcKeyGeneratorIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/MultipleColumnJdbcKeyGeneratorIntegrationTests.java @@ -8,7 +8,6 @@ import java.util.Map; import java.util.Properties; import org.springframework.batch.item.ExecutionAttributes; -import org.springframework.batch.item.stream.GenericStreamContext; import org.springframework.core.CollectionFactory; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/SingleColumnJdbcKeyGeneratorIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/SingleColumnJdbcKeyGeneratorIntegrationTests.java index 1f5237cfd..5f6735d5c 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/SingleColumnJdbcKeyGeneratorIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/driving/support/SingleColumnJdbcKeyGeneratorIntegrationTests.java @@ -4,7 +4,6 @@ import java.util.List; import java.util.Properties; import org.springframework.batch.item.ExecutionAttributes; -import org.springframework.batch.item.stream.GenericStreamContext; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; /** @@ -44,7 +43,7 @@ public class SingleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTransa Properties props = new Properties(); props.setProperty(SingleColumnJdbcKeyGenerator.RESTART_KEY, "3"); - ExecutionAttributes streamContext = new GenericStreamContext(props); + ExecutionAttributes streamContext = new ExecutionAttributes(props); List keys = keyStrategy.restoreKeys(streamContext); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/sql/AbstractJdbcItemReaderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/sql/AbstractJdbcItemReaderIntegrationTests.java index 4794971ee..060fba2d3 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/sql/AbstractJdbcItemReaderIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/sql/AbstractJdbcItemReaderIntegrationTests.java @@ -4,7 +4,6 @@ import org.springframework.batch.io.sample.domain.Foo; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.ExecutionAttributes; -import org.springframework.batch.item.stream.GenericStreamContext; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/support/AbstractDataSourceItemReaderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/support/AbstractDataSourceItemReaderIntegrationTests.java index 8bc3d28ca..d28e7a8d4 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/support/AbstractDataSourceItemReaderIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/io/support/AbstractDataSourceItemReaderIntegrationTests.java @@ -5,7 +5,6 @@ import org.springframework.batch.io.sample.domain.Foo; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.ExecutionAttributes; -import org.springframework.batch.item.stream.GenericStreamContext; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/stream/SimpleStreamManagerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/stream/SimpleStreamManagerTests.java index e5bc319a8..51b0bdf60 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/stream/SimpleStreamManagerTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/stream/SimpleStreamManagerTests.java @@ -21,7 +21,6 @@ import java.util.List; import junit.framework.TestCase; import org.springframework.batch.item.ExecutionAttributes; -import org.springframework.batch.item.StreamContext; import org.springframework.batch.item.StreamException; import org.springframework.batch.support.PropertiesConverter; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; @@ -176,7 +175,7 @@ public class SimpleStreamManagerTests extends TestCase { return true; } - public void mark(StreamContext streamContext) { + public void mark(ExecutionAttributes streamContext) { list.add("bar"); } }, null); @@ -191,7 +190,7 @@ public class SimpleStreamManagerTests extends TestCase { */ public void testCommitWithoutMark() { manager.register("foo", new ItemStreamAdapter() { - public void mark(StreamContext streamContext) { + public void mark(ExecutionAttributes streamContext) { list.add("bar"); } }, null); @@ -210,7 +209,7 @@ public class SimpleStreamManagerTests extends TestCase { return true; } - public void reset(StreamContext streamContext) { + public void reset(ExecutionAttributes streamContext) { list.add("bar"); } }, null); @@ -225,7 +224,7 @@ public class SimpleStreamManagerTests extends TestCase { */ public void testRollbackWithoutMark() { manager.register("foo", new ItemStreamAdapter() { - public void reset(StreamContext streamContext) { + public void reset(ExecutionAttributes streamContext) { list.add("bar"); } }, null); @@ -239,7 +238,7 @@ public class SimpleStreamManagerTests extends TestCase { return new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=bar")); } - public void restoreFrom(StreamContext context) { + public void restoreFrom(ExecutionAttributes context) { list.add(context.getString("foo")); } }