From 96c818e86ffb176ce408bb793dda34da50e17457 Mon Sep 17 00:00:00 2001 From: Michael Minella Date: Mon, 31 Dec 2012 08:10:08 -0600 Subject: [PATCH] BATCH-1915: Reformatting --- dictionary.txt | 1 + .../springframework/batch/core/Entity.java | 17 +- .../batch/core/ExitStatus.java | 41 ++-- .../batch/core/JobExecution.java | 37 ++-- .../batch/core/JobExecutionListener.java | 10 +- .../batch/core/JobInstance.java | 13 +- .../batch/core/JobParameter.java | 15 +- .../batch/core/StepContribution.java | 21 ++- .../batch/core/StepExecution.java | 77 ++++---- .../batch/core/StepExecutionListener.java | 12 +- .../annotation/ModularBatchConfiguration.java | 8 +- .../annotation/SimpleBatchConfiguration.java | 14 +- .../support/ApplicationContextJobFactory.java | 18 +- .../support/DefaultJobLoader.java | 178 +++++++++--------- .../configuration/support/GroupAwareJob.java | 32 ++-- .../support/JobRegistryBeanPostProcessor.java | 32 ++-- .../configuration/support/MapJobRegistry.java | 86 ++++----- .../support/MapStepRegistry.java | 99 +++++----- ...sgiBundleXmlApplicationContextFactory.java | 26 +-- .../support/ReferenceJobFactory.java | 16 +- .../xml/CoreNamespaceHandler.java | 8 +- .../xml/CoreNamespacePostProcessor.java | 18 +- .../xml/JobExecutionListenerParser.java | 8 +- .../xml/JobParserJobFactoryBean.java | 20 +- .../xml/SimpleFlowFactoryBean.java | 52 +++-- .../configuration/xml/StepListenerParser.java | 12 +- .../xml/StepParserStepFactoryBean.java | 69 +++---- .../DefaultJobParametersConverter.java | 32 ++-- .../AbstractJobExplorerFactoryBean.java | 15 +- .../support/JobExplorerFactoryBean.java | 8 +- .../support/MapJobExplorerFactoryBean.java | 10 +- .../explore/support/SimpleJobExplorer.java | 34 ++-- .../batch/core/job/AbstractJob.java | 72 +++---- .../job/CompositeJobParametersValidator.java | 20 +- .../job/DefaultJobParametersValidator.java | 39 ++-- .../batch/core/job/SimpleJob.java | 24 +-- .../batch/core/job/SimpleStepHandler.java | 18 +- .../core/job/builder/JobFlowBuilder.java | 6 +- .../batch/core/job/flow/FlowExecution.java | 8 +- .../core/job/flow/FlowExecutionStatus.java | 12 +- .../batch/core/job/flow/JobFlowExecutor.java | 26 +-- .../core/job/flow/support/SimpleFlow.java | 28 +-- .../job/flow/support/StateTransition.java | 24 +-- .../job/flow/support/state/AbstractState.java | 14 +- .../job/flow/support/state/DecisionState.java | 8 +- .../core/job/flow/support/state/EndState.java | 14 +- .../job/flow/support/state/FlowState.java | 12 +- .../MaxValueFlowExecutionAggregator.java | 8 +- .../job/flow/support/state/SplitState.java | 16 +- .../job/flow/support/state/StepState.java | 10 +- .../JobRegistryBackgroundJobRunner.java | 32 ++-- .../core/launch/support/JvmSystemExiter.java | 10 +- .../core/launch/support/RunIdIncrementer.java | 14 +- .../support/RuntimeExceptionTranslator.java | 4 +- .../ScheduledJobParametersFactory.java | 16 +- .../launch/support/SimpleJobLauncher.java | 22 +-- .../launch/support/SimpleJobOperator.java | 86 ++++----- .../support/SimpleJvmExitCodeMapper.java | 6 +- .../listener/AbstractListenerFactoryBean.java | 19 +- .../core/listener/ChunkListenerSupport.java | 8 +- .../core/listener/CompositeChunkListener.java | 16 +- .../CompositeItemProcessListener.java | 14 +- .../listener/CompositeItemReadListener.java | 14 +- .../listener/CompositeItemWriteListener.java | 14 +- .../CompositeJobExecutionListener.java | 12 +- .../core/listener/CompositeSkipListener.java | 14 +- .../CompositeStepExecutionListener.java | 16 +- .../ExecutionContextPromotionListener.java | 14 +- .../core/listener/ItemListenerSupport.java | 42 ++--- .../listener/JobExecutionListenerSupport.java | 6 +- .../core/listener/JobListenerFactoryBean.java | 16 +- .../core/listener/JobListenerMetaData.java | 28 +-- .../MethodInvokerMethodInterceptor.java | 8 +- .../listener/MulticasterBatchListener.java | 36 ++-- .../core/listener/SkipListenerSupport.java | 10 +- .../StepExecutionListenerSupport.java | 6 +- .../listener/StepListenerFactoryBean.java | 16 +- .../core/listener/StepListenerMetaData.java | 28 +-- .../core/listener/StepListenerSupport.java | 38 ++-- .../support/AbstractPartitionHandler.java | 66 +++---- .../DefaultStepExecutionAggregator.java | 6 +- .../support/MultiResourcePartitioner.java | 8 +- .../core/partition/support/PartitionStep.java | 16 +- .../RemoteStepExecutionAggregator.java | 12 +- .../partition/support/SimplePartitioner.java | 6 +- .../support/SimpleStepExecutionSplitter.java | 30 +-- .../support/TaskExecutorPartitionHandler.java | 8 +- .../dao/AbstractJdbcBatchMetadataDao.java | 16 +- .../DefaultExecutionContextSerializer.java | 19 +- .../dao/JdbcExecutionContextDao.java | 19 +- .../repository/dao/JdbcJobExecutionDao.java | 48 ++--- .../repository/dao/JdbcJobInstanceDao.java | 69 +++---- .../repository/dao/JdbcStepExecutionDao.java | 46 ++--- .../dao/MapExecutionContextDao.java | 55 ++++-- .../repository/dao/MapJobExecutionDao.java | 24 ++- .../repository/dao/MapJobInstanceDao.java | 18 +- .../repository/dao/MapStepExecutionDao.java | 14 +- ...treamExecutionContextStringSerializer.java | 9 +- .../AbstractJobRepositoryFactoryBean.java | 27 +-- .../support/SimpleJobRepository.java | 42 ++--- .../resource/ListPreparedStatementSetter.java | 14 +- .../StepExecutionSimpleCompletionPolicy.java | 22 +-- .../batch/core/scope/StepScope.java | 57 +++--- .../context/StepContextRepeatCallback.java | 16 +- .../util/PlaceholderProxyFactoryBean.java | 19 +- .../core/scope/util/StepContextFactory.java | 10 +- .../batch/core/step/AbstractStep.java | 44 ++--- .../NoWorkFoundStepExecutionListener.java | 6 +- .../core/step/StepLocatorStepFactoryBean.java | 31 ++- .../step/ThreadStepInterruptionPolicy.java | 8 +- .../builder/FaultTolerantStepBuilder.java | 59 +++--- .../factory/FaultTolerantStepFactoryBean.java | 46 +++-- .../step/factory/SimpleStepFactoryBean.java | 47 ++--- .../core/step/item/BatchRetryTemplate.java | 23 +-- .../batch/core/step/item/Chunk.java | 28 +-- .../batch/core/step/item/ChunkMonitor.java | 14 +- .../core/step/item/ChunkOrientedTasklet.java | 10 +- .../item/FaultTolerantChunkProcessor.java | 30 +-- .../core/step/item/SimpleChunkProcessor.java | 36 ++-- .../core/step/item/SimpleChunkProvider.java | 8 +- .../item/SimpleRetryExceptionHandler.java | 26 +-- .../job/DefaultJobParametersExtractor.java | 12 +- .../step/skip/AlwaysSkipItemSkipPolicy.java | 6 +- .../core/step/skip/CompositeSkipPolicy.java | 8 +- .../skip/ExceptionClassifierSkipPolicy.java | 14 +- .../skip/LimitCheckingItemSkipPolicy.java | 18 +- .../step/skip/NeverSkipItemSkipPolicy.java | 6 +- .../step/tasklet/CallableTaskletAdapter.java | 12 +- ...nfigurableSystemProcessExitCodeMapper.java | 16 +- .../tasklet/MethodInvokingTaskletAdapter.java | 14 +- .../SimpleSystemProcessExitCodeMapper.java | 8 +- .../step/tasklet/SystemCommandTasklet.java | 20 +- .../batch/core/step/tasklet/TaskletStep.java | 51 ++--- .../core/JobExecutionExceptionTests.java | 6 +- .../core/JobInterruptedExceptionTests.java | 6 +- .../DuplicateJobExceptionTests.java | 9 +- .../ApplicationContextJobFactoryTests.java | 8 +- .../JobFactoryRegistrationListenerTests.java | 16 +- .../xml/DecisionJobParserTests.java | 6 +- .../xml/DummyCompletionPolicy.java | 8 +- .../configuration/xml/DummyItemProcessor.java | 2 +- .../configuration/xml/DummyItemReader.java | 2 +- .../configuration/xml/DummyItemWriter.java | 2 +- .../configuration/xml/DummyJobRepository.java | 24 +-- .../xml/DummyPlatformTransactionManager.java | 10 +- .../configuration/xml/DummyRetryListener.java | 6 +- .../core/configuration/xml/DummyStep.java | 12 +- .../core/configuration/xml/DummyTasklet.java | 2 +- .../configuration/xml/FailingTasklet.java | 6 +- .../xml/FlowStepParserTests.java | 6 +- .../xml/InterruptibleTasklet.java | 8 +- .../xml/JobRegistryJobParserTests.java | 10 +- .../configuration/xml/NameStoringTasklet.java | 8 +- .../xml/PartitionStepParserTests.java | 24 ++- .../xml/PartitionStepWithFlowParserTests.java | 8 +- .../xml/SplitInterruptedJobParserTests.java | 8 +- .../configuration/xml/StopJobParserTests.java | 6 +- .../xml/TestCustomStatusListener.java | 6 +- .../configuration/xml/TestIncrementer.java | 2 +- .../core/configuration/xml/TestListener.java | 8 +- .../core/configuration/xml/TestProcessor.java | 2 +- .../core/configuration/xml/TestReader.java | 8 +- .../configuration/xml/TestRetryListener.java | 6 +- .../core/configuration/xml/TestTasklet.java | 10 +- .../core/configuration/xml/TestWriter.java | 2 +- .../MapJobExplorerIntegrationTests.java | 7 +- .../core/job/ExtendedAbstractJobTests.java | 20 +- .../batch/core/job/JobSupport.java | 70 +++---- .../batch/core/job/SimpleJobTests.java | 32 ++-- .../core/job/SimpleStepHandlerTests.java | 6 +- .../core/job/builder/FlowJobBuilderTests.java | 10 +- .../batch/core/job/flow/FlowJobTests.java | 14 +- .../batch/core/job/flow/FlowStepTests.java | 8 +- .../batch/core/job/flow/StateSupport.java | 10 +- .../flow/support/JobFlowExecutorSupport.java | 28 +-- .../batch/core/launch/EmptyItemWriter.java | 6 +- .../JobExecutionNotFailedExceptionTests.java | 6 +- ...obInstanceAlreadyExistsExceptionTests.java | 7 +- .../JobParametersNotFoundExceptionTests.java | 6 +- .../NoSuchJobExecutionExceptionTests.java | 7 +- .../NoSuchJobInstanceExceptionTests.java | 7 +- .../core/launch/SimpleJobLauncherTests.java | 12 +- .../support/CommandLineJobRunnerTests.java | 58 +++--- .../ScheduledJobParametersFactoryTests.java | 9 +- .../support/SimpleJobOperatorTests.java | 73 +++---- .../support/SimpleJvmExitCodeMapperTests.java | 30 ++- .../core/launch/support/StubJobLauncher.java | 2 +- .../support/TestJobParametersIncrementer.java | 2 +- .../CompositeJobExecutionListenerTests.java | 12 +- .../CompositeStepExecutionListenerTests.java | 12 +- .../listener/JobListenerFactoryBeanTests.java | 16 +- .../core/listener/OrderedCompositeTests.java | 16 +- .../StepListenerFactoryBeanTests.java | 33 ++-- .../StepListenerMethodInterceptorTests.java | 42 ++--- .../core/partition/ExampleItemReader.java | 8 +- .../core/partition/ExampleItemWriter.java | 6 +- .../core/partition/MinMaxPartitioner.java | 12 +- .../partition/support/PartitionStepTests.java | 14 +- .../SimpleStepExecutionSplitterTests.java | 14 +- .../TaskExecutorPartitionHandlerTests.java | 8 +- ...ExecutionAlreadyRunningExceptionTests.java | 6 +- ...InstanceAlreadyCompleteExceptionTests.java | 6 +- .../repository/JobRestartExceptionTests.java | 8 +- .../repository/dao/JdbcJobDaoQueryTests.java | 14 +- .../dao/JdbcJobInstanceDaoTests.java | 12 +- .../dao/JdbcStepExecutionDaoTests.java | 12 +- .../dao/MapJobExecutionDaoTests.java | 29 +-- .../dao/MapJobInstanceDaoTests.java | 2 +- .../dao/MapStepExecutionDaoTests.java | 50 ++--- .../core/repository/dao/TablePrefixTests.java | 6 +- .../JobRepositoryFactoryBeanTests.java | 8 +- .../SimpleJobRepositoryProxyTests.java | 4 +- .../batch/core/resource/Foo.java | 47 +++-- .../batch/core/resource/FooRowMapper.java | 19 +- .../ListPreparedStatementSetterTests.java | 20 +- ...pExecutionSimpleCompletionPolicyTests.java | 8 +- .../scope/AsyncStepScopeIntegrationTests.java | 6 +- .../batch/core/scope/JobStartupRunner.java | 6 +- .../scope/StepScopeClassIntegrationTests.java | 2 +- .../core/scope/StepScopePerformanceTests.java | 4 +- .../StepScopePlaceholderIntegrationTests.java | 2 +- ...ScopeProxyTargetClassIntegrationTests.java | 2 +- .../batch/core/scope/StepScopeTests.java | 20 +- .../batch/core/scope/TestCollaborator.java | 11 +- .../scope/TestDisposableCollaborator.java | 3 +- .../batch/core/scope/TestStep.java | 8 +- .../core/scope/context/StepContextTests.java | 13 +- .../StepSynchronizationManagerTests.java | 6 +- .../AsyncPlaceholderTargetSourceTests.java | 8 +- .../scope/util/ContextFactorySupport.java | 8 +- ...leContextPlaceholderTargetSourceTests.java | 12 +- ...ceholderTargetSourceCustomEditorTests.java | 4 +- .../PlaceholderTargetSourceErrorTests.java | 16 +- .../util/PlaceholderTargetSourceTests.java | 18 +- .../SimplePlaceholderTargetSourceTests.java | 22 +-- .../batch/core/step/JobRepositorySupport.java | 22 +-- .../batch/core/step/NonAbstractStepTests.java | 13 +- .../step/StepLocatorStepFactoryBeanTests.java | 94 ++++----- .../batch/core/step/StepSupport.java | 32 ++-- .../core/step/builder/StepBuilderTests.java | 4 +- .../step/item/BatchRetryTemplateTests.java | 13 +- .../core/step/item/ChunkMonitorTests.java | 14 +- .../step/item/ChunkOrientedTaskletTests.java | 22 +-- .../item/ExceptionThrowingTaskletStub.java | 6 +- .../FaultTolerantChunkProcessorTests.java | 37 ++-- .../item/FaultTolerantChunkProviderTests.java | 2 +- .../FaultTolerantExceptionClassesTests.java | 6 +- ...erantStepFactoryBeanNonBufferingTests.java | 2 +- ...aultTolerantStepFactoryBeanRetryTests.java | 64 +++---- ...tTolerantStepFactoryBeanRollbackTests.java | 20 +- .../FaultTolerantStepFactoryBeanTests.java | 106 ++++++----- ...tepFactoryBeanUnexpectedRollbackTests.java | 5 +- .../RepeatOperationsStepFactoryBeanTests.java | 8 +- .../step/item/SimpleChunkProcessorTests.java | 4 +- .../SimpleRetryExceptionHandlerTests.java | 12 +- .../step/item/SimpleStepFactoryBeanTests.java | 52 ++--- .../core/step/item/SkipProcessorStub.java | 4 +- .../batch/core/step/item/SkipReaderStub.java | 4 +- .../batch/core/step/item/SkipWriterStub.java | 4 +- .../step/item/TaskletStepExceptionTests.java | 54 +++--- ...syncChunkOrientedStepIntegrationTests.java | 12 +- .../step/tasklet/AsyncTaskletStepTests.java | 6 +- .../tasklet/CallableTaskletAdapterTests.java | 8 +- .../ChunkOrientedStepIntegrationTests.java | 25 +-- .../StepExecutorInterruptionTests.java | 16 +- .../SystemCommandTaskletIntegrationTests.java | 2 +- .../core/step/tasklet/TaskletStepTests.java | 93 ++++----- .../config/DummyNamespaceHandler.java | 16 +- .../datasource/DataSourceInitializer.java | 23 +-- .../batch/item/ExecutionContext.java | 67 +++---- .../batch/item/ItemStreamSupport.java | 4 +- .../AbstractMethodInvokingDelegator.java | 15 +- .../item/adapter/ItemProcessorAdapter.java | 8 +- .../batch/item/adapter/ItemReaderAdapter.java | 6 +- .../batch/item/adapter/ItemWriterAdapter.java | 22 +-- ...ropertyExtractingDelegatingItemWriter.java | 12 +- .../batch/item/amqp/AmqpItemReader.java | 48 ++--- .../database/AbstractCursorItemReader.java | 166 ++++++++-------- .../database/AbstractPagingItemReader.java | 12 +- ...ropertyItemSqlParameterSourceProvider.java | 8 +- .../ExtendedConnectionDataSourceProxy.java | 44 ++--- .../database/HibernateCursorItemReader.java | 38 ++-- .../database/HibernateItemReaderHelper.java | 18 +- .../item/database/HibernateItemWriter.java | 22 +-- .../database/HibernatePagingItemReader.java | 26 +-- .../item/database/IbatisBatchItemWriter.java | 40 ++-- .../item/database/IbatisPagingItemReader.java | 26 +-- .../item/database/JdbcBatchItemWriter.java | 36 ++-- .../item/database/JdbcCursorItemReader.java | 40 ++-- .../batch/item/database/JpaItemWriter.java | 22 +-- .../item/database/JpaPagingItemReader.java | 22 +-- .../database/StoredProcedureItemReader.java | 71 +++---- .../orm/AbstractHibernateQueryProvider.java | 46 ++--- .../orm/AbstractJpaQueryProvider.java | 12 +- 294 files changed, 3154 insertions(+), 3034 deletions(-) diff --git a/dictionary.txt b/dictionary.txt index c97425432..90d2baced 100644 --- a/dictionary.txt +++ b/dictionary.txt @@ -93,3 +93,4 @@ proxied payloads unflushed memento +michael diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/Entity.java b/spring-batch-core/src/main/java/org/springframework/batch/core/Entity.java index 2d26a4a22..53cd33e1b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/Entity.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/Entity.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -25,11 +25,12 @@ import org.springframework.util.ClassUtils; * from another should subclass from Entity. More information on this pattern * and the difference between Entities and Value Objects can be found in Domain * Driven Design by Eric Evans. - * + * * @author Lucas Ward * @author Dave Syer - * + * */ +@SuppressWarnings("serial") public class Entity implements Serializable { private Long id; @@ -42,7 +43,7 @@ public class Entity implements Serializable { public Entity(Long id) { super(); - + //Commented out because StepExecutions are still created in a disconnected //manner. The Repository should create them, then this can be uncommented. //Assert.notNull(id, "Entity id must not be null."); @@ -63,7 +64,7 @@ public class Entity implements Serializable { public Integer getVersion() { return version; } - + /** * Public setter for the version needed only by repository methods. * @param version the version to set @@ -91,7 +92,7 @@ public class Entity implements Serializable { /** * Attempt to establish identity based on id if both exist. If either id * does not exist use Object.equals(). - * + * * @see java.lang.Object#equals(java.lang.Object) */ @Override @@ -121,10 +122,10 @@ public class Entity implements Serializable { * {@link Entity} after it is saved. Spring Batch does not store any of its * entities in Sets as a matter of course, so internally this is consistent. * Clients should not be exposed to unsaved entities. - * + * * @see java.lang.Object#hashCode() */ - @Override + @Override public int hashCode() { if (id == null) { return super.hashCode(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/ExitStatus.java b/spring-batch-core/src/main/java/org/springframework/batch/core/ExitStatus.java index d0dc8980f..66225cdef 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/ExitStatus.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/ExitStatus.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -24,12 +24,13 @@ import org.springframework.util.StringUtils; /** * Value object used to carry information about the status of a * job or step execution. - * + * * ExitStatus is immutable and therefore thread-safe. - * + * * @author Dave Syer - * + * */ +@SuppressWarnings("serial") public class ExitStatus implements Serializable, Comparable { /** @@ -85,7 +86,7 @@ public class ExitStatus implements Serializable, Comparable { /** * Getter for the exit code (defaults to blank). - * + * * @return the exit code. */ public String getExitCode() { @@ -106,7 +107,7 @@ public class ExitStatus implements Serializable, Comparable { * case of equal severity, the exit code is replaced if the new value is * alphabetically greater.
*
- * + * * Severity is defined by the exit code: *
    *
  • Codes beginning with EXECUTING have severity 1
  • @@ -117,9 +118,9 @@ public class ExitStatus implements Serializable, Comparable { *
  • Codes beginning with UNKNOWN have severity 6
  • *
* Others have severity 7, so custom exit codes always win.
- * + * * If the input is null just return this. - * + * * @param status an {@link ExitStatus} to combine with this one. * @return a new {@link ExitStatus} combining the current value and the * argument provided. @@ -134,12 +135,12 @@ public class ExitStatus implements Serializable, Comparable { } return result; } - + /** * @param status an {@link ExitStatus} to compare * @return 1,0,-1 according to the severity and exit code */ - @Override + @Override public int compareTo(ExitStatus status) { if (severity(status) > severity(this)) { return -1; @@ -178,20 +179,20 @@ public class ExitStatus implements Serializable, Comparable { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ - @Override + @Override public String toString() { return String.format("exitCode=%s;exitDescription=%s", exitCode, exitDescription); } /** * Compare the fields one by one. - * + * * @see java.lang.Object#equals(java.lang.Object) */ - @Override + @Override public boolean equals(Object obj) { if (obj == null) { return false; @@ -201,10 +202,10 @@ public class ExitStatus implements Serializable, Comparable { /** * Compatible with the equals implementation. - * + * * @see java.lang.Object#hashCode() */ - @Override + @Override public int hashCode() { return toString().hashCode(); } @@ -212,7 +213,7 @@ public class ExitStatus implements Serializable, Comparable { /** * Add an exit code to an existing {@link ExitStatus}. If there is already a * code present tit will be replaced. - * + * * @param code the code to add * @return a new {@link ExitStatus} with the same properties but a new exit * code. @@ -223,7 +224,7 @@ public class ExitStatus implements Serializable, Comparable { /** * Check if this status represents a running process. - * + * * @return true if the exit code is "RUNNING" or "UNKNOWN" */ public boolean isRunning() { @@ -234,7 +235,7 @@ public class ExitStatus implements Serializable, Comparable { * Add an exit description to an existing {@link ExitStatus}. If there is * already a description present the two will be concatenated with a * semicolon. - * + * * @param description the description to add * @return a new {@link ExitStatus} with the same properties but a new exit * description @@ -257,7 +258,7 @@ public class ExitStatus implements Serializable, Comparable { /** * Extract the stack trace from the throwable provided and append it to * the exist description. - * + * * @param throwable * @return a new ExitStatus with the stack trace appended */ diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java index 7603e45bf..9d7b50a20 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecution.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -32,10 +32,11 @@ import org.springframework.batch.item.ExecutionContext; /** * Batch domain object representing the execution of a job. - * + * * @author Lucas Ward - * + * */ +@SuppressWarnings("serial") public class JobExecution extends Entity { private JobInstance jobInstance; @@ -61,7 +62,7 @@ public class JobExecution extends Entity { /** * Because a JobExecution isn't valid unless the job is set, this * constructor is the only valid one from a modelling point of view. - * + * * @param job the job of which this execution is a part */ public JobExecution(JobInstance job, Long id) { @@ -71,7 +72,7 @@ public class JobExecution extends Entity { /** * Constructor for transient (unsaved) instances. - * + * * @param job the enclosing {@link JobInstance} */ public JobExecution(JobInstance job) { @@ -108,7 +109,7 @@ public class JobExecution extends Entity { /** * Set the value of the status field. - * + * * @param status the status to set */ public void setStatus(BatchStatus status) { @@ -119,7 +120,7 @@ public class JobExecution extends Entity { * Upgrade the status field if the provided value is greater than the * existing one. Clients using this method to set the status can be sure * that they don't overwrite a failed status with an successful one. - * + * * @param status the new status value */ public void upgradeStatus(BatchStatus status) { @@ -129,7 +130,7 @@ public class JobExecution extends Entity { /** * Convenience getter for for the id of the enclosing job. Useful for DAO * implementations. - * + * * @return the id of the enclosing job */ public Long getJobId() { @@ -162,7 +163,7 @@ public class JobExecution extends Entity { /** * Accessor for the step executions. - * + * * @return the step executions that were registered */ public Collection getStepExecutions() { @@ -201,7 +202,7 @@ public class JobExecution extends Entity { /** * Signal the {@link JobExecution} to stop. Iterates through the associated * {@link StepExecution}s, calling {@link StepExecution#setTerminateOnly()}. - * + * */ public void stop() { for (StepExecution stepExecution : stepExecutions) { @@ -212,7 +213,7 @@ public class JobExecution extends Entity { /** * Sets the {@link ExecutionContext} for this execution - * + * * @param executionContext the context */ public void setExecutionContext(ExecutionContext executionContext) { @@ -222,7 +223,7 @@ public class JobExecution extends Entity { /** * Returns the {@link ExecutionContext} for this execution. The content is * expected to be persisted after each step completion (successful or not). - * + * * @return the context */ public ExecutionContext getExecutionContext() { @@ -255,7 +256,7 @@ public class JobExecution extends Entity { /** * Get the date representing the last time this JobExecution was updated in * the JobRepository. - * + * * @return Date representing the last time this JobExecution was updated. */ public Date getLastUpdated() { @@ -264,7 +265,7 @@ public class JobExecution extends Entity { /** * Set the last time this JobExecution was updated. - * + * * @param lastUpdated */ public void setLastUpdated(Date lastUpdated) { @@ -277,7 +278,7 @@ public class JobExecution extends Entity { /** * Add the provided throwable to the failure exception list. - * + * * @param t */ public synchronized void addFailureException(Throwable t) { @@ -287,7 +288,7 @@ public class JobExecution extends Entity { /** * Return all failure causing exceptions for this JobExecution, including * step executions. - * + * * @return List containing all exceptions causing failure for * this JobExecution. */ @@ -312,10 +313,10 @@ public class JobExecution extends Entity { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.Entity#toString() */ - @Override + @Override public String toString() { return super.toString() + String.format(", startTime=%s, endTime=%s, lastUpdated=%s, status=%s, exitStatus=%s, job=[%s]", diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecutionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecutionListener.java index ab98c4919..1cd2fd2b4 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecutionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecutionListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -20,15 +20,15 @@ package org.springframework.batch.core; * Implementations can be stateful if they are careful to either ensure thread * safety, or to use one instance of a listener per job, assuming that job * instances themselves are not used by more than one thread. - * + * * @author Dave Syer - * + * */ public interface JobExecutionListener { /** * Callback before a job executes. - * + * * @param jobExecution the current {@link JobExecution} */ void beforeJob(JobExecution jobExecution); @@ -37,7 +37,7 @@ public interface JobExecutionListener { * Callback after completion of a job. Called after both both successful and * failed executions. To perform logic on a particular status, use * "if (jobExecution.getStatus() == BatchStatus.X)". - * + * * @param jobExecution the current {@link JobExecution} */ void afterJob(JobExecution jobExecution); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobInstance.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobInstance.java index f9b7798bf..a1320dcda 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobInstance.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobInstance.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -23,20 +23,21 @@ import org.springframework.util.Assert; * identity is given by the pair {@link Job} and {@link JobParameters}. * JobInstance can be restarted multiple times in case of execution failure and * it's lifecycle ends with first successful execution. - * + * * Trying to execute an existing JobIntance that has already completed * successfully will result in error. Error will be raised also for an attempt * to restart a failed JobInstance if the Job is not restartable. - * + * * @see Job * @see JobParameters * @see JobExecution - * + * * @author Lucas Ward * @author Dave Syer * @author Robert Kasanicky - * + * */ +@SuppressWarnings("unchecked") public class JobInstance extends Entity { private final JobParameters jobParameters; @@ -65,7 +66,7 @@ public class JobInstance extends Entity { return jobName; } - @Override + @Override public String toString() { return super.toString() + ", JobParameters=[" + jobParameters + "]" + ", Job=[" + jobName + "]"; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobParameter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobParameter.java index ea58bc929..6fc74b992 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobParameter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobParameter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -22,12 +22,13 @@ import java.util.Date; /** * Domain representation of a parameter to a batch job. Only the following types * can be parameters: String, Long, Date, and Double. - * + * * @author Lucas Ward * @author Dave Syer * @since 2.0 - * + * */ +@SuppressWarnings("serial") public class JobParameter implements Serializable { private final Object parameter; @@ -44,7 +45,7 @@ public class JobParameter implements Serializable { /** * Construct a new JobParameter as a Long. - * + * * @param parameter */ public JobParameter(Long parameter) { @@ -54,7 +55,7 @@ public class JobParameter implements Serializable { /** * Construct a new JobParameter as a Date. - * + * * @param parameter */ public JobParameter(Date parameter) { @@ -64,7 +65,7 @@ public class JobParameter implements Serializable { /** * Construct a new JobParameter as a Double. - * + * * @param parameter */ public JobParameter(Double parameter) { @@ -112,7 +113,7 @@ public class JobParameter implements Serializable { : parameter.toString()); } - @Override + @Override public int hashCode() { return 7 + 21 * (parameter == null ? parameterType.hashCode() : parameter.hashCode()); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/StepContribution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/StepContribution.java index bbaba57dc..6bffd54f3 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/StepContribution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/StepContribution.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -20,10 +20,11 @@ import java.io.Serializable; /** * Represents a contribution to a {@link StepExecution}, buffering changes until * they can be applied at a chunk boundary. - * + * * @author Dave Syer - * + * */ +@SuppressWarnings("serial") public class StepContribution implements Serializable { private volatile int readCount = 0; @@ -51,7 +52,7 @@ public class StepContribution implements Serializable { /** * Set the {@link ExitStatus} for this contribution. - * + * * @param status */ public void setExitStatus(ExitStatus status) { @@ -60,7 +61,7 @@ public class StepContribution implements Serializable { /** * Public getter for the status. - * + * * @return the {@link ExitStatus} for this contribution */ public ExitStatus getExitStatus() { @@ -90,7 +91,7 @@ public class StepContribution implements Serializable { /** * Public access to the read counter. - * + * * @return the item counter. */ public int getReadCount() { @@ -99,7 +100,7 @@ public class StepContribution implements Serializable { /** * Public access to the write counter. - * + * * @return the item counter. */ public int getWriteCount() { @@ -153,7 +154,7 @@ public class StepContribution implements Serializable { } /** - * + * */ public void incrementProcessSkipCount() { processSkipCount++; @@ -183,10 +184,10 @@ public class StepContribution implements Serializable { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ - @Override + @Override public String toString() { return "[StepContribution: read=" + readCount + ", written=" + writeCount + ", filtered=" + filterCount + ", readSkips=" + readSkipCount + ", writeSkips=" + writeSkipCount + ", processSkips=" diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java index 648a77ba3..07b20ffb7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -30,11 +30,12 @@ import org.springframework.util.Assert; * Batch domain object representation the execution of a step. Unlike * {@link JobExecution}, there are additional properties related the processing * of items such as commit count, etc. - * + * * @author Lucas Ward * @author Dave Syer - * + * */ +@SuppressWarnings("serial") public class StepExecution extends Entity { private final JobExecution jobExecution; @@ -75,7 +76,7 @@ public class StepExecution extends Entity { /** * Constructor with mandatory properties. - * + * * @param stepName the step to which this execution belongs * @param jobExecution the current job execution * @param id the id of this execution @@ -90,7 +91,7 @@ public class StepExecution extends Entity { /** * Constructor that substitutes in null for the execution id - * + * * @param stepName the step to which this execution belongs * @param jobExecution the current job execution */ @@ -103,7 +104,7 @@ public class StepExecution extends Entity { /** * Returns the {@link ExecutionContext} for this execution - * + * * @return the attributes */ public ExecutionContext getExecutionContext() { @@ -112,7 +113,7 @@ public class StepExecution extends Entity { /** * Sets the {@link ExecutionContext} for this execution - * + * * @param executionContext the attributes */ public void setExecutionContext(ExecutionContext executionContext) { @@ -121,7 +122,7 @@ public class StepExecution extends Entity { /** * Returns the current number of commits for this execution - * + * * @return the current number of commits */ public int getCommitCount() { @@ -130,7 +131,7 @@ public class StepExecution extends Entity { /** * Sets the current number of commits for this execution - * + * * @param commitCount the current number of commits */ public void setCommitCount(int commitCount) { @@ -139,7 +140,7 @@ public class StepExecution extends Entity { /** * Returns the time that this execution ended - * + * * @return the time that this execution ended */ public Date getEndTime() { @@ -148,7 +149,7 @@ public class StepExecution extends Entity { /** * Sets the time that this execution ended - * + * * @param endTime the time that this execution ended */ public void setEndTime(Date endTime) { @@ -157,7 +158,7 @@ public class StepExecution extends Entity { /** * Returns the current number of items read for this execution - * + * * @return the current number of items read for this execution */ public int getReadCount() { @@ -166,7 +167,7 @@ public class StepExecution extends Entity { /** * Sets the current number of read items for this execution - * + * * @param readCount the current number of read items for this execution */ public void setReadCount(int readCount) { @@ -175,7 +176,7 @@ public class StepExecution extends Entity { /** * Returns the current number of items written for this execution - * + * * @return the current number of items written for this execution */ public int getWriteCount() { @@ -184,7 +185,7 @@ public class StepExecution extends Entity { /** * Sets the current number of written items for this execution - * + * * @param writeCount the current number of written items for this execution */ public void setWriteCount(int writeCount) { @@ -193,7 +194,7 @@ public class StepExecution extends Entity { /** * Returns the current number of rollbacks for this execution - * + * * @return the current number of rollbacks for this execution */ public int getRollbackCount() { @@ -202,7 +203,7 @@ public class StepExecution extends Entity { /** * Returns the current number of items filtered out of this execution - * + * * @return the current number of items filtered out of this execution */ public int getFilterCount() { @@ -227,7 +228,7 @@ public class StepExecution extends Entity { /** * Gets the time this execution started - * + * * @return the time this execution started */ public Date getStartTime() { @@ -236,7 +237,7 @@ public class StepExecution extends Entity { /** * Sets the time this execution started - * + * * @param startTime the time this execution started */ public void setStartTime(Date startTime) { @@ -245,7 +246,7 @@ public class StepExecution extends Entity { /** * Returns the current status of this step - * + * * @return the current status of this step */ public BatchStatus getStatus() { @@ -254,7 +255,7 @@ public class StepExecution extends Entity { /** * Sets the current status of this step - * + * * @param status the current status of this step */ public void setStatus(BatchStatus status) { @@ -265,7 +266,7 @@ public class StepExecution extends Entity { * Upgrade the status field if the provided value is greater than the * existing one. Clients using this method to set the status can be sure * that they don't overwrite a failed status with an successful one. - * + * * @param status the new status value */ public void upgradeStatus(BatchStatus status) { @@ -281,7 +282,7 @@ public class StepExecution extends Entity { /** * Accessor for the job execution id. - * + * * @return the jobExecutionId */ public Long getJobExecutionId() { @@ -307,7 +308,7 @@ public class StepExecution extends Entity { /** * Accessor for the execution context information of the enclosing job. - * + * * @return the {@link JobExecution} that was used to start this step * execution. */ @@ -317,7 +318,7 @@ public class StepExecution extends Entity { /** * Factory method for {@link StepContribution}. - * + * * @return a new {@link StepContribution} */ public StepContribution createStepContribution() { @@ -328,7 +329,7 @@ public class StepExecution extends Entity { * On successful execution just before a chunk commit, this method should be * called. Synchronizes access to the {@link StepExecution} so that changes * are atomic. - * + * * @param contribution */ public synchronized void apply(StepContribution contribution) { @@ -379,7 +380,7 @@ public class StepExecution extends Entity { /** * Convenience method to get the current job parameters. - * + * * @return the {@link JobParameters} from the enclosing job, or empty if * that is null */ @@ -406,7 +407,7 @@ public class StepExecution extends Entity { /** * Set the number of records skipped on read - * + * * @param readSkipCount */ public void setReadSkipCount(int readSkipCount) { @@ -415,7 +416,7 @@ public class StepExecution extends Entity { /** * Set the number of records skipped on write - * + * * @param writeSkipCount */ public void setWriteSkipCount(int writeSkipCount) { @@ -431,7 +432,7 @@ public class StepExecution extends Entity { /** * Set the number of records skipped during processing. - * + * * @param processSkipCount */ public void setProcessSkipCount(int processSkipCount) { @@ -447,7 +448,7 @@ public class StepExecution extends Entity { /** * Set the time when the StepExecution was last updated before persisting - * + * * @param lastUpdated */ public void setLastUpdated(Date lastUpdated) { @@ -464,12 +465,12 @@ public class StepExecution extends Entity { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.container.common.domain.Entity#equals(java. * lang.Object) */ - @Override + @Override public boolean equals(Object obj) { Object jobExecutionId = getJobExecutionId(); @@ -493,10 +494,10 @@ public class StepExecution extends Entity { /* * (non-Javadoc) - * + * * @see org.springframework.batch.container.common.domain.Entity#hashCode() */ - @Override + @Override public int hashCode() { Object jobExecutionId = getJobExecutionId(); Long id = getId(); @@ -504,7 +505,7 @@ public class StepExecution extends Entity { * (jobExecutionId != null ? jobExecutionId.hashCode() : 0) + 59 * (id != null ? id.hashCode() : 0); } - @Override + @Override public String toString() { return String.format(getSummary() + ", exitDescription=%s", exitStatus.getExitDescription()); } @@ -514,8 +515,8 @@ public class StepExecution extends Entity { + String.format( ", name=%s, status=%s, exitStatus=%s, readCount=%d, filterCount=%d, writeCount=%d readSkipCount=%d, writeSkipCount=%d" + ", processSkipCount=%d, commitCount=%d, rollbackCount=%d", stepName, status, - exitStatus.getExitCode(), readCount, filterCount, writeCount, readSkipCount, writeSkipCount, - processSkipCount, commitCount, rollbackCount); + exitStatus.getExitCode(), readCount, filterCount, writeCount, readSkipCount, writeSkipCount, + processSkipCount, commitCount, rollbackCount); } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecutionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecutionListener.java index f969e2409..04a668e6a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecutionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecutionListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -18,17 +18,17 @@ package org.springframework.batch.core; /** * Listener interface for the lifecycle of a {@link Step}. - * + * * @author Lucas Ward * @author Dave Syer - * + * */ public interface StepExecutionListener extends StepListener { /** * Initialize the state of the listener with the {@link StepExecution} from * the current scope. - * + * * @param stepExecution */ void beforeStep(StepExecution stepExecution); @@ -37,11 +37,11 @@ public interface StepExecutionListener extends StepListener { * Give a listener a chance to modify the exit status from a step. The value * returned will be combined with the normal exit status using * {@link ExitStatus#and(ExitStatus)}. - * + * * Called after execution of step's processing logic (both successful or * failed). Throwing exception in this method has no effect, it will only be * logged. - * + * * @return an {@link ExitStatus} to combine with the normal value. Return * null to leave the old value unchanged. */ diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/ModularBatchConfiguration.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/ModularBatchConfiguration.java index 1d0230850..1d5217946 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/ModularBatchConfiguration.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/ModularBatchConfiguration.java @@ -31,7 +31,7 @@ import org.springframework.transaction.PlatformTransactionManager; /** * Base {@code Configuration} class providing common structure for enabling and using Spring Batch. Customization is * available by implementing the {@link BatchConfigurer} interface. - * + * * @author Dave Syer * @since 2.2 * @see EnableBatchProcessing @@ -47,19 +47,19 @@ public class ModularBatchConfiguration extends AbstractBatchConfiguration { private AutomaticJobRegistrar registrar = new AutomaticJobRegistrar(); - @Override + @Override @Bean public JobRepository jobRepository() throws Exception { return getConfigurer(configurers).getJobRepository(); } - @Override + @Override @Bean public JobLauncher jobLauncher() throws Exception { return getConfigurer(configurers).getJobLauncher(); } - @Override + @Override @Bean public PlatformTransactionManager transactionManager() throws Exception { return getConfigurer(configurers).getTransactionManager(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.java index c1952959a..b3310a267 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.java @@ -37,7 +37,7 @@ import org.springframework.transaction.PlatformTransactionManager; * only initialize when a method is called. This is to prevent (as much as possible) configuration cycles from * developing when these components are needed in a configuration resource that itself provides a * {@link BatchConfigurer}. - * + * * @author Dave Syer * @since 2.2 * @see EnableBatchProcessing @@ -47,7 +47,7 @@ public class SimpleBatchConfiguration extends AbstractBatchConfiguration { @Autowired private ApplicationContext context; - + private boolean initialized = false; private AtomicReference jobRepository = new AtomicReference(); @@ -58,25 +58,25 @@ public class SimpleBatchConfiguration extends AbstractBatchConfiguration { private AtomicReference transactionManager = new AtomicReference(); - @Override + @Override @Bean public JobRepository jobRepository() throws Exception { return createLazyProxy(jobRepository, JobRepository.class); } - @Override + @Override @Bean public JobLauncher jobLauncher() throws Exception { return createLazyProxy(jobLauncher, JobLauncher.class); } - @Override + @Override @Bean public JobRegistry jobRegistry() throws Exception { return createLazyProxy(jobRegistry, JobRegistry.class); } - @Override + @Override @Bean public PlatformTransactionManager transactionManager() throws Exception { return createLazyProxy(transactionManager, PlatformTransactionManager.class); @@ -95,7 +95,7 @@ public class SimpleBatchConfiguration extends AbstractBatchConfiguration { /** * Sets up the basic components by extracting them from the {@link BatchConfigurer configurer}, defaulting to some * sensible values as long as a unique DataSource is available. - * + * * @throws Exception if there is a problem in the configurer */ protected void initialize() throws Exception { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactory.java index a489cb9af..125e3daa9 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -23,9 +23,9 @@ import org.springframework.context.ConfigurableApplicationContext; /** * A {@link JobFactory} that creates its own {@link ApplicationContext} and * pulls a bean out when asked to create a {@link Job}. - * + * * @author Dave Syer - * + * */ public class ApplicationContextJobFactory implements JobFactory { @@ -39,26 +39,26 @@ public class ApplicationContextJobFactory implements JobFactory { */ public ApplicationContextJobFactory(String jobName, ApplicationContextFactory applicationContextFactory) { ConfigurableApplicationContext context = applicationContextFactory.createApplicationContext(); - this.job = (Job) context.getBean(jobName, Job.class); + this.job = context.getBean(jobName, Job.class); } /** * Create an {@link ApplicationContext} from the factory provided and pull * out a bean with the name given during initialization. - * + * * @see org.springframework.batch.core.configuration.JobFactory#createJob() */ - @Override + @Override public final Job createJob() { return job; } - + /** * Just return the name of instance passed in on initialization. - * + * * @see JobFactory#getJobName() */ - @Override + @Override public String getJobName() { return job.getName(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/DefaultJobLoader.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/DefaultJobLoader.java index 228a0ee98..cf3bc97db 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/DefaultJobLoader.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/DefaultJobLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 the original author or authors. + * Copyright 2006-2013 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. @@ -50,7 +50,7 @@ public class DefaultJobLoader implements JobLoader, InitializingBean { private static Log logger = LogFactory.getLog(DefaultJobLoader.class); private JobRegistry jobRegistry; - private StepRegistry stepRegistry; + private StepRegistry stepRegistry; private Map contexts = new ConcurrentHashMap(); @@ -63,24 +63,24 @@ public class DefaultJobLoader implements JobLoader, InitializingBean { this(null, null); } - /** - * Creates a job loader with the job registry provided. - * - * @param jobRegistry a {@link JobRegistry} - */ - public DefaultJobLoader(JobRegistry jobRegistry) { - this(jobRegistry, null); - } + /** + * Creates a job loader with the job registry provided. + * + * @param jobRegistry a {@link JobRegistry} + */ + public DefaultJobLoader(JobRegistry jobRegistry) { + this(jobRegistry, null); + } /** * Creates a job loader with the job and step registries provided. - * + * * @param jobRegistry a {@link JobRegistry} - * @param stepRegistry a {@link StepRegistry} + * @param stepRegistry a {@link StepRegistry} */ public DefaultJobLoader(JobRegistry jobRegistry, StepRegistry stepRegistry) { this.jobRegistry = jobRegistry; - this.stepRegistry = stepRegistry; + this.stepRegistry = stepRegistry; } /** @@ -92,14 +92,14 @@ public class DefaultJobLoader implements JobLoader, InitializingBean { this.jobRegistry = jobRegistry; } - /** - * The {@link StepRegistry} to use for the steps of created jobs. - * - * @param stepRegistry the step registry - */ - public void setStepRegistry(StepRegistry stepRegistry) { - this.stepRegistry = stepRegistry; - } + /** + * The {@link StepRegistry} to use for the steps of created jobs. + * + * @param stepRegistry the step registry + */ + public void setStepRegistry(StepRegistry stepRegistry) { + this.stepRegistry = stepRegistry; + } /** * Unregister all the jobs and close all the contexts created by this @@ -107,7 +107,7 @@ public class DefaultJobLoader implements JobLoader, InitializingBean { * * @see JobLoader#clear() */ - @Override + @Override public void clear() { for (ConfigurableApplicationContext context : contexts.values()) { if (context.isActive()) { @@ -115,12 +115,12 @@ public class DefaultJobLoader implements JobLoader, InitializingBean { } } for (String jobName : jobRegistry.getJobNames()) { - doUnregister(jobName); + doUnregister(jobName); } contexts.clear(); } - @Override + @Override public Collection reload(ApplicationContextFactory factory) { // If the same factory is loaded twice the context can be closed @@ -142,7 +142,7 @@ public class DefaultJobLoader implements JobLoader, InitializingBean { } } - @Override + @Override public Collection load(ApplicationContextFactory factory) throws DuplicateJobException { return doLoad(factory, false); } @@ -205,74 +205,74 @@ public class DefaultJobLoader implements JobLoader, InitializingBean { } - /** - * Returns all the {@link Step} instances defined by the specified {@link StepLocator}. - *

- * The specified jobApplicationContext is used to collect additional steps that - * are not exposed by the step locator - * - * @param stepLocator the given step locator - * @param jobApplicationContext the application context of the job - * @return all the {@link Step} defined by the given step locator and context - * @see StepLocator - */ - private Collection getSteps(final StepLocator stepLocator, final ApplicationContext jobApplicationContext) { - final Collection stepNames = stepLocator.getStepNames(); - final Collection result = new ArrayList(); - for (String stepName : stepNames) { - result.add(stepLocator.getStep(stepName)); - } + /** + * Returns all the {@link Step} instances defined by the specified {@link StepLocator}. + *

+ * The specified jobApplicationContext is used to collect additional steps that + * are not exposed by the step locator + * + * @param stepLocator the given step locator + * @param jobApplicationContext the application context of the job + * @return all the {@link Step} defined by the given step locator and context + * @see StepLocator + */ + private Collection getSteps(final StepLocator stepLocator, final ApplicationContext jobApplicationContext) { + final Collection stepNames = stepLocator.getStepNames(); + final Collection result = new ArrayList(); + for (String stepName : stepNames) { + result.add(stepLocator.getStep(stepName)); + } - // Because some steps are referenced by name, we need to look in the context to see if there - // are more Step instances defined. Right now they are registered as being available in the - // context of the job but we have no idea if they are linked to that Job or not. - @SuppressWarnings("unchecked") - final Map allSteps = jobApplicationContext.getBeansOfType(Step.class); - for (Map.Entry entry : allSteps.entrySet()) { - if (!stepNames.contains(entry.getKey())) { - result.add(entry.getValue()); - } - } - return result; - } + // Because some steps are referenced by name, we need to look in the context to see if there + // are more Step instances defined. Right now they are registered as being available in the + // context of the job but we have no idea if they are linked to that Job or not. + @SuppressWarnings("unchecked") + final Map allSteps = jobApplicationContext.getBeansOfType(Step.class); + for (Map.Entry entry : allSteps.entrySet()) { + if (!stepNames.contains(entry.getKey())) { + result.add(entry.getValue()); + } + } + return result; + } - /** - * Registers the specified {@link Job} defined in the specified {@link ConfigurableApplicationContext}. - *

- * Makes sure to update the {@link StepRegistry} if it is available. - * - * @param context the context in which the job is defined - * @param job the job to register - * @throws DuplicateJobException if that job is already registered - */ - private void doRegister(ConfigurableApplicationContext context, Job job) throws DuplicateJobException { - final JobFactory jobFactory = new ReferenceJobFactory(job); - jobRegistry.register(jobFactory); + /** + * Registers the specified {@link Job} defined in the specified {@link ConfigurableApplicationContext}. + *

+ * Makes sure to update the {@link StepRegistry} if it is available. + * + * @param context the context in which the job is defined + * @param job the job to register + * @throws DuplicateJobException if that job is already registered + */ + private void doRegister(ConfigurableApplicationContext context, Job job) throws DuplicateJobException { + final JobFactory jobFactory = new ReferenceJobFactory(job); + jobRegistry.register(jobFactory); - if (stepRegistry != null) { - if (!(job instanceof StepLocator)) { - throw new UnsupportedOperationException("Cannot locate steps from a Job that is not a StepLocator: job=" - + job.getName() + " does not implement StepLocator"); - } - stepRegistry.register(job.getName(), getSteps((StepLocator) job, context)); - } - } + if (stepRegistry != null) { + if (!(job instanceof StepLocator)) { + throw new UnsupportedOperationException("Cannot locate steps from a Job that is not a StepLocator: job=" + + job.getName() + " does not implement StepLocator"); + } + stepRegistry.register(job.getName(), getSteps((StepLocator) job, context)); + } + } - /** - * Unregisters the job identified by the specified jobName. - * - * @param jobName the name of the job to unregister - */ - private void doUnregister(String jobName) { - jobRegistry.unregister(jobName); - if (stepRegistry != null) { - stepRegistry.unregisterStepsFromJob(jobName); - } + /** + * Unregisters the job identified by the specified jobName. + * + * @param jobName the name of the job to unregister + */ + private void doUnregister(String jobName) { + jobRegistry.unregister(jobName); + if (stepRegistry != null) { + stepRegistry.unregisterStepsFromJob(jobName); + } - } + } - @Override - public void afterPropertiesSet() { - Assert.notNull(jobRegistry, "Job registry could not be null."); - } + @Override + public void afterPropertiesSet() { + Assert.notNull(jobRegistry, "Job registry could not be null."); + } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/GroupAwareJob.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/GroupAwareJob.java index 9a7cbbf22..be40fc985 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/GroupAwareJob.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/GroupAwareJob.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -29,10 +29,10 @@ import org.springframework.util.ClassUtils; * identical functionality but named financeDepartment.overnightJob * . The use of a "." separator for elements is deliberate, since it is a "safe" * character in a URL. - * - * + * + * * @author Dave Syer - * + * */ public class GroupAwareJob implements Job { @@ -48,7 +48,7 @@ public class GroupAwareJob implements Job { /** * Create a new {@link Job} with the delegate and no group name. - * + * * @param delegate a delegate for the features of a regular Job */ public GroupAwareJob(Job delegate) { @@ -57,7 +57,7 @@ public class GroupAwareJob implements Job { /** * Create a new {@link Job} with the given group name and delegate. - * + * * @param groupName the group name to prepend * @param delegate a delegate for the features of a regular Job */ @@ -67,40 +67,40 @@ public class GroupAwareJob implements Job { this.delegate = delegate; } - @Override + @Override public void execute(JobExecution execution) { delegate.execute(execution); } - + /** * Concatenates the group name and the delegate job name (joining with a * "."). - * + * * @see org.springframework.batch.core.Job#getName() */ - @Override + @Override public String getName() { return groupName==null ? delegate.getName() : groupName + SEPARATOR + delegate.getName(); } - @Override + @Override public boolean isRestartable() { return delegate.isRestartable(); } - @Override + @Override public JobParametersIncrementer getJobParametersIncrementer() { return delegate.getJobParametersIncrementer(); } - @Override + @Override public JobParametersValidator getJobParametersValidator() { return delegate.getJobParametersValidator(); } /* * (non-Javadoc) - * + * * @see java.lang.Object#equals(java.lang.Object) */ @Override @@ -113,14 +113,14 @@ public class GroupAwareJob implements Job { /* * (non-Javadoc) - * + * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { return delegate.hashCode(); } - + @Override public String toString() { return ClassUtils.getShortName(delegate.getClass()) + ": [name=" + getName() + "]"; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobRegistryBeanPostProcessor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobRegistryBeanPostProcessor.java index 59cf3f266..643e9c439 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobRegistryBeanPostProcessor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JobRegistryBeanPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -40,12 +40,12 @@ import org.springframework.util.Assert; * {@link JobRegistry}. Include a bean of this type along with your job * configuration, and use the same {@link JobRegistry} as a {@link JobLocator} * when you need to locate a {@link Job} to launch. - * + * * @author Dave Syer - * + * */ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFactoryAware, InitializingBean, - DisposableBean { +DisposableBean { private static Log logger = LogFactory.getLog(JobRegistryBeanPostProcessor.class); @@ -65,7 +65,7 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact * contributing to the same {@link JobRegistry}: child contexts can then * define an instance with a unique group name to avoid clashes between job * names. - * + * * @param groupName the groupName to set */ public void setGroupName(String groupName) { @@ -74,7 +74,7 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact /** * Injection setter for {@link JobRegistry}. - * + * * @param jobRegistry the jobConfigurationRegistry to set */ public void setJobRegistry(JobRegistry jobRegistry) { @@ -83,12 +83,12 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact /* * (non-Javadoc) - * + * * @see * org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org * .springframework.beans.factory.BeanFactory) */ - @Override + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { if (beanFactory instanceof DefaultListableBeanFactory) { this.beanFactory = (DefaultListableBeanFactory) beanFactory; @@ -97,10 +97,10 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact /** * Make sure the registry is set before use. - * + * * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(jobRegistry, "JobRegistry must not be null"); } @@ -110,7 +110,7 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact * post processor. * @see org.springframework.beans.factory.DisposableBean#destroy() */ - @Override + @Override public void destroy() throws Exception { for (String name : jobNames) { logger.debug("Unregistering job: " + name); @@ -122,11 +122,11 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact /** * If the bean is an instance of {@link Job} then register it. * @throws FatalBeanException if there is a {@link DuplicateJobException}. - * + * * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, * java.lang.String) */ - @Override + @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof Job) { Job job = (Job) bean; @@ -154,7 +154,7 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact * Determine a group name for the job to be registered. Default * implementation just returns the {@link #setGroupName(String) groupName} * configured. Provides an extension point for specialised subclasses. - * + * * @param beanDefinition the bean definition for the job * @param job the job * @return a group name for the job (or null if not needed) @@ -165,11 +165,11 @@ public class JobRegistryBeanPostProcessor implements BeanPostProcessor, BeanFact /** * Do nothing. - * + * * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, * java.lang.String) */ - @Override + @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { return bean; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java index f97c26ece..9cd93cb54 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -15,6 +15,11 @@ */ package org.springframework.batch.core.configuration.support; +import java.util.Collections; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + import org.springframework.batch.core.Job; import org.springframework.batch.core.configuration.DuplicateJobException; import org.springframework.batch.core.configuration.JobFactory; @@ -22,11 +27,6 @@ import org.springframework.batch.core.configuration.JobRegistry; import org.springframework.batch.core.launch.NoSuchJobException; import org.springframework.util.Assert; -import java.util.Collections; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - /** * Simple, thread-safe, map-based implementation of {@link JobRegistry}. * @@ -35,46 +35,46 @@ import java.util.concurrent.ConcurrentMap; */ public class MapJobRegistry implements JobRegistry { - /** - * The map holding the registered job factories. - */ - // The "final" ensures that it is visible and initialized when the constructor resolves. - private final ConcurrentMap map = new ConcurrentHashMap(); + /** + * The map holding the registered job factories. + */ + // The "final" ensures that it is visible and initialized when the constructor resolves. + private final ConcurrentMap map = new ConcurrentHashMap(); - @Override - public void register(JobFactory jobFactory) throws DuplicateJobException { - Assert.notNull(jobFactory); - String name = jobFactory.getJobName(); - Assert.notNull(name, "Job configuration must have a name."); - JobFactory previousValue = map.putIfAbsent(name, jobFactory); - if (previousValue != null) { - throw new DuplicateJobException("A job configuration with this name [" + name - + "] was already registered"); - } - } + @Override + public void register(JobFactory jobFactory) throws DuplicateJobException { + Assert.notNull(jobFactory); + String name = jobFactory.getJobName(); + Assert.notNull(name, "Job configuration must have a name."); + JobFactory previousValue = map.putIfAbsent(name, jobFactory); + if (previousValue != null) { + throw new DuplicateJobException("A job configuration with this name [" + name + + "] was already registered"); + } + } - @Override - public void unregister(String name) { - Assert.notNull(name, "Job configuration must have a name."); - map.remove(name); - } + @Override + public void unregister(String name) { + Assert.notNull(name, "Job configuration must have a name."); + map.remove(name); + } - @Override - public Job getJob(String name) throws NoSuchJobException { - JobFactory factory = map.get(name); - if (factory == null) { - throw new NoSuchJobException("No job configuration with the name [" + name + "] was registered"); - } else { - return factory.createJob(); - } - } + @Override + public Job getJob(String name) throws NoSuchJobException { + JobFactory factory = map.get(name); + if (factory == null) { + throw new NoSuchJobException("No job configuration with the name [" + name + "] was registered"); + } else { + return factory.createJob(); + } + } - /** - * Provides an unmodifiable view of the job names. - */ - @Override - public Set getJobNames() { - return Collections.unmodifiableSet(map.keySet()); - } + /** + * Provides an unmodifiable view of the job names. + */ + @Override + public Set getJobNames() { + return Collections.unmodifiableSet(map.keySet()); + } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapStepRegistry.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapStepRegistry.java index 0fc7ca50c..fea8816e7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapStepRegistry.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapStepRegistry.java @@ -1,5 +1,26 @@ +/* + * Copyright 2012-2013 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.core.configuration.support; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + import org.springframework.batch.core.Step; import org.springframework.batch.core.configuration.DuplicateJobException; import org.springframework.batch.core.configuration.StepRegistry; @@ -7,12 +28,6 @@ import org.springframework.batch.core.launch.NoSuchJobException; import org.springframework.batch.core.step.NoSuchStepException; import org.springframework.util.Assert; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - /** * Simple map-based implementation of {@link StepRegistry}. Access to the map is * synchronized, guarded by an internal lock. @@ -22,46 +37,46 @@ import java.util.concurrent.ConcurrentMap; */ public class MapStepRegistry implements StepRegistry { - private final ConcurrentMap> map = new ConcurrentHashMap>(); + private final ConcurrentMap> map = new ConcurrentHashMap>(); - @Override - public void register(String jobName, Collection steps) throws DuplicateJobException { - Assert.notNull(jobName, "The job name cannot be null."); - Assert.notNull(steps, "The job steps cannot be null."); + @Override + public void register(String jobName, Collection steps) throws DuplicateJobException { + Assert.notNull(jobName, "The job name cannot be null."); + Assert.notNull(steps, "The job steps cannot be null."); - final Map jobSteps = new HashMap(); - for (Step step : steps) { - jobSteps.put(step.getName(), step); - } - final Object previousValue = map.putIfAbsent(jobName, jobSteps); - if (previousValue != null) { - throw new DuplicateJobException("A job configuration with this name [" + jobName - + "] was already registered"); - } - } + final Map jobSteps = new HashMap(); + for (Step step : steps) { + jobSteps.put(step.getName(), step); + } + final Object previousValue = map.putIfAbsent(jobName, jobSteps); + if (previousValue != null) { + throw new DuplicateJobException("A job configuration with this name [" + jobName + + "] was already registered"); + } + } - @Override - public void unregisterStepsFromJob(String jobName) { - Assert.notNull(jobName, "Job configuration must have a name."); - map.remove(jobName); - } + @Override + public void unregisterStepsFromJob(String jobName) { + Assert.notNull(jobName, "Job configuration must have a name."); + map.remove(jobName); + } - @Override - public Step getStep(String jobName, String stepName) throws NoSuchJobException { - Assert.notNull(jobName, "The job name cannot be null."); - Assert.notNull(stepName, "The step name cannot be null."); - if (!map.containsKey(jobName)) { - throw new NoSuchJobException("No job configuration with the name [" + jobName + "] was registered"); - } else { - final Map jobSteps = map.get(jobName); - if (jobSteps.containsKey(stepName)) { - return jobSteps.get(stepName); - } else { - throw new NoSuchStepException("The step called [" + stepName + "] does not exist in the job [" + - jobName + "]"); - } - } - } + @Override + public Step getStep(String jobName, String stepName) throws NoSuchJobException { + Assert.notNull(jobName, "The job name cannot be null."); + Assert.notNull(stepName, "The step name cannot be null."); + if (!map.containsKey(jobName)) { + throw new NoSuchJobException("No job configuration with the name [" + jobName + "] was registered"); + } else { + final Map jobSteps = map.get(jobName); + if (jobSteps.containsKey(stepName)) { + return jobSteps.get(stepName); + } else { + throw new NoSuchStepException("The step called [" + stepName + "] does not exist in the job [" + + jobName + "]"); + } + } + } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/OsgiBundleXmlApplicationContextFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/OsgiBundleXmlApplicationContextFactory.java index df4d62484..82c2942fa 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/OsgiBundleXmlApplicationContextFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/OsgiBundleXmlApplicationContextFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -27,12 +27,12 @@ import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; /** * {@link ApplicationContextFactory} that can be used to load a context from an * XML location in a bundle. - * + * * @author Dave Syer - * + * */ public class OsgiBundleXmlApplicationContextFactory implements BundleContextAware, ApplicationContextFactory, - ApplicationContextAware { +ApplicationContextAware { private BundleContext bundleContext; @@ -58,10 +58,10 @@ public class OsgiBundleXmlApplicationContextFactory implements BundleContextAwar /** * Setter for the parent application context. - * + * * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) */ - @Override + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { parent = applicationContext; } @@ -69,10 +69,10 @@ public class OsgiBundleXmlApplicationContextFactory implements BundleContextAwar /** * Stash the {@link BundleContext} for creating a job application context * later. - * + * * @see org.springframework.osgi.context.BundleContextAware#setBundleContext(org.osgi.framework.BundleContext) */ - @Override + @Override public void setBundleContext(BundleContext context) { this.bundleContext = context; } @@ -81,10 +81,10 @@ public class OsgiBundleXmlApplicationContextFactory implements BundleContextAwar * Create an application context from the provided path, using the current * OSGi {@link BundleContext} and the enclosing Spring * {@link ApplicationContext} as a parent context. - * + * * @see ApplicationContextFactory#createApplicationContext() */ - @Override + @Override public ConfigurableApplicationContext createApplicationContext() { OsgiBundleXmlApplicationContext context = new OsgiBundleXmlApplicationContext(new String[] { path }, parent); String displayName = bundleContext.getBundle().getSymbolicName() + ":" + this.displayName; @@ -108,10 +108,12 @@ public class OsgiBundleXmlApplicationContextFactory implements BundleContextAwar @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; + } return toString().equals(obj.toString()); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ReferenceJobFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ReferenceJobFactory.java index 066f6d013..0427aebe3 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ReferenceJobFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/ReferenceJobFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -21,9 +21,9 @@ import org.springframework.batch.core.configuration.JobFactory; /** * A {@link JobFactory} that just keeps a reference to a {@link Job}. It never * modifies its {@link Job}. - * + * * @author Dave Syer - * + * */ public class ReferenceJobFactory implements JobFactory { @@ -38,20 +38,20 @@ public class ReferenceJobFactory implements JobFactory { /** * Just return the instance passed in on initialization. - * + * * @see JobFactory#createJob() */ - @Override + @Override public final Job createJob() { return job; } - + /** * Just return the name of instance passed in on initialization. - * + * * @see JobFactory#getJobName() */ - @Override + @Override public String getJobName() { return job.getName(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceHandler.java index ba486af05..53890ac24 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -19,17 +19,17 @@ import org.springframework.beans.factory.xml.NamespaceHandler; import org.springframework.beans.factory.xml.NamespaceHandlerSupport; /** - * + * * * @author Dave Syer - * + * */ public class CoreNamespaceHandler extends NamespaceHandlerSupport { /** * @see NamespaceHandler#init() */ - @Override + @Override public void init() { this.registerBeanDefinitionParser("job", new JobParser()); this.registerBeanDefinitionParser("flow", new TopLevelFlowParser()); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespacePostProcessor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespacePostProcessor.java index b3d44f246..e7223c8fa 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespacePostProcessor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespacePostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -33,7 +33,7 @@ import org.springframework.transaction.PlatformTransactionManager; /** * Post-process jobs and steps defined using the batch namespace to inject * dependencies. - * + * * @author Dan Garrette * @since 2.0.1 */ @@ -49,7 +49,7 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor private ApplicationContext applicationContext; - @Override + @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { for (String beanName : beanFactory.getBeanDefinitionNames()) { injectJobRepositoryIntoSteps(beanName, beanFactory); @@ -60,7 +60,7 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor /** * Automatically inject job-repository from a job into its steps. Only * inject if the step is an AbstractStep or StepParserStepFactoryBean. - * + * * @param beanName * @param beanFactory */ @@ -89,7 +89,7 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor * If any of the beans in the parent hierarchy is a <step/> with a * <tasklet/>, then the bean class must be * {@link StepParserStepFactoryBean}. - * + * * @param beanName * @param beanFactory */ @@ -102,7 +102,7 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor } } - @Override + @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { return injectDefaults(bean); } @@ -115,7 +115,7 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor *

  • Inject "transactionManager" into any * {@link StepParserStepFactoryBean} without a transactionManager. * - * + * * @param bean * @return */ @@ -142,12 +142,12 @@ public class CoreNamespacePostProcessor implements BeanPostProcessor, BeanFactor return bean; } - @Override + @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { return bean; } - @Override + @Override public void setApplicationContext(ApplicationContext applicationContext) { this.applicationContext = applicationContext; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobExecutionListenerParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobExecutionListenerParser.java index 8da10a252..7065b75f6 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobExecutionListenerParser.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobExecutionListenerParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2013 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. @@ -24,19 +24,19 @@ import org.springframework.batch.core.listener.ListenerMetaData; /** * Parser for a step listener element. Builds a {@link JobListenerFactoryBean} * using attributes from the configuration. - * + * * @author Dan Garrette * @since 2.0 * @see AbstractListenerParser */ public class JobExecutionListenerParser extends AbstractListenerParser { - @Override + @Override protected Class getBeanClass() { return JobListenerFactoryBean.class; } - @Override + @Override protected ListenerMetaData[] getMetaDataValues() { return JobListenerMetaData.values(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParserJobFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParserJobFactoryBean.java index 07d46cabd..202281f63 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParserJobFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParserJobFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -30,7 +30,7 @@ import org.springframework.util.StringUtils; * This {@link FactoryBean} is used by the batch namespace parser to create * {@link FlowJob} objects. It stores all of the properties that are * configurable on the <job/>. - * + * * @author Dan Garrette * @author Dave Syer * @since 2.0.1 @@ -55,7 +55,7 @@ class JobParserJobFactoryBean implements SmartFactoryBean { this.name = name; } - @Override + @Override public final Object getObject() throws Exception { Assert.isTrue(StringUtils.hasText(name), "The job must have an id."); FlowJob flowJob = new FlowJob(name); @@ -95,7 +95,7 @@ class JobParserJobFactoryBean implements SmartFactoryBean { public void setJobRepository(JobRepository jobRepository) { this.jobRepository = jobRepository; } - + public void setJobParametersValidator(JobParametersValidator jobParametersValidator) { this.jobParametersValidator = jobParametersValidator; } @@ -116,22 +116,22 @@ class JobParserJobFactoryBean implements SmartFactoryBean { this.flow = flow; } - @Override + @Override public Class getObjectType() { return FlowJob.class; } - @Override + @Override public boolean isSingleton() { return true; } - - @Override + + @Override public boolean isEagerInit() { return true; } - - @Override + + @Override public boolean isPrototype() { return false; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/SimpleFlowFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/SimpleFlowFactoryBean.java index bc396928f..b963d1d05 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/SimpleFlowFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/SimpleFlowFactoryBean.java @@ -1,3 +1,18 @@ +/* + * Copyright 2012-2013 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.core.configuration.xml; import java.util.ArrayList; @@ -23,10 +38,11 @@ import org.springframework.util.Assert; * replaces the states in the input with proxies that have a unique name formed * from the flow name and the original state name (unless the name is already in * that form, in which case it is not modified). - * + * * @author Dave Syer - * + * */ +@SuppressWarnings("rawtypes") public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean { private String name; @@ -37,7 +53,7 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean { /** * The name of the flow that is created by this factory. - * + * * @param name the value of the name */ public void setName(String name) { @@ -47,10 +63,10 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean { /** * The raw state transitions for the flow. They will be transformed into - * proxies that have the same behaviour but unique names prefixed with the + * proxies that have the same behavior but unique names prefixed with the * flow name. - * - * @param name the value of the name + * + * @param stateTransitions the list of transitions */ public void setStateTransitions(List stateTransitions) { this.stateTransitions = stateTransitions; @@ -58,15 +74,15 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean { /** * Check mandatory properties (name). - * + * * @throws Exception */ - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.hasText(name, "The flow must have a name"); } - @Override + @Override public Object getObject() throws Exception { SimpleFlow flow = new SimpleFlow(name); @@ -95,7 +111,7 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean { * Convenience method to get a state that proxies the input but with a * different name, appropriate to this flow. If the state is a StepState * then the step name is also changed. - * + * * @param state * @return */ @@ -111,22 +127,22 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean { return new DelegateState(stateName, state); } - @Override + @Override public Class getObjectType() { return SimpleFlow.class; } - @Override + @Override public boolean isSingleton() { return true; } /** * A State that proxies a delegate and changes its name but leaves its - * behaviour unchanged. - * + * behavior unchanged. + * * @author Dave Syer - * + * */ private static class DelegateState extends AbstractState implements FlowHolder { private final State state; @@ -136,7 +152,7 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean { this.state = state; } - @Override + @Override public boolean isEndState() { return state.isEndState(); } @@ -146,11 +162,11 @@ public class SimpleFlowFactoryBean implements FactoryBean, InitializingBean { return state.handle(executor); } - @Override + @Override public Collection getFlows() { return (state instanceof FlowHolder) ? ((FlowHolder)state).getFlows() : Collections.emptyList(); } - + } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepListenerParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepListenerParser.java index 818d8e0eb..bc33146f6 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepListenerParser.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepListenerParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -32,13 +32,13 @@ import org.w3c.dom.Element; /** * Parser for a step listener element. Builds a {@link StepListenerFactoryBean} * using attributes from the configuration. - * + * * @author Dan Garrette * @since 2.0 * @see AbstractListenerParser */ public class StepListenerParser extends AbstractListenerParser { - + private static final String LISTENERS_ELE = "listeners"; private static final String MERGE_ATTR = "merge"; @@ -53,17 +53,17 @@ public class StepListenerParser extends AbstractListenerParser { this.listenerMetaData = listenerMetaData; } - @Override + @Override protected Class getBeanClass() { return StepListenerFactoryBean.class; } - @Override + @Override protected ListenerMetaData[] getMetaDataValues() { return listenerMetaData; } - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "rawtypes"}) public void handleListenersElement(Element stepElement, BeanDefinition beanDefinition, ParserContext parserContext) { MutablePropertyValues propertyValues = beanDefinition.getPropertyValues(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java index dbc9e601f..9cecd4c43 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -80,7 +80,7 @@ import org.springframework.util.Assert; * This {@link FactoryBean} is used by the batch namespace parser to create {@link Step} objects. Stores all of the * properties that are configurable on the <step/> (and its inner <tasklet/>). Based on which properties are * configured, the {@link #getObject()} method will delegate to the appropriate class for generating the {@link Step}. - * + * * @author Dan Garrette * @author Josh Long * @see SimpleStepFactoryBean @@ -88,6 +88,7 @@ import org.springframework.util.Assert; * @see TaskletStep * @since 2.0 */ +@SuppressWarnings("rawtypes") class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { // @@ -217,10 +218,10 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Create a {@link Step} from the configuration provided. - * + * * @see FactoryBean#getObject() */ - @Override + @Override public final Object getObject() throws Exception { if (hasChunkElement) { Assert.isNull(tasklet, "Step [" + name @@ -382,7 +383,6 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { @SuppressWarnings("unchecked") private Step createSimpleStep() { - @SuppressWarnings("rawtypes") SimpleStepBuilder builder = new SimpleStepBuilder(new StepBuilder(name)); if (commitInterval != null) { builder.chunk(commitInterval); @@ -402,6 +402,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { return builder.build(); } + @SuppressWarnings("serial") private void enhanceTaskletStepBuilder(AbstractTaskletStepBuilder builder) { enhanceCommonStep(builder); @@ -474,7 +475,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Check if a field is present then a second is also. If the twoWayDependency flag is set then the opposite must * also be true: if the second value is present, the first must also be. - * + * * @param dependentName the name of the first field * @param dependentValue the value of the first field * @param name the name of the other field (which should be absent if the first is present) @@ -496,7 +497,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Is the object non-null (or if an Integer, non-zero)? - * + * * @param o an object * @return true if the object has a value */ @@ -526,12 +527,12 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { return n != null && n > 0; } - @Override + @Override public Class getObjectType() { return TaskletStep.class; } - @Override + @Override public boolean isSingleton() { return true; } @@ -542,10 +543,10 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Set the bean name property, which will become the name of the {@link Step} when it is created. - * + * * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String) */ - @Override + @Override public void setBeanName(String name) { if (this.name == null) { this.name = name; @@ -632,7 +633,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for the flag to indicate that the step should be replayed on a restart, even if successful the * first time. - * + * * @param allowStartIfComplete the shouldAllowStartIfComplete to set */ public void setAllowStartIfComplete(boolean allowStartIfComplete) { @@ -649,7 +650,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for {@link JobRepository}. - * + * * @param jobRepository */ public void setJobRepository(JobRepository jobRepository) { @@ -658,7 +659,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * The number of times that the step should be allowed to start - * + * * @param startLimit */ public void setStartLimit(int startLimit) { @@ -667,7 +668,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * A preconfigured {@link Tasklet} to use. - * + * * @param tasklet */ public void setTasklet(Tasklet tasklet) { @@ -695,7 +696,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * The listeners to inject into the {@link Step}. Any instance of {@link StepListener} can be used, and will then * receive callbacks at the appropriate stage in the step. - * + * * @param listeners an array of listeners */ public void setListeners(StepListener[] listeners) { @@ -734,7 +735,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Exception classes that may not cause a rollback if encountered in the right place. - * + * * @param noRollbackExceptionClasses the noRollbackExceptionClasses to set */ public void setNoRollbackExceptionClasses(Collection> noRollbackExceptionClasses) { @@ -768,7 +769,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * A backoff policy to be applied to retry process. - * + * * @param backOffPolicy the {@link BackOffPolicy} to set */ public void setBackOffPolicy(BackOffPolicy backOffPolicy) { @@ -778,7 +779,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * A retry policy to apply when exceptions occur. If this is specified then the retry limit and retryable exceptions * will be ignored. - * + * * @param retryPolicy the {@link RetryPolicy} to set */ public void setRetryPolicy(RetryPolicy retryPolicy) { @@ -795,7 +796,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * A key generator that can be used to compare items with previously recorded items in a retry. Only used if the * reader is a transactional queue. - * + * * @param keyGenerator the {@link KeyGenerator} to set */ public void setKeyGenerator(KeyGenerator keyGenerator) { @@ -814,7 +815,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { * The default value should be high enough and more for most purposes. To breach the limit in a single-threaded step * typically you have to have this many failures in a single transaction. Defaults to the value in the * {@link MapRetryContextCache}.
    - * + * * @param cacheCapacity the cache capacity to set (greater than 0 else ignored) */ public void setCacheCapacity(int cacheCapacity) { @@ -825,7 +826,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { * Public setter for the {@link CompletionPolicy} applying to the chunk level. A transaction will be committed when * this policy decides to complete. Defaults to a {@link SimpleCompletionPolicy} with chunk size equal to the * commitInterval property. - * + * * @param chunkCompletionPolicy the chunkCompletionPolicy to set */ public void setChunkCompletionPolicy(CompletionPolicy chunkCompletionPolicy) { @@ -834,7 +835,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Set the commit interval. Either set this or the chunkCompletionPolicy but not both. - * + * * @param commitInterval 1 by default */ public void setCommitInterval(int commitInterval) { @@ -844,7 +845,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Flag to signal that the reader is transactional (usually a JMS consumer) so that items are re-presented after a * rollback. The default is false and readers are assumed to be forward-only. - * + * * @param isReaderTransactionalQueue the value of the flag */ public void setIsReaderTransactionalQueue(boolean isReaderTransactionalQueue) { @@ -854,7 +855,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Flag to signal that the processor is transactional, in which case it should be called for every item in every * transaction. If false then we can cache the processor results between transactions in the case of a rollback. - * + * * @param processorTransactional the value to set */ public void setProcessorTransactional(Boolean processorTransactional) { @@ -864,7 +865,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for the retry limit. Each item can be retried up to this limit. Note this limit includes the * initial attempt to process the item, therefore retryLimit == 1 by default. - * + * * @param retryLimit the retry limit to set, must be greater or equal to 1. */ public void setRetryLimit(int retryLimit) { @@ -875,7 +876,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { * Public setter for a limit that determines skip policy. If this value is positive then an exception in chunk * processing will cause the item to be skipped and no exception propagated until the limit is reached. If it is * zero then all exceptions will be propagated from the chunk and cause the step to abort. - * + * * @param skipLimit the value to set. Default is 0 (never skip). */ public void setSkipLimit(int skipLimit) { @@ -884,7 +885,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for a skip policy. If this value is set then the skip limit and skippable exceptions are ignored. - * + * * @param skipPolicy the {@link SkipPolicy} to set */ public void setSkipPolicy(SkipPolicy skipPolicy) { @@ -894,7 +895,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for the {@link TaskExecutor}. If this is set, then it will be used to execute the chunk processing * inside the {@link Step}. - * + * * @param taskExecutor the taskExecutor to set */ public void setTaskExecutor(TaskExecutor taskExecutor) { @@ -904,7 +905,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for the throttle limit. This limits the number of tasks queued for concurrent processing to prevent * thread pools from being overwhelmed. Defaults to {@link TaskExecutorRepeatTemplate#DEFAULT_THROTTLE_LIMIT}. - * + * * @param throttleLimit the throttle limit to set. */ public void setThrottleLimit(Integer throttleLimit) { @@ -938,7 +939,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for the {@link RetryListener}s. - * + * * @param retryListeners the {@link RetryListener}s to set */ public void setRetryListeners(RetryListener... retryListeners) { @@ -948,7 +949,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for exception classes that when raised won't crash the job but will result in transaction rollback * and the item which handling caused the exception will be skipped. - * + * * @param exceptionClasses */ public void setSkippableExceptionClasses(Map, Boolean> exceptionClasses) { @@ -957,7 +958,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for exception classes that will retry the item when raised. - * + * * @param retryableExceptionClasses the retryableExceptionClasses to set */ public void setRetryableExceptionClasses(Map, Boolean> retryableExceptionClasses) { @@ -967,7 +968,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { /** * The streams to inject into the {@link Step}. Any instance of {@link ItemStream} can be used, and will then * receive callbacks at the appropriate stage in the step. - * + * * @param streams an array of listeners */ public void setStreams(ItemStream[] streams) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java index 444c9729e..7c1d8c000 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/converter/DefaultJobParametersConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -38,23 +38,23 @@ import org.springframework.util.StringUtils; * convention for property keys. Key names ending with "(<type>)" where * type is one of string, date, long are converted to the corresponding type. * The default type is string. E.g. - * + * *
      * schedule.date(date)=2007/12/11
      * department.id(long)=2345
      * 
    - * + * * The literal values are converted to the correct type using the default Spring * strategies, augmented if necessary by the custom editors provided. - * + * *
    - * + * * If you need to be able to parse and format local-specific dates and numbers, * you can inject formatters ({@link #setDateFormat(DateFormat)} and * {@link #setNumberFormat(NumberFormat)}). - * + * * @author Dave Syer - * + * */ public class DefaultJobParametersConverter implements JobParametersConverter { @@ -77,13 +77,13 @@ public class DefaultJobParametersConverter implements JobParametersConverter { /** * Check for suffix on keys and use those to decide how to convert the * value. - * + * * @throws IllegalArgumentException if a number or date is passed in that * cannot be parsed, or cast to the correct type. - * + * * @see org.springframework.batch.core.converter.JobParametersConverter#getJobParameters(java.util.Properties) */ - @Override + @Override public JobParameters getJobParameters(Properties props) { if (props == null || props.isEmpty()) { @@ -104,7 +104,7 @@ public class DefaultJobParametersConverter implements JobParametersConverter { catch (ParseException ex) { String suffix = (dateFormat instanceof SimpleDateFormat) ? ", use " + ((SimpleDateFormat) dateFormat).toPattern() : ""; - throw new IllegalArgumentException("Date format is invalid: [" + value + "]" + suffix); + throw new IllegalArgumentException("Date format is invalid: [" + value + "]" + suffix); } propertiesBuilder.addDate(StringUtils.replace(key, DATE_TYPE, ""), date); } @@ -144,17 +144,17 @@ public class DefaultJobParametersConverter implements JobParametersConverter { catch (ParseException ex) { String suffix = (numberFormat instanceof DecimalFormat) ? ", use " + ((DecimalFormat) numberFormat).toPattern() : ""; - throw new IllegalArgumentException("Number format is invalid: [" + value + "], use " + suffix); + throw new IllegalArgumentException("Number format is invalid: [" + value + "], use " + suffix); } } /** * Use the same suffixes to create properties (omitting the string suffix * because it is the default). - * + * * @see org.springframework.batch.core.converter.JobParametersConverter#getProperties(org.springframework.batch.core.JobParameters) */ - @Override + @Override public Properties getProperties(JobParameters params) { if (params == null || params.isEmpty()) { @@ -199,7 +199,7 @@ public class DefaultJobParametersConverter implements JobParametersConverter { /** * Public setter for injecting a date format. - * + * * @param dateFormat a {@link DateFormat}, defaults to "yyyy/MM/dd" */ public void setDateFormat(DateFormat dateFormat) { @@ -209,7 +209,7 @@ public class DefaultJobParametersConverter implements JobParametersConverter { /** * Public setter for the {@link NumberFormat}. Used to parse longs and * doubles, so must not contain decimal place (e.g. use "#" or "#,###"). - * + * * @param numberFormat the {@link NumberFormat} to set */ public void setNumberFormat(NumberFormat numberFormat) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/AbstractJobExplorerFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/AbstractJobExplorerFactoryBean.java index 2f097794c..a6219d8d1 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/AbstractJobExplorerFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/AbstractJobExplorerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -27,13 +27,14 @@ import org.springframework.beans.factory.FactoryBean; * A {@link FactoryBean} that automates the creation of a * {@link SimpleJobExplorer}. Declares abstract methods for providing DAO * object implementations. - * + * * @see JobExplorerFactoryBean * @see MapJobExplorerFactoryBean - * + * * @author Dave Syer * @since 2.0 */ +@SuppressWarnings("rawtypes") public abstract class AbstractJobExplorerFactoryBean implements FactoryBean { /** @@ -45,23 +46,23 @@ public abstract class AbstractJobExplorerFactoryBean implements FactoryBean { * @return fully configured {@link JobExecutionDao} implementation. */ protected abstract JobExecutionDao createJobExecutionDao() throws Exception; - + protected abstract StepExecutionDao createStepExecutionDao() throws Exception; protected abstract ExecutionContextDao createExecutionContextDao() throws Exception; /** * The type of object to be returned from {@link #getObject()}. - * + * * @return JobExplorer.class * @see org.springframework.beans.factory.FactoryBean#getObjectType() */ - @Override + @Override public Class getObjectType() { return JobExplorer.class; } - @Override + @Override public boolean isSingleton() { return true; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/JobExplorerFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/JobExplorerFactoryBean.java index 8f5a9c097..f60b57920 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/JobExplorerFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/JobExplorerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2013 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. @@ -48,7 +48,7 @@ import org.springframework.util.Assert; * @since 2.0 */ public class JobExplorerFactoryBean extends AbstractJobExplorerFactoryBean - implements InitializingBean { +implements InitializingBean { private DataSource dataSource; @@ -107,7 +107,7 @@ public class JobExplorerFactoryBean extends AbstractJobExplorerFactoryBean this.lobHandler = lobHandler; } - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(dataSource, "DataSource must not be null."); @@ -169,7 +169,7 @@ public class JobExplorerFactoryBean extends AbstractJobExplorerFactoryBean return dao; } - @Override + @Override public Object getObject() throws Exception { return getTarget(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/MapJobExplorerFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/MapJobExplorerFactoryBean.java index dc967fa2f..b8df7e977 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/MapJobExplorerFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/MapJobExplorerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -28,7 +28,7 @@ import org.springframework.util.Assert; /** * A {@link FactoryBean} that automates the creation of a * {@link SimpleJobExplorer} using in-memory DAO implementations. - * + * * @author Dave Syer * @since 2.0 */ @@ -54,7 +54,7 @@ public class MapJobExplorerFactoryBean extends AbstractJobExplorerFactoryBean im /** * The repository factory that can be used to create daos for the explorer. - * + * * @param repositoryFactory a {@link MapJobExplorerFactoryBean} */ public void setRepositoryFactory(MapJobRepositoryFactoryBean repositoryFactory) { @@ -65,7 +65,7 @@ public class MapJobExplorerFactoryBean extends AbstractJobExplorerFactoryBean im * @throws Exception * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.state(repositoryFactory != null, "A MapJobRepositoryFactoryBean must be provided"); repositoryFactory.afterPropertiesSet(); @@ -91,7 +91,7 @@ public class MapJobExplorerFactoryBean extends AbstractJobExplorerFactoryBean im return repositoryFactory.getExecutionContextDao(); } - @Override + @Override public Object getObject() throws Exception { return new SimpleJobExplorer(createJobInstanceDao(), createJobExecutionDao(), createStepExecutionDao(), createExecutionContextDao()); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java index 145c76cd3..6839d6953 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -30,10 +30,10 @@ import org.springframework.batch.core.repository.dao.StepExecutionDao; /** * Implementation of {@link JobExplorer} using the injected DAOs. - * + * * @author Dave Syer * @author Lucas Ward - * + * * @see JobExplorer * @see JobInstanceDao * @see JobExecutionDao @@ -68,12 +68,12 @@ public class SimpleJobExplorer implements JobExplorer { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.explore.JobExplorer#findJobExecutions( * org.springframework.batch.core.JobInstance) */ - @Override + @Override public List getJobExecutions(JobInstance jobInstance) { List executions = jobExecutionDao.findJobExecutions(jobInstance); for (JobExecution jobExecution : executions) { @@ -87,12 +87,12 @@ public class SimpleJobExplorer implements JobExplorer { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.explore.JobExplorer#findRunningJobExecutions * (java.lang.String) */ - @Override + @Override public Set findRunningJobExecutions(String jobName) { Set executions = jobExecutionDao.findRunningJobExecutions(jobName); for (JobExecution jobExecution : executions) { @@ -106,12 +106,12 @@ public class SimpleJobExplorer implements JobExplorer { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.explore.JobExplorer#getJobExecution(java * .lang.Long) */ - @Override + @Override public JobExecution getJobExecution(Long executionId) { if (executionId == null) { return null; @@ -129,12 +129,12 @@ public class SimpleJobExplorer implements JobExplorer { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.explore.JobExplorer#getStepExecution(java * .lang.Long) */ - @Override + @Override public StepExecution getStepExecution(Long jobExecutionId, Long executionId) { JobExecution jobExecution = jobExecutionDao.getJobExecution(jobExecutionId); if (jobExecution == null) { @@ -147,34 +147,34 @@ public class SimpleJobExplorer implements JobExplorer { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.explore.JobExplorer#getJobInstance(java * .lang.Long) */ - @Override + @Override public JobInstance getJobInstance(Long instanceId) { return jobInstanceDao.getJobInstance(instanceId); } /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.explore.JobExplorer#getLastJobInstances * (java.lang.String, int) */ - @Override + @Override public List getJobInstances(String jobName, int start, int count) { return jobInstanceDao.getJobInstances(jobName, start, count); } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.explore.JobExplorer#getJobNames() */ - @Override + @Override public List getJobNames() { return jobInstanceDao.getJobNames(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java index 3a128b801..b8941b3c5 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -50,12 +50,12 @@ import org.springframework.util.ClassUtils; * such as a {@link JobRepository}, {@link JobExecutionListener}s, and various * configuration parameters are set here. Therefore, common error handling and * listener calling activities are abstracted away from implementations. - * + * * @author Lucas Ward * @author Dave Syer */ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, - InitializingBean { +InitializingBean { protected static final Log logger = LogFactory.getLog(AbstractJob.class); @@ -83,7 +83,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /** * Convenience constructor to immediately add name (which is mandatory but * not final). - * + * * @param name */ public AbstractJob(String name) { @@ -94,7 +94,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /** * A validator for job parameters. Defaults to a vanilla * {@link DefaultJobParametersValidator}. - * + * * @param jobParametersValidator * a validator instance */ @@ -105,10 +105,10 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /** * Assert mandatory properties: {@link JobRepository}. - * + * * @see InitializingBean#afterPropertiesSet() */ - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(jobRepository, "JobRepository must be set"); } @@ -119,10 +119,10 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, * if it is present. Care is needed with bean definition inheritance - if a * parent bean has a name, then its children need an explicit name as well, * otherwise they will not be unique. - * + * * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String) */ - @Override + @Override public void setBeanName(String name) { if (this.name == null) { this.name = name; @@ -132,7 +132,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /** * Set the name property. Always overrides the default value if this object * is a Spring bean. - * + * * @see #setBeanName(java.lang.String) */ public void setName(String name) { @@ -141,10 +141,10 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.IJob#getName() */ - @Override + @Override public String getName() { return name; } @@ -152,22 +152,22 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /** * Retrieve the step with the given name. If there is no Step with the given * name, then return null. - * + * * @param stepName * @return the Step */ - @Override + @Override public abstract Step getStep(String stepName); /** * Retrieve the step names. - * + * * @return the step names */ - @Override + @Override public abstract Collection getStepNames(); - @Override + @Override public JobParametersValidator getJobParametersValidator() { return jobParametersValidator; } @@ -175,7 +175,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /** * Boolean flag to prevent categorically a job from restarting, even if it * has failed previously. - * + * * @param restartable * the value of the flag to set (default true) */ @@ -186,14 +186,14 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /** * @see Job#isRestartable() */ - @Override + @Override public boolean isRestartable() { return restartable; } /** * Public setter for the {@link JobParametersIncrementer}. - * + * * @param jobParametersIncrementer * the {@link JobParametersIncrementer} to set */ @@ -204,10 +204,10 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.Job#getJobParametersIncrementer() */ - @Override + @Override public JobParametersIncrementer getJobParametersIncrementer() { return this.jobParametersIncrementer; } @@ -215,7 +215,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /** * Public setter for injecting {@link JobExecutionListener}s. They will all * be given the listener callbacks at the appropriate point in the job. - * + * * @param listeners * the listeners to set. */ @@ -228,7 +228,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /** * Register a single listener for the {@link JobExecutionListener} * callbacks. - * + * * @param listener * a {@link JobExecutionListener} */ @@ -240,7 +240,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, * Public setter for the {@link JobRepository} that is needed to manage the * state of the batch meta domain (jobs, steps, executions) during the life * of a job. - * + * * @param jobRepository */ public void setJobRepository(JobRepository jobRepository) { @@ -250,7 +250,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /** * Convenience method for subclasses to access the job repository. - * + * * @return the jobRepository */ protected JobRepository getJobRepository() { @@ -262,10 +262,10 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, * logic and ignore listeners and repository calls. Implementations usually * are concerned with the ordering of steps, and delegate actual step * processing to {@link #handleStep(Step, JobExecution)}. - * + * * @param execution * the current {@link JobExecution} - * + * * @throws JobExecutionException * to signal a fatal batch framework error (not a business or * validation exception) @@ -276,12 +276,12 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /** * Run the specified job, handling all listener and repository calls, and * delegating the actual processing to {@link #doExecute(JobExecution)}. - * + * * @see Job#execute(JobExecution) * @throws StartLimitExceededException * if start limit of one of the steps was exceeded */ - @Override + @Override public final void execute(JobExecution execution) { logger.debug("Job execution starting: " + execution); @@ -334,8 +334,8 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, && execution.getStepExecutions().isEmpty()) { ExitStatus exitStatus = execution.getExitStatus(); execution - .setExitStatus(exitStatus.and(ExitStatus.NOOP - .addExitDescription("All steps already completed or no steps configured for this job."))); + .setExitStatus(exitStatus.and(ExitStatus.NOOP + .addExitDescription("All steps already completed or no steps configured for this job."))); } execution.setEndTime(new Date()); @@ -358,13 +358,13 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, * method do not need access to the {@link JobRepository}, nor do they need * to worry about populating the execution context on a restart, nor * detecting the interrupted state (in job or step execution). - * + * * @param step * the {@link Step} to execute * @param execution * the current {@link JobExecution} * @return the {@link StepExecution} corresponding to this step - * + * * @throws JobInterruptedException * if the {@link JobExecution} has been interrupted, and in * particular if {@link BatchStatus#ABANDONED} or @@ -384,7 +384,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, /** * Default mapping from throwable to {@link ExitStatus}. - * + * * @param ex * the cause of the failure * @return an {@link ExitStatus} @@ -411,7 +411,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, jobRepository.update(jobExecution); } - @Override + @Override public String toString() { return ClassUtils.getShortName(getClass()) + ": [name=" + name + "]"; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/CompositeJobParametersValidator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/CompositeJobParametersValidator.java index 601193e69..c8e449aec 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/CompositeJobParametersValidator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/CompositeJobParametersValidator.java @@ -1,5 +1,5 @@ /* - * Copyright 2011 the original author or authors. + * Copyright 2011-2013 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. @@ -25,29 +25,29 @@ import org.springframework.util.Assert; /** * Composite {@link JobParametersValidator} that passes the job parameters through a sequence of - * injected JobParametersValidators - * + * injected JobParametersValidators + * * @author Morten Andersen-Gott * */ public class CompositeJobParametersValidator implements JobParametersValidator, InitializingBean { private List validators; - + /** * Validates the JobParameters according to the injected JobParameterValidators * Validation stops and exception is thrown on first validation error - * + * * @param parameters some {@link JobParameters} * @throws JobParametersInvalidException if the parameters are invalid */ - @Override + @Override public void validate(JobParameters parameters) throws JobParametersInvalidException { for (JobParametersValidator validator : validators) { validator.validate(parameters); } } - + /** * Public setter for the validators * @param validators @@ -56,12 +56,12 @@ public class CompositeJobParametersValidator implements JobParametersValidator, this.validators = validators; } - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(validators, "The 'validators' may not be null"); Assert.notEmpty(validators, "The 'validators' may not be empty"); } - - + + } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/DefaultJobParametersValidator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/DefaultJobParametersValidator.java index c66cb43ff..2e81f4731 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/DefaultJobParametersValidator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/DefaultJobParametersValidator.java @@ -1,3 +1,18 @@ +/* + * Copyright 2012-2013 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.core.job; import java.util.Arrays; @@ -13,9 +28,9 @@ import org.springframework.util.Assert; /** * Default implementation of {@link JobParametersValidator}. - * + * * @author Dave Syer - * + * */ public class DefaultJobParametersValidator implements JobParametersValidator, InitializingBean { @@ -33,10 +48,10 @@ public class DefaultJobParametersValidator implements JobParametersValidator, In /** * Create a new validator with the required and optional job parameter keys * provided. - * + * * @see DefaultJobParametersValidator#setOptionalKeys(String[]) * @see DefaultJobParametersValidator#setRequiredKeys(String[]) - * + * * @param requiredKeys the required keys * @param optionalKeys the optional keys */ @@ -50,7 +65,7 @@ public class DefaultJobParametersValidator implements JobParametersValidator, In * Check that there are no overlaps between required and optional keys. * @throws IllegalStateException if there is an overlap */ - @Override + @Override public void afterPropertiesSet() throws IllegalStateException { for (String key : requiredKeys) { Assert.state(!optionalKeys.contains(key), "Optional keys canot be required: " + key); @@ -62,12 +77,12 @@ public class DefaultJobParametersValidator implements JobParametersValidator, In * are explicitly specified then all keys must be in that list, or in the * required list. Otherwise all keys that are specified as required must be * present. - * + * * @see JobParametersValidator#validate(JobParameters) - * + * * @throws JobParametersInvalidException if the parameters are not valid */ - @Override + @Override public void validate(JobParameters parameters) throws JobParametersInvalidException { if (parameters == null) { @@ -109,9 +124,9 @@ public class DefaultJobParametersValidator implements JobParametersValidator, In * The keys that are required in the parameters. The default is empty, * meaning that all parameters are optional, unless optional keys are * explicitly specified. - * + * * @param requiredKeys the required key values - * + * * @see #setOptionalKeys(String[]) */ public final void setRequiredKeys(String[] requiredKeys) { @@ -123,9 +138,9 @@ public class DefaultJobParametersValidator implements JobParametersValidator, In * optional, then to be valid all other keys must be explicitly required. * The default is empty, meaning that all parameters that are not required * are optional. - * + * * @param optionalKeys the optional key values - * + * * @see #setRequiredKeys(String[]) */ public final void setOptionalKeys(String[] optionalKeys) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java index 03f37f8c3..3ea13e82a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -34,7 +34,7 @@ import org.springframework.batch.core.repository.JobRestartException; * {@link JobExecution}. Sequentially executes a job by iterating through its * list of steps. Any {@link Step} that fails will fail the job. The job is * considered complete when all steps have been executed. - * + * * @author Lucas Ward * @author Dave Syer */ @@ -59,7 +59,7 @@ public class SimpleJob extends AbstractJob { /** * Public setter for the steps in this job. Overrides any calls to * {@link #addStep(Step)}. - * + * * @param steps the steps to execute */ public void setSteps(List steps) { @@ -69,10 +69,10 @@ public class SimpleJob extends AbstractJob { /** * Convenience method for clients to inspect the steps for this job. - * + * * @return the step names for this job */ - @Override + @Override public Collection getStepNames() { List names = new ArrayList(); for (Step step : steps) { @@ -83,7 +83,7 @@ public class SimpleJob extends AbstractJob { /** * Convenience method for adding a single step to the job. - * + * * @param step a {@link Step} to add */ public void addStep(Step step) { @@ -92,11 +92,11 @@ public class SimpleJob extends AbstractJob { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.job.AbstractJob#getStep(java.lang.String) */ - @Override + @Override public Step getStep(String stepName) { for (Step step : this.steps) { if (step.getName().equals(stepName)) { @@ -110,14 +110,14 @@ public class SimpleJob extends AbstractJob { * Handler of steps sequentially as provided, checking each one for success * before moving to the next. Returns the last {@link StepExecution} * successfully processed if it exists, and null if none were processed. - * + * * @param execution the current {@link JobExecution} - * + * * @see AbstractJob#handleStep(Step, JobExecution) */ - @Override + @Override protected void doExecute(JobExecution execution) throws JobInterruptedException, JobRestartException, - StartLimitExceededException { + StartLimitExceededException { StepExecution stepExecution = null; for (Step step : steps) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleStepHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleStepHandler.java index 71dba7d51..21a494085 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleStepHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleStepHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -34,9 +34,9 @@ import org.springframework.util.Assert; /** * Implementation of {@link StepHandler} that manages repository and restart * concerns. - * + * * @author Dave Syer - * + * */ public class SimpleStepHandler implements StepHandler, InitializingBean { @@ -71,10 +71,10 @@ public class SimpleStepHandler implements StepHandler, InitializingBean { /** * Check mandatory properties (jobRepository). - * + * * @see InitializingBean#afterPropertiesSet() */ - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.state(jobRepository != null, "A JobRepository must be provided"); } @@ -89,16 +89,16 @@ public class SimpleStepHandler implements StepHandler, InitializingBean { /** * A context containing values to be added to the step execution before it * is handled. - * + * * @param executionContext the execution context to set */ public void setExecutionContext(ExecutionContext executionContext) { this.executionContext = executionContext; } - @Override + @Override public StepExecution handleStep(Step step, JobExecution execution) throws JobInterruptedException, - JobRestartException, StartLimitExceededException { + JobRestartException, StartLimitExceededException { if (execution.isStopping()) { throw new JobInterruptedException("JobExecution interrupted."); } @@ -178,7 +178,7 @@ public class SimpleStepHandler implements StepHandler, InitializingBean { * @param lastStepExecution the last step execution * @param jobInstance * @param step - * + * * @throws StartLimitExceededException if the start limit has been exceeded * for this step * @throws JobRestartException if the job is in an inconsistent state from diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/JobFlowBuilder.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/JobFlowBuilder.java index 3a6730056..091ebece1 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/JobFlowBuilder.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/builder/JobFlowBuilder.java @@ -21,7 +21,7 @@ import org.springframework.batch.core.job.flow.JobExecutionDecider; /** * @author Dave Syer - * + * */ public class JobFlowBuilder extends FlowBuilder { @@ -53,10 +53,10 @@ public class JobFlowBuilder extends FlowBuilder { /** * Build a flow and inject it into the parent builder. The parent builder is then returned so it can be enhanced * before building an actual job. Normally called explicitly via {@link #end()}. - * + * * @see org.springframework.batch.core.job.builder.FlowBuilder#build() */ - @Override + @Override public FlowJobBuilder build() { Flow flow = flow(); parent.flow(flow); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecution.java index 2b28f9de9..c20c35612 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecution.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -51,13 +51,13 @@ public class FlowExecution implements Comparable { /** * Create an ordering on {@link FlowExecution} instances by comparing their * statuses. - * + * * @see Comparable#compareTo(Object) - * + * * @param other * @return negative, zero or positive as per the contract */ - @Override + @Override public int compareTo(FlowExecution other) { return this.status.compareTo(other.getStatus()); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecutionStatus.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecutionStatus.java index 776f75905..24416fe93 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecutionStatus.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowExecutionStatus.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -17,7 +17,7 @@ package org.springframework.batch.core.job.flow; /** * Represents the status of {@link FlowExecution}. - * + * * @author Dan Garrette * @author Dave Syer * @since 2.0 @@ -101,13 +101,13 @@ public class FlowExecutionStatus implements Comparable { /** * Create an ordering on {@link FlowExecutionStatus} instances by comparing * their statuses. - * + * * @see Comparable#compareTo(Object) - * + * * @param other * @return negative, zero or positive as per the contract */ - @Override + @Override public int compareTo(FlowExecutionStatus other) { Status one = Status.match(this.name); Status two = Status.match(other.name); @@ -120,7 +120,7 @@ public class FlowExecutionStatus implements Comparable { /** * Check the equality of the statuses. - * + * * @see java.lang.Object#equals(java.lang.Object) */ @Override diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/JobFlowExecutor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/JobFlowExecutor.java index af9d10c02..35eb94382 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/JobFlowExecutor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/JobFlowExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -30,9 +30,9 @@ import org.springframework.batch.core.repository.JobRestartException; /** * Implementation of {@link FlowExecutor} for use in components that need to * execute a flow related to a {@link JobExecution}. - * + * * @author Dave Syer - * + * */ public class JobFlowExecutor implements FlowExecutor { @@ -56,13 +56,13 @@ public class JobFlowExecutor implements FlowExecutor { stepExecutionHolder.set(null); } - @Override + @Override public String executeStep(Step step) throws JobInterruptedException, JobRestartException, - StartLimitExceededException { + StartLimitExceededException { StepExecution stepExecution = stepHandler.handleStep(step, execution); stepExecutionHolder.set(stepExecution); if (stepExecution == null) { - return ExitStatus.COMPLETED.getExitCode(); + return ExitStatus.COMPLETED.getExitCode(); } if (stepExecution.isTerminateOnly()) { throw new JobInterruptedException("Step requested termination: "+stepExecution, stepExecution.getStatus()); @@ -70,7 +70,7 @@ public class JobFlowExecutor implements FlowExecutor { return stepExecution.getExitStatus().getExitCode(); } - @Override + @Override public void abandonStepExecution() { StepExecution lastStepExecution = stepExecutionHolder.get(); if (lastStepExecution != null && lastStepExecution.getStatus().isGreaterThan(BatchStatus.STOPPING)) { @@ -79,29 +79,29 @@ public class JobFlowExecutor implements FlowExecutor { } } - @Override + @Override public void updateJobExecutionStatus(FlowExecutionStatus status) { execution.setStatus(findBatchStatus(status)); exitStatus = exitStatus.and(new ExitStatus(status.getName())); execution.setExitStatus(exitStatus); } - @Override + @Override public JobExecution getJobExecution() { return execution; } - @Override + @Override public StepExecution getStepExecution() { return stepExecutionHolder.get(); } - @Override + @Override public void close(FlowExecution result) { stepExecutionHolder.set(null); } - @Override + @Override public boolean isRestart() { if (getStepExecution() != null && getStepExecution().getStatus() == BatchStatus.ABANDONED) { /* @@ -114,7 +114,7 @@ public class JobFlowExecutor implements FlowExecutor { return execution.getStepExecutions().isEmpty(); } - @Override + @Override public void addExitStatus(String code) { exitStatus = exitStatus.and(new ExitStatus(code)); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/SimpleFlow.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/SimpleFlow.java index 489ec78c6..08d2f460c 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/SimpleFlow.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/SimpleFlow.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -43,7 +43,7 @@ import org.springframework.beans.factory.InitializingBean; * particular order). The start state name can be specified explicitly (and must * exist in the set of transitions), or computed from the existing transitions, * if unambiguous. - * + * * @author Dave Syer * @since 2.0 */ @@ -63,7 +63,7 @@ public class SimpleFlow implements Flow, InitializingBean { /** * Create a flow with the given name. - * + * * @param name the name of the flow */ public SimpleFlow(String name) { @@ -72,17 +72,17 @@ public class SimpleFlow implements Flow, InitializingBean { /** * Get the name for this flow. - * + * * @see Flow#getName() */ - @Override + @Override public String getName() { return name; } /** * Public setter for the stateTransitions. - * + * * @param stateTransitions the stateTransitions to set */ public void setStateTransitions(List stateTransitions) { @@ -93,25 +93,25 @@ public class SimpleFlow implements Flow, InitializingBean { /** * {@inheritDoc} */ - @Override + @Override public State getState(String stateName) { return stateMap.get(stateName); } - + /** * {@inheritDoc} */ - @Override + @Override public Collection getStates() { return new HashSet(stateMap.values()); } /** * Locate start state and pre-populate data structures needed for execution. - * + * * @see InitializingBean#afterPropertiesSet() */ - @Override + @Override public void afterPropertiesSet() throws Exception { initializeTransitions(); } @@ -119,7 +119,7 @@ public class SimpleFlow implements Flow, InitializingBean { /** * @see Flow#start(FlowExecutor) */ - @Override + @Override public FlowExecution start(FlowExecutor executor) throws FlowExecutionException { if (startState == null) { initializeTransitions(); @@ -132,7 +132,7 @@ public class SimpleFlow implements Flow, InitializingBean { /** * @see Flow#resume(String, FlowExecutor) */ - @Override + @Override public FlowExecution resume(String stateName, FlowExecutor executor) throws FlowExecutionException { FlowExecutionStatus status = FlowExecutionStatus.UNKNOWN; @@ -158,7 +158,7 @@ public class SimpleFlow implements Flow, InitializingBean { throw new FlowExecutionException(String.format("Ended flow=%s at state=%s with exception", name, stateName), e); } - + logger.debug("Completed state="+stateName+" with status="+status); state = nextState(stateName, status); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/StateTransition.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/StateTransition.java index 5cbc2e5f7..4afafcead 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/StateTransition.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/StateTransition.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -26,7 +26,7 @@ import org.springframework.util.StringUtils; * another. The originating State name and the next {@link State} to execute are * linked by a pattern for the {@link ExitStatus#getExitCode() exit code} of an * execution of the originating State. - * + * * @author Dave Syer * @since 2.0 */ @@ -42,7 +42,7 @@ public final class StateTransition implements Comparable { * Create a new end state {@link StateTransition} specification. This * transition explicitly goes unconditionally to an end state (i.e. no more * executions). - * + * * @param state the {@link State} used to generate the outcome for this * transition */ @@ -54,7 +54,7 @@ public final class StateTransition implements Comparable { * Create a new end state {@link StateTransition} specification. This * transition explicitly goes to an end state (i.e. no more processing) if * the outcome matches the pattern. - * + * * @param state the {@link State} used to generate the outcome for this * transition * @param pattern the pattern to match in the exit status of the @@ -67,11 +67,11 @@ public final class StateTransition implements Comparable { /** * Convenience method to switch the origin and destination of a transition, * creating a new instance. - * + * * @param stateTransition an existing state transition * @param state the new state for the origin * @param next the new name for the destination - * + * * @return a {@link StateTransition} */ public static StateTransition switchOriginAndDestination(StateTransition stateTransition, State state, String next) { @@ -81,7 +81,7 @@ public final class StateTransition implements Comparable { /** * Create a new state {@link StateTransition} specification with a wildcard * pattern that matches all outcomes. - * + * * @param state the {@link State} used to generate the outcome for this * transition * @param next the name of the next {@link State} to execute @@ -93,7 +93,7 @@ public final class StateTransition implements Comparable { /** * Create a new {@link StateTransition} specification from one {@link State} * to another (by name). - * + * * @param state the {@link State} used to generate the outcome for this * transition * @param pattern the pattern to match in the exit status of the @@ -141,7 +141,7 @@ public final class StateTransition implements Comparable { /** * Check if the provided status matches the pattern, signalling that the * next State should be executed. - * + * * @param status the status to compare * @return true if the pattern matches this status */ @@ -151,7 +151,7 @@ public final class StateTransition implements Comparable { /** * Check for a special next State signalling the end of a job. - * + * * @return true if this transition goes nowhere (there is no next) */ public boolean isEnd() { @@ -165,7 +165,7 @@ public final class StateTransition implements Comparable { * fo? > foo. * @see Comparable#compareTo(Object) */ - @Override + @Override public int compareTo(StateTransition other) { String value = other.pattern; if (pattern.equals(value)) { @@ -192,7 +192,7 @@ public final class StateTransition implements Comparable { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/AbstractState.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/AbstractState.java index 560d39128..ee531dfa7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/AbstractState.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/AbstractState.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -25,21 +25,21 @@ import org.springframework.batch.core.job.flow.State; * @since 2.0 */ public abstract class AbstractState implements State { - + private final String name; /** - * + * */ public AbstractState(String name) { this.name = name; } - @Override + @Override public String getName() { return name; } - + /* (non-Javadoc) * @see java.lang.Object#toString() */ @@ -47,8 +47,8 @@ public abstract class AbstractState implements State { public String toString() { return getClass().getSimpleName()+": name=["+name+"]"; } - - @Override + + @Override public abstract FlowExecutionStatus handle(FlowExecutor executor) throws Exception; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/DecisionState.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/DecisionState.java index 687a9efaa..704ebba5b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/DecisionState.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/DecisionState.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -22,7 +22,7 @@ import org.springframework.batch.core.job.flow.JobExecutionDecider; /** * State that requires a decider to make the status decision. - * + * * @author Dave Syer * @since 2.0 */ @@ -42,11 +42,11 @@ public class DecisionState extends AbstractState { public FlowExecutionStatus handle(FlowExecutor executor) throws Exception { return decider.decide(executor.getJobExecution(), executor.getStepExecution()); } - + /* (non-Javadoc) * @see org.springframework.batch.core.job.flow.State#isEndState() */ - @Override + @Override public boolean isEndState() { return false; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/EndState.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/EndState.java index 7cabbc553..c8782ff31 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/EndState.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/EndState.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -25,7 +25,7 @@ import org.springframework.batch.core.job.flow.State; /** * {@link State} implementation for ending a job if it is in progress and * continuing if just starting. - * + * * @author Dave Syer * @since 2.0 */ @@ -58,7 +58,7 @@ public class EndState extends AbstractState { * @param name The name of the state * @param abandon flag to indicate that previous step execution can be * marked as abandoned (if there is one) - * + * */ public EndState(FlowExecutionStatus status, String code, String name, boolean abandon) { super(name); @@ -69,7 +69,7 @@ public class EndState extends AbstractState { /** * Return the {@link FlowExecutionStatus} stored. - * + * * @see State#handle(FlowExecutor) */ @Override @@ -116,17 +116,17 @@ public class EndState extends AbstractState { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.job.flow.State#isEndState() */ - @Override + @Override public boolean isEndState() { return !status.isStop(); } /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/FlowState.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/FlowState.java index 238ff8ad5..4c75971e9 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/FlowState.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/FlowState.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -26,7 +26,7 @@ import org.springframework.batch.core.job.flow.FlowHolder; /** * State that delegates to a Flow - * + * * @author Dave Syer * @since 2.0 */ @@ -41,11 +41,11 @@ public class FlowState extends AbstractState implements FlowHolder { super(name); this.flow = flow; } - + /** * @return the flows */ - @Override + @Override public Collection getFlows() { return Collections.singleton(flow); } @@ -54,11 +54,11 @@ public class FlowState extends AbstractState implements FlowHolder { public FlowExecutionStatus handle(FlowExecutor executor) throws Exception { return flow.start(executor).getStatus(); } - + /* (non-Javadoc) * @see org.springframework.batch.core.job.flow.State#isEndState() */ - @Override + @Override public boolean isEndState() { return false; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/MaxValueFlowExecutionAggregator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/MaxValueFlowExecutionAggregator.java index 1a25a9be0..b66b3e275 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/MaxValueFlowExecutionAggregator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/MaxValueFlowExecutionAggregator.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -26,7 +26,7 @@ import org.springframework.batch.core.job.flow.FlowExecutionStatus; * {@link FlowExecutionStatus}', using the status with the high precedence as the * aggregate status. See {@link FlowExecutionStatus} for details on status * precedence. - * + * * @author Dave Syer * @since 2.0 */ @@ -36,10 +36,10 @@ public class MaxValueFlowExecutionAggregator implements FlowExecutionAggregator * Aggregate all of the {@link FlowExecutionStatus}es of the * {@link FlowExecution}s into one status. The aggregate status will be the * status with the highest precedence. - * + * * @see FlowExecutionAggregator#aggregate(Collection) */ - @Override + @Override public FlowExecutionStatus aggregate(Collection executions) { if (executions == null || executions.size() == 0) { return FlowExecutionStatus.UNKNOWN; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/SplitState.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/SplitState.java index 459bb9404..a5e7ed3ae 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/SplitState.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/SplitState.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -36,7 +36,7 @@ import org.springframework.core.task.TaskRejectedException; /** * A {@link State} implementation that splits a {@link Flow} into multiple * parallel subflows. - * + * * @author Dave Syer * @since 2.0 */ @@ -63,11 +63,11 @@ public class SplitState extends AbstractState implements FlowHolder { public void setTaskExecutor(TaskExecutor taskExecutor) { this.taskExecutor = taskExecutor; } - + /** * @return the flows */ - @Override + @Override public Collection getFlows() { return flows; } @@ -75,7 +75,7 @@ public class SplitState extends AbstractState implements FlowHolder { /** * Execute the flows in parallel by passing them to the {@link TaskExecutor} * and wait for all of them to finish before proceeding. - * + * * @see State#handle(FlowExecutor) */ @Override @@ -88,7 +88,7 @@ public class SplitState extends AbstractState implements FlowHolder { for (final Flow flow : flows) { final FutureTask task = new FutureTask(new Callable() { - @Override + @Override public FlowExecution call() throws Exception { return flow.start(executor); } @@ -129,10 +129,10 @@ public class SplitState extends AbstractState implements FlowHolder { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.job.flow.State#isEndState() */ - @Override + @Override public boolean isEndState() { return false; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/StepState.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/StepState.java index 36ce9a334..b319908b4 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/StepState.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/StepState.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -25,7 +25,7 @@ import org.springframework.batch.core.step.StepHolder; /** * {@link State} implementation that delegates to a {@link FlowExecutor} to * execute the specified {@link Step}. - * + * * @author Dave Syer * @since 2.0 */ @@ -63,15 +63,15 @@ public class StepState extends AbstractState implements StepHolder { /** * @return the step */ - @Override + @Override public Step getStep() { return step; } - + /* (non-Javadoc) * @see org.springframework.batch.core.job.flow.State#isEndState() */ - @Override + @Override public boolean isEndState() { return false; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/JobRegistryBackgroundJobRunner.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/JobRegistryBackgroundJobRunner.java index dabe77af0..0cffcdfd7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/JobRegistryBackgroundJobRunner.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/JobRegistryBackgroundJobRunner.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -45,7 +45,7 @@ import org.springframework.util.Assert; * jobs registered, e.g. a JMX MBean wrapper for a {@link JobLauncher}, or a * Quartz trigger. *

    - * + * *

    * With any launch of a batch job within Spring Batch, a Spring context * containing the {@link Job} has to be created. Using this launcher, the jobs @@ -56,9 +56,9 @@ import org.springframework.util.Assert; * {@link JobRegistry}. Therefore, if autowiring fails to set it then an * exception will be thrown. *

    - * + * * @author Dave Syer - * + * */ public class JobRegistryBackgroundJobRunner { @@ -93,16 +93,16 @@ public class JobRegistryBackgroundJobRunner { /** * A loader for the jobs that are going to be registered. - * + * * @param jobLoader the {@link JobLoader} to set */ public void setJobLoader(JobLoader jobLoader) { this.jobLoader = jobLoader; } - + /** * A job registry that can be used to create a job loader (if none is provided). - * + * * @param jobRegistry the {@link JobRegistry} to set */ public void setJobRegistry(JobRegistry jobRegistry) { @@ -155,7 +155,7 @@ public class JobRegistryBackgroundJobRunner { String[] names = parentContext.getBeanNamesForType(JobLoader.class); if (names.length == 0) { if (parentContext.containsBean("jobLoader")) { - jobLoader = (JobLoader) parentContext.getBean("jobLoader", JobLoader.class); + jobLoader = parentContext.getBean("jobLoader", JobLoader.class); return; } if (jobRegistry != null) { @@ -164,7 +164,7 @@ public class JobRegistryBackgroundJobRunner { } } - jobLoader = (JobLoader) parentContext.getBean(names[0], JobLoader.class); + jobLoader = parentContext.getBean(names[0], JobLoader.class); return; } @@ -175,20 +175,20 @@ public class JobRegistryBackgroundJobRunner { * {@link JobRegistry} and the child contexts are expected to contain * {@link Job} definitions, each of which will be registered wit the * registry. - * + * * Example usage: - * + * *
     	 * $ java -classpath ... JobRegistryBackgroundJobRunner job-registry-context.xml job1.xml job2.xml ...
     	 * 
    - * + * * The child contexts are created only when needed though the * {@link JobFactory} interface (but the XML is validated on startup by * using it to create a {@link BeanFactory} which is then discarded). - * + * * The parent context is created in a separate thread, and the program will * pause for input in an infinite loop until the user hits any key. - * + * * @param args the context locations to use (first one is for parent) * @throws Exception if anything goes wrong with the context creation */ @@ -202,7 +202,7 @@ public class JobRegistryBackgroundJobRunner { logger.info("Starting job registry in parent context from XML at: [" + args[0] + "]"); new Thread(new Runnable() { - @Override + @Override public void run() { try { launcher.run(); @@ -241,7 +241,7 @@ public class JobRegistryBackgroundJobRunner { synchronized (JobRegistryBackgroundJobRunner.class) { System.out - .println("Started application. Interrupt (CTRL-C) or call JobRegistryBackgroundJobRunner.stop() to exit."); + .println("Started application. Interrupt (CTRL-C) or call JobRegistryBackgroundJobRunner.stop() to exit."); JobRegistryBackgroundJobRunner.class.wait(); } launcher.destroy(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/JvmSystemExiter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/JvmSystemExiter.java index 6d3b6d8d9..733d15b04 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/JvmSystemExiter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/JvmSystemExiter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -20,10 +20,10 @@ package org.springframework.batch.core.launch.support; * System.exit method. It should be noted that there will be no unit tests for * this class, since there is only one line of actual code, that would only be * testable by mocking System or Runtime. - * + * * @author Lucas Ward * @author Dave Syer - * + * */ public class JvmSystemExiter implements SystemExiter { @@ -31,10 +31,10 @@ public class JvmSystemExiter implements SystemExiter { * Delegate call to System.exit() with the argument provided. This should only * be used in a scenario where a particular status needs to be returned to * a Batch scheduler. - * + * * @see org.springframework.batch.core.launch.support.SystemExiter#exit(int) */ - @Override + @Override public void exit(int status) { System.exit(status); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/RunIdIncrementer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/RunIdIncrementer.java index 9a0d8f82d..25abace0a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/RunIdIncrementer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/RunIdIncrementer.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -25,12 +25,12 @@ import org.springframework.batch.core.JobParametersIncrementer; public class RunIdIncrementer implements JobParametersIncrementer { private static String RUN_ID_KEY = "run.id"; - + private String key = RUN_ID_KEY; - + /** * The name of the run id in the job parameters. Defaults to "run.id". - * + * * @param key the key to set */ public void setKey(String key) { @@ -40,11 +40,11 @@ public class RunIdIncrementer implements JobParametersIncrementer { /** * Increment the run.id parameter (starting with 1). */ - @Override + @Override public JobParameters getNext(JobParameters parameters) { - + JobParameters params = (parameters == null) ? new JobParameters() : parameters; - + long id = params.getLong(key, 0L) + 1; return new JobParametersBuilder(params).addLong(key, id).toJobParameters(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/RuntimeExceptionTranslator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/RuntimeExceptionTranslator.java index 352e43946..3b30b8bbf 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/RuntimeExceptionTranslator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/RuntimeExceptionTranslator.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -27,7 +27,7 @@ public class RuntimeExceptionTranslator implements MethodInterceptor { /* (non-Javadoc) * @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation) */ - @Override + @Override public Object invoke(MethodInvocation invocation) throws Throwable { try { return invocation.proceed(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/ScheduledJobParametersFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/ScheduledJobParametersFactory.java index ee2fa4e7a..520990817 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/ScheduledJobParametersFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/ScheduledJobParametersFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -20,8 +20,8 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; -import java.util.Properties; import java.util.Map.Entry; +import java.util.Properties; import org.springframework.batch.core.JobParameter; import org.springframework.batch.core.JobParameters; @@ -30,7 +30,7 @@ import org.springframework.batch.core.converter.JobParametersConverter; /** * @author Lucas Ward - * + * */ public class ScheduledJobParametersFactory implements JobParametersConverter { @@ -40,10 +40,10 @@ public class ScheduledJobParametersFactory implements JobParametersConverter { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.runtime.JobParametersFactory#getJobParameters(java.util.Properties) */ - @Override + @Override public JobParameters getJobParameters(Properties props) { if (props == null || props.isEmpty()) { @@ -71,10 +71,10 @@ public class ScheduledJobParametersFactory implements JobParametersConverter { /** * Convert schedule date to Date, and assume all other parameters can be represented by their default string value. - * + * * @see org.springframework.batch.core.converter.JobParametersConverter#getProperties(org.springframework.batch.core.JobParameters) */ - @Override + @Override public Properties getProperties(JobParameters params) { if (params == null || params.isEmpty()) { @@ -97,7 +97,7 @@ public class ScheduledJobParametersFactory implements JobParametersConverter { /** * Public setter for injecting a date format. - * + * * @param dateFormat a {@link DateFormat}, defaults to "yyyy/MM/dd" */ public void setDateFormat(DateFormat dateFormat) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobLauncher.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobLauncher.java index 64e43a03d..68e3d2df3 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobLauncher.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobLauncher.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -44,18 +44,18 @@ import org.springframework.util.Assert; * be taken to ensure any users of this class understand fully whether or not * the implementation of TaskExecutor used will start tasks synchronously or * asynchronously. The default setting uses a synchronous task executor. - * + * * There is only one required dependency of this Launcher, a * {@link JobRepository}. The JobRepository is used to obtain a valid * JobExecution. The Repository must be used because the provided {@link Job} * could be a restart of an existing {@link JobInstance}, and only the * Repository can reliably recreate it. - * + * * @author Lucas Ward * @Author Dave Syer - * + * * @since 1.0 - * + * * @see JobRepository * @see TaskExecutor */ @@ -71,7 +71,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean { * Run the provided job with the given {@link JobParameters}. The * {@link JobParameters} will be used to determine if this is an execution * of an existing job instance, or if a new one should be created. - * + * * @param job the job to be run. * @param jobParameters the {@link JobParameters} for this particular * execution. @@ -83,7 +83,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean { * completed successfully * @throws JobParametersInvalidException */ - @Override + @Override public JobExecution run(final Job job, final JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException { @@ -114,7 +114,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean { try { taskExecutor.execute(new Runnable() { - @Override + @Override public void run() { try { logger.info("Job: [" + job + "] launched with the following parameters: [" + jobParameters @@ -155,7 +155,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean { /** * Set the JobRepsitory. - * + * * @param jobRepository */ public void setJobRepository(JobRepository jobRepository) { @@ -164,7 +164,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean { /** * Set the TaskExecutor. (Optional) - * + * * @param taskExecutor */ public void setTaskExecutor(TaskExecutor taskExecutor) { @@ -175,7 +175,7 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean { * Ensure the required dependencies of a {@link JobRepository} have been * set. */ - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.state(jobRepository != null, "A JobRepository has not been set."); if (taskExecutor == null) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java index 75db5bb7e..c57c54492 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -58,17 +58,17 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; /** - * Simple implementation of the JobOperator interface. Due to the amount of + * Simple implementation of the JobOperator interface. Due to the amount of * functionality the implementation is combining, the following dependencies * are required: - * + * *
      *
    • {@link JobLauncher} *
    • {@link JobExplorer} *
    • {@link JobRepository} *
    • {@link JobRegistry} *
    - * + * * @author Dave Syer * @author Lucas Ward * @since 2.0 @@ -76,7 +76,7 @@ import org.springframework.util.Assert; public class SimpleJobOperator implements JobOperator, InitializingBean { /** - * + * */ private static final String ILLEGAL_STATE_MSG = "Illegal state (only happens on a race condition): " + "%s with name=%s and parameters=%s"; @@ -95,10 +95,10 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /** * Check mandatory properties. - * + * * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(jobLauncher, "JobLauncher must be provided"); Assert.notNull(jobRegistry, "JobLocator must be provided"); @@ -144,10 +144,10 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.launch.JobOperator#getExecutions(java.lang.Long) */ - @Override + @Override public List getExecutions(long instanceId) throws NoSuchJobInstanceException { JobInstance jobInstance = jobExplorer.getJobInstance(instanceId); if (jobInstance == null) { @@ -162,20 +162,20 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.launch.JobOperator#getJobNames() */ - @Override + @Override public Set getJobNames() { return new TreeSet(jobRegistry.getJobNames()); } /* * (non-Javadoc) - * + * * @see JobOperator#getLastInstances(String, int, int) */ - @Override + @Override public List getJobInstances(String jobName, int start, int count) throws NoSuchJobException { List list = new ArrayList(); for (JobInstance jobInstance : jobExplorer.getJobInstances(jobName, start, count)) { @@ -189,12 +189,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.launch.JobOperator#getParameters(java. * lang.Long) */ - @Override + @Override public String getParameters(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = findExecutionById(executionId); @@ -204,12 +204,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.launch.JobOperator#getRunningExecutions * (java.lang.String) */ - @Override + @Override public Set getRunningExecutions(String jobName) throws NoSuchJobException { Set set = new LinkedHashSet(); for (JobExecution jobExecution : jobExplorer.findRunningJobExecutions(jobName)) { @@ -223,12 +223,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.launch.JobOperator#getStepExecutionSummaries * (java.lang.Long) */ - @Override + @Override public Map getStepExecutionSummaries(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = findExecutionById(executionId); @@ -241,12 +241,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.launch.JobOperator#getSummary(java.lang * .Long) */ - @Override + @Override public String getSummary(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = findExecutionById(executionId); return jobExecution.toString(); @@ -254,11 +254,11 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.launch.JobOperator#resume(java.lang.Long) */ - @Override + @Override public Long restart(long executionId) throws JobInstanceAlreadyCompleteException, NoSuchJobExecutionException, NoSuchJobException, JobRestartException, JobParametersInvalidException { logger.info("Checking status of job execution with id=" + executionId); @@ -282,12 +282,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.launch.JobOperator#start(java.lang.String, * java.lang.String) */ - @Override + @Override public Long start(String jobName, String parameters) throws NoSuchJobException, JobInstanceAlreadyExistsException, JobParametersInvalidException { logger.info("Checking status of job with name=" + jobName); @@ -324,12 +324,12 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see JobOperator#startNextInstance(String ) */ - @Override + @Override public Long startNextInstance(String jobName) throws NoSuchJobException, JobParametersNotFoundException, - UnexpectedJobExecutionException, JobParametersInvalidException { + UnexpectedJobExecutionException, JobParametersInvalidException { logger.info("Locating parameters for next instance of job with name=" + jobName); @@ -373,11 +373,11 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.launch.JobOperator#stop(java.lang.Long) */ - @Override + @Override @Transactional public boolean stop(long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException { @@ -395,22 +395,22 @@ public class SimpleJobOperator implements JobOperator, InitializingBean { return true; } - @Override - public JobExecution abandon(long jobExecutionId) throws NoSuchJobExecutionException, JobExecutionAlreadyRunningException { - JobExecution jobExecution = findExecutionById(jobExecutionId); + @Override + public JobExecution abandon(long jobExecutionId) throws NoSuchJobExecutionException, JobExecutionAlreadyRunningException { + JobExecution jobExecution = findExecutionById(jobExecutionId); - if (jobExecution.getStatus().isLessThan(BatchStatus.STOPPING)) { - throw new JobExecutionAlreadyRunningException( - "JobExecution is running or complete and therefore cannot be aborted"); - } + if (jobExecution.getStatus().isLessThan(BatchStatus.STOPPING)) { + throw new JobExecutionAlreadyRunningException( + "JobExecution is running or complete and therefore cannot be aborted"); + } - logger.info("Aborting job execution: " + jobExecution); - jobExecution.upgradeStatus(BatchStatus.ABANDONED); - jobExecution.setEndTime(new Date()); - jobRepository.update(jobExecution); + logger.info("Aborting job execution: " + jobExecution); + jobExecution.upgradeStatus(BatchStatus.ABANDONED); + jobExecution.setEndTime(new Date()); + jobRepository.update(jobExecution); - return jobExecution; - } + return jobExecution; + } private JobExecution findExecutionById(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(executionId); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapper.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapper.java index a8337f362..e97776b24 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapper.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -27,7 +27,7 @@ import org.springframework.batch.core.ExitStatus; * An implementation of {@link ExitCodeMapper} that can be configured through a * map from batch exit codes (String) to integer results. Some default entries * are set up to recognise common cases. Any that are injected are added to these. - * + * * @author Stijn Maller * @author Lucas Ward * @author Dave Syer @@ -67,7 +67,7 @@ public class SimpleJvmExitCodeMapper implements ExitCodeMapper { * Framework * @return The exitCode of the Batch Job as known by the JVM */ - @Override + @Override public int intValue(String exitCode) { Integer statusCode = null; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/AbstractListenerFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/AbstractListenerFactoryBean.java index de6f06211..23604e4e4 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/AbstractListenerFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/AbstractListenerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2013 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. @@ -39,7 +39,7 @@ import org.springframework.util.Assert; * {@link FactoryBean} implementation that builds a listener based on the * various lifecycle methods or annotations that are provided. There are three * possible ways of having a method called as part of a listener lifecycle: - * + * *
      *
    • Interface implementation: By implementing any of the subclasses of a * listener interface, methods on said interface will be called @@ -47,7 +47,7 @@ import org.springframework.util.Assert; *
    • String name of the method to be called, which is tied to a * {@link ListenerMetaData} value in the metaDataMap. *
    - * + * * It should be noted that methods obtained by name or annotation that don't * match the listener method signatures to which they belong will cause errors. * However, it is acceptable to have no parameters at all. If the same method is @@ -56,19 +56,20 @@ import org.springframework.util.Assert; * has multiple methods tied to a particular listener, each method will be * called. Also note that the same annotations cannot be applied to two separate * methods in a single class. - * + * * @author Lucas Ward * @author Dan Garrette * @since 2.0 * @see ListenerMetaData */ +@SuppressWarnings("rawtypes") public abstract class AbstractListenerFactoryBean implements FactoryBean, InitializingBean { private Object delegate; private Map metaDataMap; - @Override + @Override public Object getObject() { if (metaDataMap == null) { @@ -102,7 +103,7 @@ public abstract class AbstractListenerFactoryBean implements FactoryBean, Initia if (invoker != null) { invokers.add(invoker); } - + invoker = getMethodInvokerByName(entry.getValue(), delegate, metaData.getParamTypes()); if (invoker != null) { invokers.add(invoker); @@ -175,7 +176,7 @@ public abstract class AbstractListenerFactoryBean implements FactoryBean, Initia } } - @Override + @Override public boolean isSingleton() { return true; } @@ -188,7 +189,7 @@ public abstract class AbstractListenerFactoryBean implements FactoryBean, Initia this.metaDataMap = metaDataMap; } - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(delegate, "Delegate must not be null"); } @@ -196,7 +197,7 @@ public abstract class AbstractListenerFactoryBean implements FactoryBean, Initia /** * Convenience method to check whether the given object is or can be made * into a listener. - * + * * @param target the object to check * @return true if the delegate is an instance of any of the listener * interface, or contains the marker annotations diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ChunkListenerSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ChunkListenerSupport.java index 5e9e55724..8d7979de5 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ChunkListenerSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ChunkListenerSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -19,7 +19,7 @@ import org.springframework.batch.core.ChunkListener; /** * Basic support implementation of {@link ChunkListener} - * + * * @author Lucas Ward * */ @@ -28,14 +28,14 @@ public class ChunkListenerSupport implements ChunkListener { /* (non-Javadoc) * @see org.springframework.batch.core.domain.ChunkListener#afterChunk() */ - @Override + @Override public void afterChunk() { } /* (non-Javadoc) * @see org.springframework.batch.core.domain.ChunkListener#beforeChunk() */ - @Override + @Override public void beforeChunk() { } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeChunkListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeChunkListener.java index a8b81b1a7..2109fba0b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeChunkListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeChunkListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -23,7 +23,7 @@ import org.springframework.core.Ordered; /** * @author Lucas Ward - * + * */ public class CompositeChunkListener implements ChunkListener { @@ -31,7 +31,7 @@ public class CompositeChunkListener implements ChunkListener { /** * Public setter for the listeners. - * + * * @param listeners */ public void setListeners(List listeners) { @@ -40,7 +40,7 @@ public class CompositeChunkListener implements ChunkListener { /** * Register additional listener. - * + * * @param chunkListener */ public void register(ChunkListener chunkListener) { @@ -50,10 +50,10 @@ public class CompositeChunkListener implements ChunkListener { /** * Call the registered listeners in order, respecting and prioritising those * that implement {@link Ordered}. - * + * * @see org.springframework.batch.core.ChunkListener#afterChunk() */ - @Override + @Override public void afterChunk() { for (Iterator iterator = listeners.iterator(); iterator.hasNext();) { ChunkListener listener = iterator.next(); @@ -63,10 +63,10 @@ public class CompositeChunkListener implements ChunkListener { /** * Call the registered listeners in reverse order. - * + * * @see org.springframework.batch.core.ChunkListener#beforeChunk() */ - @Override + @Override public void beforeChunk() { for (Iterator iterator = listeners.reverse(); iterator.hasNext();) { ChunkListener listener = iterator.next(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemProcessListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemProcessListener.java index deee4280d..8a85ac1fb 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemProcessListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemProcessListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -23,7 +23,7 @@ import org.springframework.core.Ordered; /** * @author Dave Syer - * + * */ public class CompositeItemProcessListener implements ItemProcessListener { @@ -31,7 +31,7 @@ public class CompositeItemProcessListener implements ItemProcessListener> itemReadListeners) { @@ -40,7 +40,7 @@ public class CompositeItemProcessListener implements ItemProcessListener itemReaderListener) { @@ -53,7 +53,7 @@ public class CompositeItemProcessListener implements ItemProcessListener> iterator = listeners.reverse(); iterator.hasNext();) { ItemProcessListener listener = iterator.next(); @@ -66,7 +66,7 @@ public class CompositeItemProcessListener implements ItemProcessListener> iterator = listeners.iterator(); iterator.hasNext();) { ItemProcessListener listener = iterator.next(); @@ -80,7 +80,7 @@ public class CompositeItemProcessListener implements ItemProcessListener> iterator = listeners.reverse(); iterator.hasNext();) { ItemProcessListener listener = iterator.next(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemReadListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemReadListener.java index 428edf496..18c782bb7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemReadListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemReadListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -24,7 +24,7 @@ import org.springframework.core.Ordered; /** * @author Lucas Ward * @author Dave Syer - * + * */ public class CompositeItemReadListener implements ItemReadListener { @@ -32,7 +32,7 @@ public class CompositeItemReadListener implements ItemReadListener { /** * Public setter for the listeners. - * + * * @param itemReadListeners */ public void setListeners(List> itemReadListeners) { @@ -41,7 +41,7 @@ public class CompositeItemReadListener implements ItemReadListener { /** * Register additional listener. - * + * * @param itemReaderListener */ public void register(ItemReadListener itemReaderListener) { @@ -53,7 +53,7 @@ public class CompositeItemReadListener implements ItemReadListener { * prioritising those that implement {@link Ordered}. * @see org.springframework.batch.core.ItemReadListener#afterRead(java.lang.Object) */ - @Override + @Override public void afterRead(T item) { for (Iterator> iterator = listeners.reverse(); iterator.hasNext();) { ItemReadListener listener = iterator.next(); @@ -66,7 +66,7 @@ public class CompositeItemReadListener implements ItemReadListener { * that implement {@link Ordered}. * @see org.springframework.batch.core.ItemReadListener#beforeRead() */ - @Override + @Override public void beforeRead() { for (Iterator> iterator = listeners.iterator(); iterator.hasNext();) { ItemReadListener listener = iterator.next(); @@ -79,7 +79,7 @@ public class CompositeItemReadListener implements ItemReadListener { * prioritising those that implement {@link Ordered}. * @see org.springframework.batch.core.ItemReadListener#onReadError(java.lang.Exception) */ - @Override + @Override public void onReadError(Exception ex) { for (Iterator> iterator = listeners.iterator(); iterator.hasNext();) { ItemReadListener listener = iterator.next(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemWriteListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemWriteListener.java index c3d32f17c..d7ecb635e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemWriteListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeItemWriteListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -24,7 +24,7 @@ import org.springframework.core.Ordered; /** * @author Lucas Ward * @author Dave Syer - * + * */ public class CompositeItemWriteListener implements ItemWriteListener { @@ -32,7 +32,7 @@ public class CompositeItemWriteListener implements ItemWriteListener { /** * Public setter for the listeners. - * + * * @param itemWriteListeners */ public void setListeners(List> itemWriteListeners) { @@ -41,7 +41,7 @@ public class CompositeItemWriteListener implements ItemWriteListener { /** * Register additional listener. - * + * * @param itemWriteListener */ public void register(ItemWriteListener itemWriteListener) { @@ -53,7 +53,7 @@ public class CompositeItemWriteListener implements ItemWriteListener { * prioritising those that implement {@link Ordered}. * @see ItemWriteListener#afterWrite(java.util.List) */ - @Override + @Override public void afterWrite(List items) { for (Iterator> iterator = listeners.reverse(); iterator.hasNext();) { ItemWriteListener listener = iterator.next(); @@ -66,7 +66,7 @@ public class CompositeItemWriteListener implements ItemWriteListener { * that implement {@link Ordered}. * @see ItemWriteListener#beforeWrite(List) */ - @Override + @Override public void beforeWrite(List items) { for (Iterator> iterator = listeners.iterator(); iterator.hasNext();) { ItemWriteListener listener = iterator.next(); @@ -79,7 +79,7 @@ public class CompositeItemWriteListener implements ItemWriteListener { * prioritising those that implement {@link Ordered}. * @see ItemWriteListener#onWriteError(Exception, List) */ - @Override + @Override public void onWriteError(Exception ex, List items) { for (Iterator> iterator = listeners.reverse(); iterator.hasNext();) { ItemWriteListener listener = iterator.next(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeJobExecutionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeJobExecutionListener.java index 579a63f7d..699073ec4 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeJobExecutionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeJobExecutionListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -24,7 +24,7 @@ import org.springframework.core.Ordered; /** * @author Dave Syer - * + * */ public class CompositeJobExecutionListener implements JobExecutionListener { @@ -32,7 +32,7 @@ public class CompositeJobExecutionListener implements JobExecutionListener { /** * Public setter for the listeners. - * + * * @param listeners */ public void setListeners(List listeners) { @@ -41,7 +41,7 @@ public class CompositeJobExecutionListener implements JobExecutionListener { /** * Register additional listener. - * + * * @param jobExecutionListener */ public void register(JobExecutionListener jobExecutionListener) { @@ -53,7 +53,7 @@ public class CompositeJobExecutionListener implements JobExecutionListener { * prioritising those that implement {@link Ordered}. * @see org.springframework.batch.core.JobExecutionListener#afterJob(org.springframework.batch.core.JobExecution) */ - @Override + @Override public void afterJob(JobExecution jobExecution) { for (Iterator iterator = listeners.reverse(); iterator.hasNext();) { JobExecutionListener listener = iterator.next(); @@ -66,7 +66,7 @@ public class CompositeJobExecutionListener implements JobExecutionListener { * that implement {@link Ordered}. * @see org.springframework.batch.core.JobExecutionListener#beforeJob(org.springframework.batch.core.JobExecution) */ - @Override + @Override public void beforeJob(JobExecution jobExecution) { for (Iterator iterator = listeners.iterator(); iterator.hasNext();) { JobExecutionListener listener = iterator.next(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeSkipListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeSkipListener.java index 7b99d9cdd..2e39c4e6f 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeSkipListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeSkipListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -23,7 +23,7 @@ import org.springframework.core.Ordered; /** * @author Dave Syer - * + * */ public class CompositeSkipListener implements SkipListener { @@ -31,7 +31,7 @@ public class CompositeSkipListener implements SkipListener { /** * Public setter for the listeners. - * + * * @param listeners */ public void setListeners(List> listeners) { @@ -40,7 +40,7 @@ public class CompositeSkipListener implements SkipListener { /** * Register additional listener. - * + * * @param listener */ public void register(SkipListener listener) { @@ -52,7 +52,7 @@ public class CompositeSkipListener implements SkipListener { * that implement {@link Ordered}. * @see org.springframework.batch.core.SkipListener#onSkipInRead(java.lang.Throwable) */ - @Override + @Override public void onSkipInRead(Throwable t) { for (Iterator> iterator = listeners.iterator(); iterator.hasNext();) { SkipListener listener = iterator.next(); @@ -66,7 +66,7 @@ public class CompositeSkipListener implements SkipListener { * @see org.springframework.batch.core.SkipListener#onSkipInWrite(java.lang.Object, * java.lang.Throwable) */ - @Override + @Override public void onSkipInWrite(S item, Throwable t) { for (Iterator> iterator = listeners.iterator(); iterator.hasNext();) { SkipListener listener = iterator.next(); @@ -80,7 +80,7 @@ public class CompositeSkipListener implements SkipListener { * @see org.springframework.batch.core.SkipListener#onSkipInWrite(java.lang.Object, * java.lang.Throwable) */ - @Override + @Override public void onSkipInProcess(T item, Throwable t) { for (Iterator> iterator = listeners.iterator(); iterator.hasNext();) { SkipListener listener = iterator.next(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeStepExecutionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeStepExecutionListener.java index 12343bfd6..057295100 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeStepExecutionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeStepExecutionListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -26,7 +26,7 @@ import org.springframework.core.Ordered; /** * @author Lucas Ward * @author Dave Syer - * + * */ public class CompositeStepExecutionListener implements StepExecutionListener { @@ -34,7 +34,7 @@ public class CompositeStepExecutionListener implements StepExecutionListener { /** * Public setter for the listeners. - * + * * @param listeners */ public void setListeners(StepExecutionListener[] listeners) { @@ -43,7 +43,7 @@ public class CompositeStepExecutionListener implements StepExecutionListener { /** * Register additional listener. - * + * * @param stepExecutionListener */ public void register(StepExecutionListener stepExecutionListener) { @@ -52,10 +52,10 @@ public class CompositeStepExecutionListener implements StepExecutionListener { /** * Call the registered listeners in reverse order, respecting and - * prioritising those that implement {@link Ordered}. + * prioritizing those that implement {@link Ordered}. * @see org.springframework.batch.core.StepExecutionListener#afterStep(StepExecution) */ - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { ExitStatus status = null; for (Iterator iterator = list.reverse(); iterator.hasNext();) { @@ -67,11 +67,11 @@ public class CompositeStepExecutionListener implements StepExecutionListener { } /** - * Call the registered listeners in order, respecting and prioritising those + * Call the registered listeners in order, respecting and prioritizing those * that implement {@link Ordered}. * @see org.springframework.batch.core.StepExecutionListener#beforeStep(StepExecution) */ - @Override + @Override public void beforeStep(StepExecution stepExecution) { for (Iterator iterator = list.iterator(); iterator.hasNext();) { StepExecutionListener listener = iterator.next(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java index 6b5cbb6e7..0f55912ae 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -29,12 +29,12 @@ import org.springframework.util.Assert; * {@link ExecutionContext} to the {@link Job} {@link ExecutionContext} at the * end of a step. A list of keys should be provided that correspond to the items * in the {@link Step} {@link ExecutionContext} that should be promoted. - * + * * Additionally, an optional list of statuses can be set to indicate for which * exit status codes the promotion should occur. These statuses will be checked * using the {@link PatternMatcher}, so wildcards are allowed. By default, * promotion will only occur for steps with an exit code of "COMPLETED". - * + * * @author Dan Garrette * @since 2.0 */ @@ -46,7 +46,7 @@ public class ExecutionContextPromotionListener extends StepExecutionListenerSupp private boolean strict = false; - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { ExecutionContext stepContext = stepExecution.getExecutionContext(); ExecutionContext jobContext = stepExecution.getJobExecution().getExecutionContext(); @@ -60,7 +60,7 @@ public class ExecutionContextPromotionListener extends StepExecutionListenerSupp if (strict) { throw new IllegalArgumentException("The key [" + key + "] was not found in the Step's ExecutionContext."); - } + } } } break; @@ -70,7 +70,7 @@ public class ExecutionContextPromotionListener extends StepExecutionListenerSupp return null; } - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(this.keys, "The 'keys' property must be provided"); Assert.notEmpty(this.keys, "The 'keys' property must not be empty"); @@ -98,7 +98,7 @@ public class ExecutionContextPromotionListener extends StepExecutionListenerSupp /** * If set to TRUE, the listener will throw an exception if any 'key' is not * found in the Step {@link ExecutionContext}. FALSE by default. - * + * * @param strict */ public void setStrict(boolean strict) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ItemListenerSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ItemListenerSupport.java index c0a2da608..4b305a5b5 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ItemListenerSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ItemListenerSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -26,93 +26,93 @@ import org.springframework.batch.core.ItemWriteListener; * {@link ItemProcessListener}, and {@link ItemWriteListener} interfaces. All * are implemented, since it is very common that all may need to be implemented * at once. - * + * * @author Lucas Ward - * + * */ public class ItemListenerSupport implements ItemReadListener, ItemProcessListener, ItemWriteListener { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.ItemReadListener#afterRead(java.lang.Object) */ - @Override + @Override public void afterRead(I item) { } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.ItemReadListener#beforeRead() */ - @Override + @Override public void beforeRead() { } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.ItemReadListener#onReadError(java.lang.Exception) */ - @Override + @Override public void onReadError(Exception ex) { } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.ItemProcessListener#afterProcess(java.lang.Object, * java.lang.Object) */ - @Override + @Override public void afterProcess(I item, O result) { } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.ItemProcessListener#beforeProcess(java.lang.Object) */ - @Override + @Override public void beforeProcess(I item) { } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.ItemProcessListener#onProcessError(java.lang.Object, * java.lang.Exception) */ - @Override + @Override public void onProcessError(I item, Exception e) { } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.ItemWriteListener#afterWrite() */ - @Override + @Override public void afterWrite(List item) { } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.ItemWriteListener#beforeWrite(java.lang.Object) */ - @Override + @Override public void beforeWrite(List item) { } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.ItemWriteListener#onWriteError(java.lang.Exception, * java.lang.Object) */ - @Override + @Override public void onWriteError(Exception ex, List item) { } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobExecutionListenerSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobExecutionListenerSupport.java index 2e9d5239f..94ea48984 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobExecutionListenerSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobExecutionListenerSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -27,14 +27,14 @@ public class JobExecutionListenerSupport implements JobExecutionListener { /* (non-Javadoc) * @see org.springframework.batch.core.domain.JobListener#afterJob() */ - @Override + @Override public void afterJob(JobExecution jobExecution) { } /* (non-Javadoc) * @see org.springframework.batch.core.domain.JobListener#beforeJob(org.springframework.batch.core.domain.JobExecution) */ - @Override + @Override public void beforeJob(JobExecution jobExecution) { } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobListenerFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobListenerFactoryBean.java index e97f718da..bb39640fc 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobListenerFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobListenerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2013 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. @@ -20,7 +20,7 @@ import org.springframework.batch.core.JobExecutionListener; /** * This {@link AbstractListenerFactoryBean} implementation is used to create a * {@link JobExecutionListener}. - * + * * @author Lucas Ward * @author Dan Garrette * @since 2.0 @@ -29,22 +29,22 @@ import org.springframework.batch.core.JobExecutionListener; */ public class JobListenerFactoryBean extends AbstractListenerFactoryBean { - @Override + @Override protected ListenerMetaData getMetaDataFromPropertyName(String propertyName) { return JobListenerMetaData.fromPropertyName(propertyName); } - @Override + @Override protected ListenerMetaData[] getMetaDataValues() { return JobListenerMetaData.values(); } - @Override + @Override protected Class getDefaultListenerClass() { return JobExecutionListener.class; } - @Override + @Override public Class getObjectType() { return JobExecutionListener.class; } @@ -52,7 +52,7 @@ public class JobListenerFactoryBean extends AbstractListenerFactoryBean { /** * Convenience method to wrap any object and expose the appropriate * {@link JobExecutionListener} interfaces. - * + * * @param delegate a delegate object * @return a JobListener instance constructed from the delegate */ @@ -65,7 +65,7 @@ public class JobListenerFactoryBean extends AbstractListenerFactoryBean { /** * Convenience method to check whether the given object is or can be made * into a {@link JobExecutionListener}. - * + * * @param delegate the object to check * @return true if the delegate is an instance of * {@link JobExecutionListener}, or contains the marker annotations diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobListenerMetaData.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobListenerMetaData.java index 78404a1d8..14d0bd737 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobListenerMetaData.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobListenerMetaData.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2013 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. @@ -27,7 +27,7 @@ import org.springframework.batch.core.annotation.BeforeJob; /** * Enumeration for {@link JobExecutionListener} meta data, which ties together the names * of methods, their interfaces, annotation, and expected arguments. - * + * * @author Lucas Ward * @since 2.0 * @see JobListenerFactoryBean @@ -36,19 +36,19 @@ public enum JobListenerMetaData implements ListenerMetaData { BEFORE_JOB("beforeJob", "before-job-method", BeforeJob.class), AFTER_JOB("afterJob", "after-job-method", AfterJob.class); - - + + private final String methodName; private final String propertyName; private final Class annotation; private static final Map propertyMap; - + JobListenerMetaData(String methodName, String propertyName, Class annotation) { this.methodName = methodName; this.propertyName = propertyName; this.annotation = annotation; } - + static{ propertyMap = new HashMap(); for(JobListenerMetaData metaData : values()){ @@ -56,34 +56,34 @@ public enum JobListenerMetaData implements ListenerMetaData { } } - @Override + @Override public String getMethodName() { return methodName; } - @Override + @Override public Class getAnnotation() { return annotation; } - @Override + @Override public Class getListenerInterface() { return JobExecutionListener.class; } - - @Override + + @Override public String getPropertyName() { return propertyName; } - - @Override + + @Override public Class[] getParamTypes() { return new Class[]{ JobExecution.class }; } /** * Return the relevant meta data for the provided property name. - * + * * @param propertyName * @return meta data with supplied property name, null if none exists. */ diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MethodInvokerMethodInterceptor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MethodInvokerMethodInterceptor.java index 993f5bb9b..ef2673730 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MethodInvokerMethodInterceptor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MethodInvokerMethodInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2013 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. @@ -32,7 +32,7 @@ import org.springframework.batch.support.MethodInvoker; * that isn't void is * {@link StepExecutionListener#afterStep(org.springframework.batch.core.StepExecution)} * , which returns ExitStatus. - * + * * @author Lucas Ward * @since 2.0 * @see MethodInvoker @@ -51,7 +51,7 @@ public class MethodInvokerMethodInterceptor implements MethodInterceptor { this.invokerMap = invokerMap; } - @Override + @Override public Object invoke(MethodInvocation invocation) throws Throwable { String methodName = invocation.getMethod().getName(); @@ -92,7 +92,7 @@ public class MethodInvokerMethodInterceptor implements MethodInterceptor { MethodInvokerMethodInterceptor other = (MethodInvokerMethodInterceptor) obj; return invokerMap.equals(other.invokerMap); } - + /** * {@inheritDoc} */ diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java index bebc48d5b..83eb33171 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2013 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. @@ -33,7 +33,7 @@ import org.springframework.batch.item.ItemStream; * @author Michael Minella */ public class MulticasterBatchListener implements StepExecutionListener, ChunkListener, ItemReadListener, - ItemProcessListener, ItemWriteListener, SkipListener { +ItemProcessListener, ItemWriteListener, SkipListener { private CompositeStepExecutionListener stepListener = new CompositeStepExecutionListener(); @@ -106,7 +106,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @see org.springframework.batch.core.listener.CompositeItemProcessListener#afterProcess(java.lang.Object, * java.lang.Object) */ - @Override + @Override public void afterProcess(T item, S result) { try { itemProcessListener.afterProcess(item, result); @@ -120,7 +120,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @param item * @see org.springframework.batch.core.listener.CompositeItemProcessListener#beforeProcess(java.lang.Object) */ - @Override + @Override public void beforeProcess(T item) { try { itemProcessListener.beforeProcess(item); @@ -136,7 +136,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @see org.springframework.batch.core.listener.CompositeItemProcessListener#onProcessError(java.lang.Object, * java.lang.Exception) */ - @Override + @Override public void onProcessError(T item, Exception ex) { try { itemProcessListener.onProcessError(item, ex); @@ -149,7 +149,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch /** * @see org.springframework.batch.core.listener.CompositeStepExecutionListener#afterStep(StepExecution) */ - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { try { return stepListener.afterStep(stepExecution); @@ -163,7 +163,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @param stepExecution * @see org.springframework.batch.core.listener.CompositeStepExecutionListener#beforeStep(org.springframework.batch.core.StepExecution) */ - @Override + @Override public void beforeStep(StepExecution stepExecution) { try { stepListener.beforeStep(stepExecution); @@ -177,7 +177,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * * @see org.springframework.batch.core.listener.CompositeChunkListener#afterChunk() */ - @Override + @Override public void afterChunk() { try { chunkListener.afterChunk(); @@ -191,7 +191,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * * @see org.springframework.batch.core.listener.CompositeChunkListener#beforeChunk() */ - @Override + @Override public void beforeChunk() { try { chunkListener.beforeChunk(); @@ -205,7 +205,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @param item * @see org.springframework.batch.core.listener.CompositeItemReadListener#afterRead(java.lang.Object) */ - @Override + @Override public void afterRead(T item) { try { itemReadListener.afterRead(item); @@ -219,7 +219,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * * @see org.springframework.batch.core.listener.CompositeItemReadListener#beforeRead() */ - @Override + @Override public void beforeRead() { try { itemReadListener.beforeRead(); @@ -233,7 +233,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @param ex * @see org.springframework.batch.core.listener.CompositeItemReadListener#onReadError(java.lang.Exception) */ - @Override + @Override public void onReadError(Exception ex) { try { itemReadListener.onReadError(ex); @@ -247,7 +247,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * * @see ItemWriteListener#afterWrite(List) */ - @Override + @Override public void afterWrite(List items) { try { itemWriteListener.afterWrite(items); @@ -261,7 +261,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @param items * @see ItemWriteListener#beforeWrite(List) */ - @Override + @Override public void beforeWrite(List items) { try { itemWriteListener.beforeWrite(items); @@ -276,7 +276,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @param items * @see ItemWriteListener#onWriteError(Exception, List) */ - @Override + @Override public void onWriteError(Exception ex, List items) { try { itemWriteListener.onWriteError(ex, items); @@ -290,7 +290,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @param t * @see org.springframework.batch.core.listener.CompositeSkipListener#onSkipInRead(java.lang.Throwable) */ - @Override + @Override public void onSkipInRead(Throwable t) { skipListener.onSkipInRead(t); } @@ -301,7 +301,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @see org.springframework.batch.core.listener.CompositeSkipListener#onSkipInWrite(java.lang.Object, * java.lang.Throwable) */ - @Override + @Override public void onSkipInWrite(S item, Throwable t) { skipListener.onSkipInWrite(item, t); } @@ -312,7 +312,7 @@ public class MulticasterBatchListener implements StepExecutionListener, Ch * @see org.springframework.batch.core.listener.CompositeSkipListener#onSkipInProcess(Object, * Throwable) */ - @Override + @Override public void onSkipInProcess(T item, Throwable t) { skipListener.onSkipInProcess(item, t); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/SkipListenerSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/SkipListenerSupport.java index 185c96b73..4afc57d9d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/SkipListenerSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/SkipListenerSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -19,7 +19,7 @@ import org.springframework.batch.core.SkipListener; /** * Basic no-op implementations of all {@link SkipListener} implementations. - * + * * @author Dave Syer * */ @@ -28,21 +28,21 @@ public class SkipListenerSupport implements SkipListener { /* (non-Javadoc) * @see org.springframework.batch.core.SkipListener#onSkipInRead(java.lang.Throwable) */ - @Override + @Override public void onSkipInRead(Throwable t) { } /* (non-Javadoc) * @see org.springframework.batch.core.SkipListener#onSkipInWrite(java.lang.Object, java.lang.Throwable) */ - @Override + @Override public void onSkipInWrite(S item, Throwable t) { } /* (non-Javadoc) * @see org.springframework.batch.core.SkipListener#onSkipInProcess(java.lang.Object, java.lang.Throwable) */ - @Override + @Override public void onSkipInProcess(T item, Throwable t) { } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepExecutionListenerSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepExecutionListenerSupport.java index d22d2511c..d87b01c12 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepExecutionListenerSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepExecutionListenerSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -28,7 +28,7 @@ public class StepExecutionListenerSupport implements StepExecutionListener { /* (non-Javadoc) * @see org.springframework.batch.core.domain.StepListener#afterStep(StepExecution stepExecution) */ - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; } @@ -36,7 +36,7 @@ public class StepExecutionListenerSupport implements StepExecutionListener { /* (non-Javadoc) * @see org.springframework.batch.core.domain.StepListener#open(org.springframework.batch.item.ExecutionContext) */ - @Override + @Override public void beforeStep(StepExecution stepExecution) { } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerFactoryBean.java index 1dc526c65..e77ef8a60 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2013 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. @@ -20,7 +20,7 @@ import org.springframework.batch.core.StepListener; /** * This {@link AbstractListenerFactoryBean} implementation is used to create a * {@link StepListener}. - * + * * @author Lucas Ward * @author Dan Garrette * @since 2.0 @@ -29,22 +29,22 @@ import org.springframework.batch.core.StepListener; */ public class StepListenerFactoryBean extends AbstractListenerFactoryBean { - @Override + @Override protected ListenerMetaData getMetaDataFromPropertyName(String propertyName) { return StepListenerMetaData.fromPropertyName(propertyName); } - @Override + @Override protected ListenerMetaData[] getMetaDataValues() { return StepListenerMetaData.values(); } - @Override + @Override protected Class getDefaultListenerClass() { return StepListener.class; } - @Override + @Override @SuppressWarnings("rawtypes") public Class getObjectType() { return StepListener.class; @@ -53,7 +53,7 @@ public class StepListenerFactoryBean extends AbstractListenerFactoryBean { /** * Convenience method to wrap any object and expose the appropriate * {@link StepListener} interfaces. - * + * * @param delegate a delegate object * @return a StepListener instance constructed from the delegate */ @@ -66,7 +66,7 @@ public class StepListenerFactoryBean extends AbstractListenerFactoryBean { /** * Convenience method to check whether the given object is or can be made * into a {@link StepListener}. - * + * * @param delegate the object to check * @return true if the delegate is an instance of any of the * {@link StepListener} interfaces, or contains the marker diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerMetaData.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerMetaData.java index 21d2fc035..50a23c371 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerMetaData.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerMetaData.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2013 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. @@ -48,7 +48,7 @@ import org.springframework.batch.core.annotation.OnWriteError; /** * Enumeration for {@link StepListener} meta data, which ties together the names * of methods, their interfaces, annotation, and expected arguments. - * + * * @author Lucas Ward * @since 2.0 * @see StepListenerFactoryBean @@ -71,14 +71,14 @@ public enum StepListenerMetaData implements ListenerMetaData { ON_SKIP_IN_READ("onSkipInRead", "on-skip-in-read-method", OnSkipInRead.class, SkipListener.class, Throwable.class), ON_SKIP_IN_PROCESS("onSkipInProcess", "on-skip-in-process-method", OnSkipInProcess.class, SkipListener.class, Object.class, Throwable.class), ON_SKIP_IN_WRITE("onSkipInWrite", "on-skip-in-write-method", OnSkipInWrite.class, SkipListener.class, Object.class, Throwable.class); - + private final String methodName; private final String propertyName; private final Class annotation; private final Class listenerInterface; private final Class[] paramTypes; private static final Map propertyMap; - + StepListenerMetaData(String methodName, String propertyName, Class annotation, Class listenerInterface, Class... paramTypes) { this.methodName = methodName; this.propertyName = propertyName; @@ -86,7 +86,7 @@ public enum StepListenerMetaData implements ListenerMetaData { this.listenerInterface = listenerInterface; this.paramTypes = paramTypes; } - + static{ propertyMap = new HashMap(); for(StepListenerMetaData metaData : values()){ @@ -94,41 +94,41 @@ public enum StepListenerMetaData implements ListenerMetaData { } } - @Override + @Override public String getMethodName() { return methodName; } - @Override + @Override public Class getAnnotation() { return annotation; } - @Override + @Override public Class getListenerInterface() { return listenerInterface; } - @Override + @Override public Class[] getParamTypes() { return paramTypes; } - - @Override + + @Override public String getPropertyName() { return propertyName; } - + /** * Return the relevant meta data for the provided property name. - * + * * @param propertyName * @return meta data with supplied property name, null if none exists. */ public static StepListenerMetaData fromPropertyName(String propertyName){ return propertyMap.get(propertyName); } - + public static ListenerMetaData[] itemListenerMetaData() { return new ListenerMetaData[] {BEFORE_WRITE, AFTER_WRITE, ON_WRITE_ERROR, BEFORE_PROCESS, AFTER_PROCESS, ON_PROCESS_ERROR, BEFORE_READ, AFTER_READ, ON_READ_ERROR, ON_SKIP_IN_WRITE, ON_SKIP_IN_PROCESS, ON_SKIP_IN_READ}; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerSupport.java index c415cca34..70d9d4028 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -29,17 +29,17 @@ import org.springframework.batch.core.StepListener; /** * Basic no-op implementations of all {@link StepListener} interfaces. - * + * * @author Lucas Ward * @author Robert Kasanicky */ public class StepListenerSupport implements StepExecutionListener, ChunkListener, - ItemReadListener, ItemProcessListener, ItemWriteListener, SkipListener { +ItemReadListener, ItemProcessListener, ItemWriteListener, SkipListener { /* (non-Javadoc) * @see org.springframework.batch.core.StepExecutionListener#afterStep(org.springframework.batch.core.StepExecution) */ - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; } @@ -47,105 +47,105 @@ public class StepListenerSupport implements StepExecutionListener, ChunkLis /* (non-Javadoc) * @see org.springframework.batch.core.StepExecutionListener#beforeStep(org.springframework.batch.core.StepExecution) */ - @Override + @Override public void beforeStep(StepExecution stepExecution) { } /* (non-Javadoc) * @see org.springframework.batch.core.domain.ChunkListener#afterChunk() */ - @Override + @Override public void afterChunk() { } /* (non-Javadoc) * @see org.springframework.batch.core.domain.ChunkListener#beforeChunk() */ - @Override + @Override public void beforeChunk() { } /* (non-Javadoc) * @see org.springframework.batch.core.domain.ItemReadListener#afterRead(java.lang.Object) */ - @Override + @Override public void afterRead(T item) { } /* (non-Javadoc) * @see org.springframework.batch.core.domain.ItemReadListener#beforeRead() */ - @Override + @Override public void beforeRead() { } /* (non-Javadoc) * @see org.springframework.batch.core.domain.ItemReadListener#onReadError(java.lang.Exception) */ - @Override + @Override public void onReadError(Exception ex) { } /* (non-Javadoc) * @see org.springframework.batch.core.ItemWriteListener#afterWrite(java.util.List) */ - @Override + @Override public void afterWrite(List items) { } /* (non-Javadoc) * @see org.springframework.batch.core.ItemWriteListener#beforeWrite(java.util.List) */ - @Override + @Override public void beforeWrite(List items) { } /* (non-Javadoc) * @see org.springframework.batch.core.ItemWriteListener#onWriteError(java.lang.Exception, java.util.List) */ - @Override + @Override public void onWriteError(Exception exception, List items) { } /* (non-Javadoc) * @see org.springframework.batch.core.ItemProcessListener#afterProcess(java.lang.Object, java.lang.Object) */ - @Override + @Override public void afterProcess(T item, S result) { } /* (non-Javadoc) * @see org.springframework.batch.core.ItemProcessListener#beforeProcess(java.lang.Object) */ - @Override + @Override public void beforeProcess(T item) { } /* (non-Javadoc) * @see org.springframework.batch.core.ItemProcessListener#onProcessError(java.lang.Object, java.lang.Exception) */ - @Override + @Override public void onProcessError(T item, Exception e) { } /* (non-Javadoc) * @see org.springframework.batch.core.SkipListener#onSkipInProcess(java.lang.Object, java.lang.Throwable) */ - @Override + @Override public void onSkipInProcess(T item, Throwable t) { } /* (non-Javadoc) * @see org.springframework.batch.core.SkipListener#onSkipInRead(java.lang.Throwable) */ - @Override + @Override public void onSkipInRead(Throwable t) { } /* (non-Javadoc) * @see org.springframework.batch.core.SkipListener#onSkipInWrite(java.lang.Object, java.lang.Throwable) */ - @Override + @Override public void onSkipInWrite(S item, Throwable t) { } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/AbstractPartitionHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/AbstractPartitionHandler.java index 27cd42668..e75585efa 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/AbstractPartitionHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/AbstractPartitionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2013 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. @@ -34,43 +34,43 @@ import org.springframework.batch.core.partition.StepExecutionSplitter; */ public abstract class AbstractPartitionHandler implements PartitionHandler { - private int gridSize = 1; + private int gridSize = 1; - /** - * Executes the specified {@link StepExecution} instances and returns an updated - * view of them. Throws an {@link Exception} if anything goes wrong. - * - * @param masterStepExecution the whole partition execution - * @param partitionStepExecutions the {@link StepExecution} instances to execute - * @return an updated view of these completed {@link StepExecution} instances - * @throws Exception if anything goes wrong. This allows implementations to - * be liberal and rely on the caller to translate an exception into a step - * failure as necessary. - */ - protected abstract Set doHandle(StepExecution masterStepExecution, - Set partitionStepExecutions) throws Exception; + /** + * Executes the specified {@link StepExecution} instances and returns an updated + * view of them. Throws an {@link Exception} if anything goes wrong. + * + * @param masterStepExecution the whole partition execution + * @param partitionStepExecutions the {@link StepExecution} instances to execute + * @return an updated view of these completed {@link StepExecution} instances + * @throws Exception if anything goes wrong. This allows implementations to + * be liberal and rely on the caller to translate an exception into a step + * failure as necessary. + */ + protected abstract Set doHandle(StepExecution masterStepExecution, + Set partitionStepExecutions) throws Exception; /** * @see PartitionHandler#handle(StepExecutionSplitter, StepExecution) */ - @Override - public Collection handle(final StepExecutionSplitter stepSplitter, - final StepExecution masterStepExecution) throws Exception { - final Set stepExecutions = stepSplitter.split(masterStepExecution, gridSize); + @Override + public Collection handle(final StepExecutionSplitter stepSplitter, + final StepExecution masterStepExecution) throws Exception { + final Set stepExecutions = stepSplitter.split(masterStepExecution, gridSize); - return doHandle(masterStepExecution, stepExecutions); - } + return doHandle(masterStepExecution, stepExecutions); + } - /** - * Returns the number of step executions. - * - * @return the number of step executions - */ - public int getGridSize() { - return gridSize; - } + /** + * Returns the number of step executions. + * + * @return the number of step executions + */ + public int getGridSize() { + return gridSize; + } - /** + /** * Passed to the {@link StepExecutionSplitter} in the * {@link #handle(StepExecutionSplitter, StepExecution)} method, instructing * it how many {@link StepExecution} instances are required, ideally. The @@ -79,9 +79,9 @@ public abstract class AbstractPartitionHandler implements PartitionHandler { * * @param gridSize the number of step executions that will be created */ - public void setGridSize(int gridSize) { - this.gridSize = gridSize; - } + public void setGridSize(int gridSize) { + this.gridSize = gridSize; + } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/DefaultStepExecutionAggregator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/DefaultStepExecutionAggregator.java index 467545d9b..a293d4673 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/DefaultStepExecutionAggregator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/DefaultStepExecutionAggregator.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -26,7 +26,7 @@ import org.springframework.util.Assert; /** * Convenience class for aggregating a set of {@link StepExecution} instances * into a single result. - * + * * @author Dave Syer * @since 2.1 */ @@ -43,7 +43,7 @@ public class DefaultStepExecutionAggregator implements StepExecutionAggregator { * * @see StepExecutionAggregator #aggregate(StepExecution, Collection) */ - @Override + @Override public void aggregate(StepExecution result, Collection executions) { Assert.notNull(result, "To aggregate into a result it must be non-null."); if (executions == null) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/MultiResourcePartitioner.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/MultiResourcePartitioner.java index 91ee19a23..03f3eef09 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/MultiResourcePartitioner.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/MultiResourcePartitioner.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -30,7 +30,7 @@ import org.springframework.util.Assert; * {@link ExecutionContext} per resource, and labels them as * {partition0, partition1, ..., partitionN}. The grid size is * ignored. - * + * * @author Dave Syer * @since 2.0 */ @@ -65,10 +65,10 @@ public class MultiResourcePartitioner implements Partitioner { /** * Assign the filename of each of the injected resources to an * {@link ExecutionContext}. - * + * * @see Partitioner#partition(int) */ - @Override + @Override public Map partition(int gridSize) { Map map = new HashMap(gridSize); int i = 0; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/PartitionStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/PartitionStep.java index 04ddf492f..6eed9e759 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/PartitionStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/PartitionStep.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -31,7 +31,7 @@ import org.springframework.util.Assert; /** * Implementation of {@link Step} which partitions the execution and spreads the * load using a {@link PartitionHandler}. - * + * * @author Dave Syer * @since 2.0 */ @@ -46,7 +46,7 @@ public class PartitionStep extends AbstractStep { /** * A {@link PartitionHandler} which can send out step executions for remote * processing and bring back the results. - * + * * @param partitionHandler the {@link PartitionHandler} to set */ public void setPartitionHandler(PartitionHandler partitionHandler) { @@ -57,7 +57,7 @@ public class PartitionStep extends AbstractStep { * A {@link StepExecutionAggregator} that can aggregate step executions when * they come back from the handler. Defaults to a * {@link DefaultStepExecutionAggregator}. - * + * * @param stepExecutionAggregator the {@link StepExecutionAggregator} to set */ public void setStepExecutionAggregator(StepExecutionAggregator stepExecutionAggregator) { @@ -75,10 +75,10 @@ public class PartitionStep extends AbstractStep { /** * Assert that mandatory properties are set (stepExecutionSplitter, * partitionHandler) and delegate top superclass. - * + * * @see AbstractStep#afterPropertiesSet() */ - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(stepExecutionSplitter, "StepExecutionSplitter must be provided"); Assert.notNull(partitionHandler, "PartitionHandler must be provided"); @@ -93,9 +93,9 @@ public class PartitionStep extends AbstractStep { * individual step executions and their input parameters (through * {@link ExecutionContext}) for the partition elements are provided by the * {@link StepExecutionSplitter}. - * + * * @param stepExecution the master step execution for the partition - * + * * @see Step#execute(StepExecution) */ @Override diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java index cff7d490d..f49ddf4f5 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -28,7 +28,7 @@ import org.springframework.util.Assert; * Convenience class for aggregating a set of {@link StepExecution} instances * when the input comes from remote steps, so the data need to be refreshed from * the repository. - * + * * @author Dave Syer * @since 2.1 */ @@ -47,7 +47,7 @@ public class RemoteStepExecutionAggregator implements StepExecutionAggregator, I /** * Create a new instance with a job explorer that can be used to refresh the * data when aggregating. - * + * * @param jobExplorer the {@link JobExplorer} to use */ public RemoteStepExecutionAggregator(JobExplorer jobExplorer) { @@ -72,7 +72,7 @@ public class RemoteStepExecutionAggregator implements StepExecutionAggregator, I /** * @throws Exception if the job explorer is not provided */ - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.state(jobExplorer != null, "A JobExplorer must be provided"); } @@ -81,10 +81,10 @@ public class RemoteStepExecutionAggregator implements StepExecutionAggregator, I * Aggregates the input executions into the result {@link StepExecution} * delegating to the delegate aggregator once the input has been refreshed * from the {@link JobExplorer}. - * + * * @see StepExecutionAggregator #aggregate(StepExecution, Collection) */ - @Override + @Override public void aggregate(StepExecution result, Collection executions) { Assert.notNull(result, "To aggregate into a result it must be non-null."); if (executions == null) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimplePartitioner.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimplePartitioner.java index dbcd46359..7b9c3848e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimplePartitioner.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimplePartitioner.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -26,7 +26,7 @@ import org.springframework.batch.item.ExecutionContext; * of empty {@link ExecutionContext} instances, and labels them as * {partition0, partition1, ..., partitionN}, where N is the grid * size. - * + * * @author Dave Syer * @since 2.0 */ @@ -34,7 +34,7 @@ public class SimplePartitioner implements Partitioner { private static final String PARTITION_KEY = "partition"; - @Override + @Override public Map partition(int gridSize) { Map map = new HashMap(gridSize); for (int i = 0; i < gridSize; i++) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitter.java index 4967a2445..a6db0a6b8 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -20,8 +20,8 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.Map.Entry; +import java.util.Set; import org.springframework.batch.core.BatchStatus; import org.springframework.batch.core.JobExecution; @@ -44,7 +44,7 @@ import org.springframework.util.Assert; * base (name of the target step) plus a suffix taken from the * {@link Partitioner} identifiers, separated by a colon, e.g. * {step1:partition0, step1:partition1, ...}. - * + * * @author Dave Syer * @since 2.0 */ @@ -69,7 +69,7 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi /** * Construct a {@link SimpleStepExecutionSplitter} from its mandatory * properties. - * + * * @param jobRepository the {@link JobRepository} * @param allowStartIfComplete flag specifying preferences on restart * @param stepName the target step name @@ -86,13 +86,13 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi /** * Construct a {@link SimpleStepExecutionSplitter} from its mandatory * properties. - * + * * @param jobRepository the {@link JobRepository} * @param step the target step (a local version of it), used to extract the * name and allowStartIfComplete flags * @param partitioner a {@link Partitioner} to use for generating input * parameters - * + * * @deprecated use {@link #SimpleStepExecutionSplitter(JobRepository, boolean, String, Partitioner)} instead */ @Deprecated @@ -105,10 +105,10 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi /** * Check mandatory properties (step name, job repository and partitioner). - * + * * @see InitializingBean#afterPropertiesSet() */ - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.state(jobRepository != null, "A JobRepository is required"); Assert.state(stepName != null, "A step name is required"); @@ -119,9 +119,9 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi * Flag to indicate that the partition target step is allowed to start if an * execution is complete. Defaults to the same value as the underlying step. * Set this manually to override the underlying step properties. - * + * * @see Step#isAllowStartIfComplete() - * + * * @param allowStartIfComplete the value to set */ public void setAllowStartIfComplete(boolean allowStartIfComplete) { @@ -131,7 +131,7 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi /** * The job repository that will be used to manage the persistence of the * delegate step executions. - * + * * @param jobRepository the JobRepository to set */ public void setJobRepository(JobRepository jobRepository) { @@ -141,7 +141,7 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi /** * The {@link Partitioner} that will be used to generate step execution meta * data for the target step. - * + * * @param partitioner the partitioner to set */ public void setPartitioner(Partitioner partitioner) { @@ -151,7 +151,7 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi /** * The name of the target step that will be executed across the partitions. * Mandatory with no default. - * + * * @param stepName the step name to set */ public void setStepName(String stepName) { @@ -161,7 +161,7 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi /** * @see StepExecutionSplitter#getStepName() */ - @Override + @Override public String getStepName() { return this.stepName; } @@ -169,7 +169,7 @@ public class SimpleStepExecutionSplitter implements StepExecutionSplitter, Initi /** * @see StepExecutionSplitter#split(StepExecution, int) */ - @Override + @Override public Set split(StepExecution stepExecution, int gridSize) throws JobExecutionException { JobExecution jobExecution = stepExecution.getJobExecution(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandler.java index f382c3864..083274862 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2013 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. @@ -71,17 +71,17 @@ public class TaskExecutorPartitionHandler extends AbstractPartitionHandler imple * {@link StepExecution}. This is a regular Spring Batch step, with all the * business logic required to complete an execution based on the input * parameters in its {@link StepExecution} context. - * + * * @param step the {@link Step} instance to use to execute business logic */ @Required public void setStep(Step step) { this.step = step; } - + /** * The step instance that will be executed in parallel by this handler. - * + * * @return the step instance that will be used * @see StepHolder#getStep() */ diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/AbstractJdbcBatchMetadataDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/AbstractJdbcBatchMetadataDao.java index 1c648ba06..a6e393686 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/AbstractJdbcBatchMetadataDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/AbstractJdbcBatchMetadataDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -26,7 +26,7 @@ import org.springframework.util.StringUtils; /** * Encapsulates common functionality needed by JDBC batch metadata DAOs - * provides jdbcTemplate for subclasses and handles table prefixes. - * + * * @author Robert Kasanicky */ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean { @@ -35,11 +35,11 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean { * Default value for the table prefix property. */ public static final String DEFAULT_TABLE_PREFIX = "BATCH_"; - + public static final int DEFAULT_EXIT_MESSAGE_LENGTH = 2500; private String tablePrefix = DEFAULT_TABLE_PREFIX; - + private int clobTypeToUse = Types.CLOB; private JdbcOperations jdbcTemplate; @@ -47,7 +47,7 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean { protected String getQuery(String base) { return StringUtils.replace(base, "%PREFIX%", tablePrefix); } - + protected String getTablePrefix() { return tablePrefix; } @@ -56,7 +56,7 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean { * Public setter for the table prefix property. This will be prefixed to all * the table names before queries are executed. Defaults to * {@link #DEFAULT_TABLE_PREFIX}. - * + * * @param tablePrefix the tablePrefix to set */ public void setTablePrefix(String tablePrefix) { @@ -70,7 +70,7 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean { protected JdbcOperations getJdbcTemplate() { return jdbcTemplate; } - + public int getClobTypeToUse() { return clobTypeToUse; } @@ -79,7 +79,7 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean { this.clobTypeToUse = clobTypeToUse; } - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(jdbcTemplate); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/DefaultExecutionContextSerializer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/DefaultExecutionContextSerializer.java index 3533613e6..93323eb8a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/DefaultExecutionContextSerializer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/DefaultExecutionContextSerializer.java @@ -1,5 +1,17 @@ -/** +/* + * Copyright 2012-2013 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.core.repository.dao; @@ -22,6 +34,7 @@ import org.springframework.util.Assert; * @author Michael Minella * @since 2.2 */ +@SuppressWarnings("rawtypes") public class DefaultExecutionContextSerializer implements ExecutionContextSerializer { private Serializer serializer = new DefaultSerializer(); @@ -34,7 +47,7 @@ public class DefaultExecutionContextSerializer implements ExecutionContextSerial * @param context * @param out */ - @Override + @Override @SuppressWarnings("unchecked") public void serialize(Object context, OutputStream out) throws IOException { Assert.notNull(context); @@ -49,7 +62,7 @@ public class DefaultExecutionContextSerializer implements ExecutionContextSerial * @param inputStream * @return the object serialized in the provided {@link InputStream} */ - @Override + @Override public Object deserialize(InputStream inputStream) throws IOException { return deserializer.deserialize(inputStream); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java index 0b09db54f..e6222595b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -100,7 +100,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem this.shortContextLength = shortContextLength; } - @Override + @Override public ExecutionContext getExecutionContext(JobExecution jobExecution) { Long executionId = jobExecution.getId(); Assert.notNull(executionId, "ExecutionId must not be null."); @@ -115,7 +115,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem } } - @Override + @Override public ExecutionContext getExecutionContext(StepExecution stepExecution) { Long executionId = stepExecution.getId(); Assert.notNull(executionId, "ExecutionId must not be null."); @@ -130,7 +130,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem } } - @Override + @Override public void updateExecutionContext(final JobExecution jobExecution) { Long executionId = jobExecution.getId(); ExecutionContext executionContext = jobExecution.getExecutionContext(); @@ -142,7 +142,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem persistSerializedContext(executionId, serializedContext, UPDATE_JOB_EXECUTION_CONTEXT); } - @Override + @Override public void updateExecutionContext(final StepExecution stepExecution) { Long executionId = stepExecution.getId(); @@ -155,7 +155,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem persistSerializedContext(executionId, serializedContext, UPDATE_STEP_EXECUTION_CONTEXT); } - @Override + @Override public void saveExecutionContext(JobExecution jobExecution) { Long executionId = jobExecution.getId(); @@ -168,7 +168,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem persistSerializedContext(executionId, serializedContext, INSERT_JOB_EXECUTION_CONTEXT); } - @Override + @Override public void saveExecutionContext(StepExecution stepExecution) { Long executionId = stepExecution.getId(); ExecutionContext executionContext = stepExecution.getExecutionContext(); @@ -210,7 +210,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem } getJdbcTemplate().update(getQuery(sql), new PreparedStatementSetter() { - @Override + @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, shortContext); if (longContext != null) { @@ -224,6 +224,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem }); } + @SuppressWarnings("unchecked") private String serializeContext(ExecutionContext ctx) { Map m = new HashMap(); for (Entry me : ctx.entrySet()) { @@ -247,7 +248,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem @SuppressWarnings("unchecked") private class ExecutionContextRowMapper implements ParameterizedRowMapper { - @Override + @Override public ExecutionContext mapRow(ResultSet rs, int i) throws SQLException { ExecutionContext executionContext = new ExecutionContext(); String serializedContext = rs.getString("SERIALIZED_CONTEXT"); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java index cf9c7b21c..83bf252c7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2013 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. @@ -38,14 +38,14 @@ import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer import org.springframework.util.Assert; /** - * Jdbc implementation of {@link JobExecutionDao}. Uses sequences (via Spring's + * JDBC implementation of {@link JobExecutionDao}. Uses sequences (via Spring's * {@link DataFieldMaxValueIncrementer} abstraction) to create all primary keys * before inserting a new row. Objects are checked to ensure all mandatory * fields to be stored are not null. If any are found to be null, an * IllegalArgumentException will be thrown. This could be left to JdbcTemplate, * however, the exception will be fairly vague, and fails to highlight which * field caused the exception. - * + * * @author Lucas Ward * @author Dave Syer * @author Robert Kasanicky @@ -95,20 +95,20 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements /** * Setter for {@link DataFieldMaxValueIncrementer} to be used when * generating primary keys for {@link JobExecution} instances. - * + * * @param jobExecutionIncrementer the {@link DataFieldMaxValueIncrementer} */ public void setJobExecutionIncrementer(DataFieldMaxValueIncrementer jobExecutionIncrementer) { this.jobExecutionIncrementer = jobExecutionIncrementer; } - @Override + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(jobExecutionIncrementer, "The jobExecutionIncrementer must not be null."); } - @Override + @Override public List findJobExecutions(final JobInstance job) { Assert.notNull(job, "Job cannot be null."); @@ -118,16 +118,16 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements } /** - * + * * SQL implementation using Sequences via the Spring incrementer * abstraction. Once a new id has been obtained, the JobExecution is saved * via a SQL INSERT statement. - * + * * @see JobExecutionDao#saveJobExecution(JobExecution) * @throws IllegalArgumentException if jobExecution is null, as well as any * of it's fields to be persisted. */ - @Override + @Override public void saveJobExecution(JobExecution jobExecution) { validateJobExecution(jobExecution); @@ -143,13 +143,13 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements getQuery(SAVE_JOB_EXECUTION), parameters, new int[] { Types.BIGINT, Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, - Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.TIMESTAMP, Types.TIMESTAMP }); + Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.TIMESTAMP, Types.TIMESTAMP }); } /** * Validate JobExecution. At a minimum, JobId, StartTime, EndTime, and * Status cannot be null. - * + * * @param jobExecution * @throws IllegalArgumentException */ @@ -166,10 +166,10 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements * is first checked to ensure all fields are not null, and that it has an * ID. The database is then queried to ensure that the ID exists, which * ensures that it is valid. - * + * * @see JobExecutionDao#updateJobExecution(JobExecution) */ - @Override + @Override public void updateJobExecution(JobExecution jobExecution) { validateJobExecution(jobExecution); @@ -206,7 +206,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements getQuery(UPDATE_JOB_EXECUTION), parameters, new int[] { Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, - Types.INTEGER, Types.TIMESTAMP, Types.TIMESTAMP, Types.BIGINT, Types.INTEGER }); + Types.INTEGER, Types.TIMESTAMP, Types.TIMESTAMP, Types.BIGINT, Types.INTEGER }); // Avoid concurrent modifications... if (count == 0) { @@ -221,7 +221,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements } } - @Override + @Override public JobExecution getLastJobExecution(JobInstance jobInstance) { Long id = jobInstance.getId(); @@ -241,11 +241,11 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements /* * (non-Javadoc) - * + * * @seeorg.springframework.batch.core.repository.dao.JobExecutionDao# * getLastJobExecution(java.lang.String) */ - @Override + @Override public JobExecution getJobExecution(Long executionId) { try { JobExecution jobExecution = getJdbcTemplate().queryForObject(getQuery(GET_EXECUTION_BY_ID), @@ -259,16 +259,16 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements /* * (non-Javadoc) - * + * * @seeorg.springframework.batch.core.repository.dao.JobExecutionDao# * findRunningJobExecutions(java.lang.String) */ - @Override + @Override public Set findRunningJobExecutions(String jobName) { final Set result = new HashSet(); RowCallbackHandler handler = new RowCallbackHandler() { - @Override + @Override public void processRow(ResultSet rs) throws SQLException { JobExecutionRowMapper mapper = new JobExecutionRowMapper(); result.add(mapper.mapRow(rs, 0)); @@ -279,7 +279,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements return result; } - @Override + @Override public void synchronizeStatus(JobExecution jobExecution) { int currentVersion = getJdbcTemplate().queryForInt(getQuery(CURRENT_VERSION_JOB_EXECUTION), jobExecution.getId()); @@ -293,9 +293,9 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements /** * Re-usable mapper for {@link JobExecution} instances. - * + * * @author Dave Syer - * + * */ private static class JobExecutionRowMapper implements ParameterizedRowMapper { @@ -308,7 +308,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements this.jobInstance = jobInstance; } - @Override + @Override public JobExecution mapRow(ResultSet rs, int rowNum) throws SQLException { Long id = rs.getLong(1); JobExecution jobExecution; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDao.java index f5c11f01c..6bd2f6f9f 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -34,8 +34,8 @@ import java.util.Map.Entry; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobInstance; import org.springframework.batch.core.JobParameter; -import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.JobParameter.ParameterType; +import org.springframework.batch.core.JobParameters; import org.springframework.beans.factory.InitializingBean; import org.springframework.dao.DataAccessException; import org.springframework.dao.EmptyResultDataAccessException; @@ -47,20 +47,20 @@ import org.springframework.util.Assert; import org.springframework.util.StringUtils; /** - * Jdbc implementation of {@link JobInstanceDao}. Uses sequences (via Spring's + * JDBC implementation of {@link JobInstanceDao}. Uses sequences (via Spring's * {@link DataFieldMaxValueIncrementer} abstraction) to create all primary keys * before inserting a new row. Objects are checked to ensure all mandatory * fields to be stored are not null. If any are found to be null, an * IllegalArgumentException will be thrown. This could be left to JdbcTemplate, * however, the exception will be fairly vague, and fails to highlight which * field caused the exception. - * + * * @author Lucas Ward * @author Dave Syer * @author Robert Kasanicky */ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements - JobInstanceDao, InitializingBean { +JobInstanceDao, InitializingBean { private static final String CREATE_JOB_INSTANCE = "INSERT into %PREFIX%JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION)" + " values (?, ?, ?, ?)"; @@ -93,12 +93,12 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements * In this jdbc implementation a job id is obtained by asking the * jobIncrementer (which is likely a sequence) for the next long value, and * then passing the Id and parameter values into an INSERT statement. - * + * * @see JobInstanceDao#createJobInstance(String, JobParameters) * @throws IllegalArgumentException * if any {@link JobParameters} fields are null. */ - @Override + @Override public JobInstance createJobInstance(String jobName, JobParameters jobParameters) { @@ -119,7 +119,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements getQuery(CREATE_JOB_INSTANCE), parameters, new int[] { Types.BIGINT, Types.VARCHAR, Types.VARCHAR, - Types.INTEGER }); + Types.INTEGER }); insertJobParameters(jobId, jobParameters); @@ -159,7 +159,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements /** * Convenience method that inserts all parameters from the provided * JobParameters. - * + * */ private void insertJobParameters(Long jobId, JobParameters jobParameters) { @@ -202,12 +202,12 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements /** * The job table is queried for any jobs that match the * given identifier, adding them to a list via the RowMapper callback. - * + * * @see JobInstanceDao#getJobInstance(String, JobParameters) * @throws IllegalArgumentException * if any {@link JobParameters} fields are null. */ - @Override + @Override public JobInstance getJobInstance(final String jobName, final JobParameters jobParameters) { @@ -239,12 +239,12 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.repository.dao.JobInstanceDao#getJobInstance * (java.lang.Long) */ - @Override + @Override public JobInstance getJobInstance(Long instanceId) { try { @@ -263,7 +263,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements private JobParameters getJobParameters(Long instanceId) { final Map map = new HashMap(); RowCallbackHandler handler = new RowCallbackHandler() { - @Override + @Override public void processRow(ResultSet rs) throws SQLException { ParameterType type = ParameterType.valueOf(rs.getString(3)); JobParameter value = null; @@ -286,30 +286,31 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.repository.dao.JobInstanceDao#getJobNames * () */ - @Override + @Override public List getJobNames() { return getJdbcTemplate().query(getQuery(FIND_JOB_NAMES), new ParameterizedRowMapper() { - @Override - public String mapRow(ResultSet rs, int rowNum) - throws SQLException { - return rs.getString(1); - } - }); + @Override + public String mapRow(ResultSet rs, int rowNum) + throws SQLException { + return rs.getString(1); + } + }); } /* * (non-Javadoc) - * + * * @seeorg.springframework.batch.core.repository.dao.JobInstanceDao# * getLastJobInstances(java.lang.String, int) */ - @Override + @Override + @SuppressWarnings("rawtypes") public List getJobInstances(String jobName, final int start, final int count) { @@ -317,9 +318,9 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements private List list = new ArrayList(); - @Override + @Override public Object extractData(ResultSet rs) throws SQLException, - DataAccessException { + DataAccessException { int rowNum = 0; while (rowNum < start && rs.next()) { rowNum++; @@ -336,19 +337,19 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements @SuppressWarnings("unchecked") List result = (List) getJdbcTemplate().query(getQuery(FIND_LAST_JOBS_BY_NAME), - new Object[] { jobName }, extractor); + new Object[] { jobName }, extractor); return result; } /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.repository.dao.JobInstanceDao#getJobInstance * (org.springframework.batch.core.JobExecution) */ - @Override + @Override public JobInstance getJobInstance(JobExecution jobExecution) { try { @@ -363,7 +364,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements /** * Setter for {@link DataFieldMaxValueIncrementer} to be used when * generating primary keys for {@link JobInstance} instances. - * + * * @param jobIncrementer * the {@link DataFieldMaxValueIncrementer} */ @@ -371,7 +372,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements this.jobIncrementer = jobIncrementer; } - @Override + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(jobIncrementer); @@ -379,10 +380,10 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements /** * @author Dave Syer - * + * */ private final class JobInstanceRowMapper implements - ParameterizedRowMapper { + ParameterizedRowMapper { private JobParameters jobParameters; @@ -393,7 +394,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements this.jobParameters = jobParameters; } - @Override + @Override public JobInstance mapRow(ResultSet rs, int rowNum) throws SQLException { Long id = rs.getLong(1); if (jobParameters == null) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java index dc014a923..6a570c566 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -34,22 +34,22 @@ import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer import org.springframework.util.Assert; /** - * Jdbc implementation of {@link StepExecutionDao}.
    - * + * JDBC implementation of {@link StepExecutionDao}.
    + * * Allows customization of the tables names used by Spring Batch for step meta * data via a prefix property.
    - * + * * Uses sequences or tables (via Spring's {@link DataFieldMaxValueIncrementer} * abstraction) to create all primary keys before inserting a new row. All * objects are checked to ensure all fields to be stored are not null. If any * are found to be null, an IllegalArgumentException will be thrown. This could * be left to JdbcTemplate, however, the exception will be fairly vague, and * fails to highlight which field caused the exception.
    - * + * * @author Lucas Ward * @author Dave Syer * @author Robert Kasanicky - * + * * @see StepExecutionDao */ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implements StepExecutionDao, InitializingBean { @@ -91,7 +91,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement this.stepExecutionIncrementer = stepExecutionIncrementer; } - @Override + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(stepExecutionIncrementer, "StepExecutionIncrementer cannot be null."); @@ -101,10 +101,10 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement * Save a StepExecution. A unique id will be generated by the * stepExecutionIncrementor, and then set in the StepExecution. All values * will then be stored via an INSERT statement. - * + * * @see StepExecutionDao#saveStepExecution(StepExecution) */ - @Override + @Override public void saveStepExecution(StepExecution stepExecution) { Assert.isNull(stepExecution.getId(), @@ -129,15 +129,15 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement getQuery(SAVE_STEP_EXECUTION), parameters, new int[] { Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.BIGINT, Types.TIMESTAMP, - Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, - Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, - Types.TIMESTAMP }); + Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, + Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, + Types.TIMESTAMP }); } /** * Validate StepExecution. At a minimum, JobId, StartTime, and Status cannot * be null. EndTime can be null for an unfinished job. - * + * * @throws IllegalArgumentException */ private void validateStepExecution(StepExecution stepExecution) { @@ -147,7 +147,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement Assert.notNull(stepExecution.getStatus(), "StepExecution status cannot be null."); } - @Override + @Override public void updateStepExecution(StepExecution stepExecution) { validateStepExecution(stepExecution); @@ -172,12 +172,12 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement stepExecution.getWriteSkipCount(), stepExecution.getRollbackCount(), stepExecution.getLastUpdated(), stepExecution.getId(), stepExecution.getVersion() }; int count = getJdbcTemplate().update( - getQuery(UPDATE_STEP_EXECUTION), - parameters, - new int[] { Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, - Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, - Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP, - Types.BIGINT, Types.INTEGER }); + getQuery(UPDATE_STEP_EXECUTION), + parameters, + new int[] { Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, + Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, + Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP, + Types.BIGINT, Types.INTEGER }); // Avoid concurrent modifications... if (count == 0) { @@ -209,7 +209,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement } } - @Override + @Override public StepExecution getStepExecution(JobExecution jobExecution, Long stepExecutionId) { List executions = getJdbcTemplate().query(getQuery(GET_STEP_EXECUTION), new StepExecutionRowMapper(jobExecution), jobExecution.getId(), stepExecutionId); @@ -224,7 +224,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement } } - @Override + @Override public void addStepExecutions(JobExecution jobExecution) { getJdbcTemplate().query(getQuery(GET_STEP_EXECUTIONS), new StepExecutionRowMapper(jobExecution), jobExecution.getId()); @@ -238,7 +238,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement this.jobExecution = jobExecution; } - @Override + @Override public StepExecution mapRow(ResultSet rs, int rowNum) throws SQLException { StepExecution stepExecution = new StepExecution(rs.getString(2), jobExecution, rs.getLong(1)); stepExecution.setStartTime(rs.getTimestamp(3)); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java index 8585cce2d..d70dd28aa 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapExecutionContextDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -27,10 +27,11 @@ import org.springframework.batch.support.transaction.TransactionAwareProxyFactor /** * In-memory implementation of {@link ExecutionContextDao} backed by maps. - * + * * @author Robert Kasanicky * @author Dave Syer */ +@SuppressWarnings("serial") public class MapExecutionContextDao implements ExecutionContextDao { private final ConcurrentMap contexts = TransactionAwareProxyFactory @@ -44,30 +45,44 @@ public class MapExecutionContextDao implements ExecutionContextDao { private final long id; private ContextKey(Type type, long id) { - if(type == null) throw new IllegalStateException("Need a non-null type for a context"); + if(type == null) { + throw new IllegalStateException("Need a non-null type for a context"); + } this.type = type; this.id = id; } - @Override + @Override public int compareTo(ContextKey them) { - if(them == null) return 1; + if(them == null) { + return 1; + } final int idCompare = new Long(this.id).compareTo(new Long(them.id)); // JDK6 Make this Long.compare(x,y) - if(idCompare != 0) return idCompare; + if(idCompare != 0) { + return idCompare; + } final int typeCompare = this.type.compareTo(them.type); - if(typeCompare != 0) return typeCompare; + if(typeCompare != 0) { + return typeCompare; + } return 0; } @Override public boolean equals(Object them) { - if(them == null) return false; - if(them instanceof ContextKey) return this.equals((ContextKey)them); + if(them == null) { + return false; + } + if(them instanceof ContextKey) { + return this.equals((ContextKey)them); + } return false; } public boolean equals(ContextKey them) { - if(them == null) return false; + if(them == null) { + return false; + } return this.id == them.id && this.type.equals(them.type); } @@ -75,9 +90,9 @@ public class MapExecutionContextDao implements ExecutionContextDao { public int hashCode() { int value = (int)(id^(id>>>32)); switch(type) { - case STEP: return value; - case JOB: return ~value; - default: throw new IllegalStateException("Unknown type encountered in switch: " + type); + case STEP: return value; + case JOB: return ~value; + default: throw new IllegalStateException("Unknown type encountered in switch: " + type); } } @@ -86,7 +101,7 @@ public class MapExecutionContextDao implements ExecutionContextDao { public static ContextKey job(long id) { return new ContextKey(Type.JOB, id); } } - public void clear() { + public void clear() { contexts.clear(); } @@ -94,12 +109,12 @@ public class MapExecutionContextDao implements ExecutionContextDao { return (ExecutionContext) SerializationUtils.deserialize(SerializationUtils.serialize(original)); } - @Override + @Override public ExecutionContext getExecutionContext(StepExecution stepExecution) { return copy(contexts.get(ContextKey.step(stepExecution.getId()))); } - @Override + @Override public void updateExecutionContext(StepExecution stepExecution) { ExecutionContext executionContext = stepExecution.getExecutionContext(); if (executionContext != null) { @@ -107,12 +122,12 @@ public class MapExecutionContextDao implements ExecutionContextDao { } } - @Override + @Override public ExecutionContext getExecutionContext(JobExecution jobExecution) { return copy(contexts.get(ContextKey.job(jobExecution.getId()))); } - @Override + @Override public void updateExecutionContext(JobExecution jobExecution) { ExecutionContext executionContext = jobExecution.getExecutionContext(); if (executionContext != null) { @@ -120,12 +135,12 @@ public class MapExecutionContextDao implements ExecutionContextDao { } } - @Override + @Override public void saveExecutionContext(JobExecution jobExecution) { updateExecutionContext(jobExecution); } - @Override + @Override public void saveExecutionContext(StepExecution stepExecution) { updateExecutionContext(stepExecution); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java index d50302061..7c30b8ac2 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -22,10 +22,8 @@ import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Set; - import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; - import java.util.concurrent.atomic.AtomicLong; import org.springframework.batch.core.JobExecution; @@ -53,7 +51,7 @@ public class MapJobExecutionDao implements JobExecutionDao { return copy; } - @Override + @Override public void saveJobExecution(JobExecution jobExecution) { Assert.isTrue(jobExecution.getId() == null); Long newId = currentId.getAndIncrement(); @@ -62,7 +60,7 @@ public class MapJobExecutionDao implements JobExecutionDao { executionsById.put(newId, copy(jobExecution)); } - @Override + @Override public List findJobExecutions(JobInstance jobInstance) { List executions = new ArrayList(); for (JobExecution exec : executionsById.values()) { @@ -72,7 +70,7 @@ public class MapJobExecutionDao implements JobExecutionDao { } Collections.sort(executions, new Comparator() { - @Override + @Override public int compare(JobExecution e1, JobExecution e2) { long result = (e1.getId() - e2.getId()); if (result > 0) { @@ -89,7 +87,7 @@ public class MapJobExecutionDao implements JobExecutionDao { return executions; } - @Override + @Override public void updateJobExecution(JobExecution jobExecution) { Long id = jobExecution.getId(); Assert.notNull(id, "JobExecution is expected to have an id (should be saved already)"); @@ -107,7 +105,7 @@ public class MapJobExecutionDao implements JobExecutionDao { } } - @Override + @Override public JobExecution getLastJobExecution(JobInstance jobInstance) { JobExecution lastExec = null; for (JobExecution exec : executionsById.values()) { @@ -126,11 +124,11 @@ public class MapJobExecutionDao implements JobExecutionDao { /* * (non-Javadoc) - * + * * @seeorg.springframework.batch.core.repository.dao.JobExecutionDao# * findRunningJobExecutions(java.lang.String) */ - @Override + @Override public Set findRunningJobExecutions(String jobName) { Set result = new HashSet(); for (JobExecution exec : executionsById.values()) { @@ -144,17 +142,17 @@ public class MapJobExecutionDao implements JobExecutionDao { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.repository.dao.JobExecutionDao#getJobExecution * (java.lang.Long) */ - @Override + @Override public JobExecution getJobExecution(Long executionId) { return copy(executionsById.get(executionId)); } - @Override + @Override public void synchronizeStatus(JobExecution jobExecution) { JobExecution saved = getJobExecution(jobExecution.getId()); if (saved.getVersion().intValue() != jobExecution.getVersion().intValue()) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobInstanceDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobInstanceDao.java index 7c6b2da9c..a0e23c953 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobInstanceDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobInstanceDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -21,9 +21,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Set; - import java.util.concurrent.CopyOnWriteArraySet; - import java.util.concurrent.atomic.AtomicLong; import org.springframework.batch.core.JobExecution; @@ -45,7 +43,7 @@ public class MapJobInstanceDao implements JobInstanceDao { jobInstances.clear(); } - @Override + @Override public JobInstance createJobInstance(String jobName, JobParameters jobParameters) { Assert.state(getJobInstance(jobName, jobParameters) == null, "JobInstance must not already exist"); @@ -57,7 +55,7 @@ public class MapJobInstanceDao implements JobInstanceDao { return jobInstance; } - @Override + @Override public JobInstance getJobInstance(String jobName, JobParameters jobParameters) { for (JobInstance instance : jobInstances) { @@ -69,7 +67,7 @@ public class MapJobInstanceDao implements JobInstanceDao { } - @Override + @Override public JobInstance getJobInstance(Long instanceId) { for (JobInstance instance : jobInstances) { if (instance.getId().equals(instanceId)) { @@ -79,7 +77,7 @@ public class MapJobInstanceDao implements JobInstanceDao { return null; } - @Override + @Override public List getJobNames() { List result = new ArrayList(); for (JobInstance instance : jobInstances) { @@ -89,7 +87,7 @@ public class MapJobInstanceDao implements JobInstanceDao { return result; } - @Override + @Override public List getJobInstances(String jobName, int start, int count) { List result = new ArrayList(); for (JobInstance instance : jobInstances) { @@ -99,7 +97,7 @@ public class MapJobInstanceDao implements JobInstanceDao { } Collections.sort(result, new Comparator() { // sort by ID descending - @Override + @Override public int compare(JobInstance o1, JobInstance o2) { return Long.signum(o2.getId() - o1.getId()); } @@ -110,7 +108,7 @@ public class MapJobInstanceDao implements JobInstanceDao { return result.subList(startIndex, endIndex); } - @Override + @Override public JobInstance getJobInstance(JobExecution jobExecution) { return jobExecution.getJobInstance(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java index e7e8e4095..8a4d62146 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapStepExecutionDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -56,7 +56,7 @@ public class MapStepExecutionDao implements StepExecutionDao { // Cheaper than full serialization is a reflective field copy, which is // fine for volatile storage ReflectionUtils.doWithFields(StepExecution.class, new ReflectionUtils.FieldCallback() { - @Override + @Override public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException { field.setAccessible(true); field.set(targetExecution, field.get(sourceExecution)); @@ -64,7 +64,7 @@ public class MapStepExecutionDao implements StepExecutionDao { }); } - @Override + @Override public void saveStepExecution(StepExecution stepExecution) { Assert.isTrue(stepExecution.getId() == null); @@ -85,7 +85,7 @@ public class MapStepExecutionDao implements StepExecutionDao { } - @Override + @Override public void updateStepExecution(StepExecution stepExecution) { Assert.notNull(stepExecution.getJobExecutionId()); @@ -111,12 +111,12 @@ public class MapStepExecutionDao implements StepExecutionDao { } } - @Override + @Override public StepExecution getStepExecution(JobExecution jobExecution, Long stepExecutionId) { return executionsByStepExecutionId.get(stepExecutionId); } - @Override + @Override public void addStepExecutions(JobExecution jobExecution) { Map executions = executionsByJobExecutionId.get(jobExecution.getId()); if (executions == null || executions.isEmpty()) { @@ -125,7 +125,7 @@ public class MapStepExecutionDao implements StepExecutionDao { List result = new ArrayList(executions.values()); Collections.sort(result, new Comparator() { - @Override + @Override public int compare(Entity o1, Entity o2) { return Long.signum(o2.getId() - o1.getId()); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/XStreamExecutionContextStringSerializer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/XStreamExecutionContextStringSerializer.java index 951b6f8c5..4f050ebb6 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/XStreamExecutionContextStringSerializer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/XStreamExecutionContextStringSerializer.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -57,7 +57,7 @@ public class XStreamExecutionContextStringSerializer implements ExecutionContext this.hierarchicalStreamDriver = hierarchicalStreamDriver; } - @Override + @Override public void afterPropertiesSet() throws Exception { init(); } @@ -81,7 +81,7 @@ public class XStreamExecutionContextStringSerializer implements ExecutionContext * @param out * @see Serializer#serialize(Object, OutputStream) */ - @Override + @Override public void serialize(Object context, OutputStream out) throws IOException { Assert.notNull(context); Assert.notNull(out); @@ -96,8 +96,7 @@ public class XStreamExecutionContextStringSerializer implements ExecutionContext * @return a reconstructed execution context * @see Deserializer#deserialize(InputStream) */ - @Override - @SuppressWarnings("unchecked") + @Override public Object deserialize(InputStream in) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(in)); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.java index dbfdcaf77..f6a10fb11 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -38,14 +38,15 @@ import org.springframework.util.Assert; * A {@link FactoryBean} that automates the creation of a * {@link SimpleJobRepository}. Declares abstract methods for providing DAO * object implementations. - * + * * @see JobRepositoryFactoryBean * @see MapJobRepositoryFactoryBean - * + * * @author Ben Hale * @author Lucas Ward * @author Robert Kasanicky */ +@SuppressWarnings("rawtypes") public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, InitializingBean { private PlatformTransactionManager transactionManager; @@ -83,16 +84,16 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I /** * The type of object to be returned from {@link #getObject()}. - * + * * @return JobRepository.class * @see org.springframework.beans.factory.FactoryBean#getObjectType() */ - @Override + @Override public Class getObjectType() { return JobRepository.class; } - @Override + @Override public boolean isSingleton() { return true; } @@ -102,7 +103,7 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I * JobExecution is created. Defaults to true because it is usually a * mistake, and leads to problems with restartability and also to deadlocks * in multi-threaded steps. - * + * * @param validateTransactionState the flag to set */ public void setValidateTransactionState(boolean validateTransactionState) { @@ -114,9 +115,9 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I * job execution entities are initially created. The default is * ISOLATION_SERIALIZABLE, which prevents accidental concurrent execution of * the same job (ISOLATION_REPEATABLE_READ would work as well). - * + * * @param isolationLevelForCreate the isolation level name to set - * + * * @see SimpleJobRepository#createJobExecution(String, * org.springframework.batch.core.JobParameters) */ @@ -135,7 +136,7 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I /** * The transaction manager used in this factory. Useful to inject into steps * and jobs, to ensure that they are using the same instance. - * + * * @return the transactionManager */ public PlatformTransactionManager getTransactionManager() { @@ -161,7 +162,7 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I + isolationLevelForCreate + "\n*=PROPAGATION_REQUIRED")); if (validateTransactionState) { DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(new MethodInterceptor() { - @Override + @Override public Object invoke(MethodInvocation invocation) throws Throwable { if (TransactionSynchronizationManager.isActualTransactionActive()) { throw new IllegalStateException( @@ -183,7 +184,7 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I } } - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(transactionManager, "TransactionManager must not be null."); @@ -195,7 +196,7 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I createExecutionContextDao()); } - @Override + @Override public Object getObject() throws Exception { if (proxyFactory == null) { afterPropertiesSet(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java index 1b8ddfe91..9518bfb6f 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -39,21 +39,21 @@ import org.springframework.batch.item.ExecutionContext; import org.springframework.util.Assert; /** - * + * *

    * Implementation of {@link JobRepository} that stores JobInstances, * JobExecutions, and StepExecutions using the injected DAOs. *

    - * + * * @author Lucas Ward * @author Dave Syer * @author Robert Kasanicky - * + * * @see JobRepository * @see JobInstanceDao * @see JobExecutionDao * @see StepExecutionDao - * + * */ public class SimpleJobRepository implements JobRepository { @@ -83,12 +83,12 @@ public class SimpleJobRepository implements JobRepository { this.ecDao = ecDao; } - @Override + @Override public boolean isJobInstanceExists(String jobName, JobParameters jobParameters) { return jobInstanceDao.getJobInstance(jobName, jobParameters) != null; } - @Override + @Override public JobExecution createJobExecution(String jobName, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException { @@ -97,7 +97,7 @@ public class SimpleJobRepository implements JobRepository { /* * Find all jobs matching the runtime information. - * + * * If this method is transactional, and the isolation level is * REPEATABLE_READ or better, another launcher trying to start the same * job in another thread or process will block until this transaction @@ -118,12 +118,12 @@ public class SimpleJobRepository implements JobRepository { throw new JobExecutionAlreadyRunningException("A job execution for this job is already running: " + jobInstance); } - + BatchStatus status = execution.getStatus(); if (status == BatchStatus.COMPLETED || status == BatchStatus.ABANDONED) { throw new JobInstanceAlreadyCompleteException( "A job instance already exists and is complete for parameters=" + jobParameters - + ". If you want to run this job again, change the parameters."); + + ". If you want to run this job again, change the parameters."); } } executionContext = ecDao.getExecutionContext(jobExecutionDao.getLastJobExecution(jobInstance)); @@ -147,7 +147,7 @@ public class SimpleJobRepository implements JobRepository { } - @Override + @Override public void update(JobExecution jobExecution) { Assert.notNull(jobExecution, "JobExecution cannot be null."); @@ -158,7 +158,7 @@ public class SimpleJobRepository implements JobRepository { jobExecutionDao.updateJobExecution(jobExecution); } - @Override + @Override public void add(StepExecution stepExecution) { validateStepExecution(stepExecution); @@ -167,7 +167,7 @@ public class SimpleJobRepository implements JobRepository { ecDao.saveExecutionContext(stepExecution); } - @Override + @Override public void update(StepExecution stepExecution) { validateStepExecution(stepExecution); Assert.notNull(stepExecution.getId(), "StepExecution must already be saved (have an id assigned)"); @@ -183,19 +183,19 @@ public class SimpleJobRepository implements JobRepository { Assert.notNull(stepExecution.getJobExecutionId(), "StepExecution must belong to persisted JobExecution"); } - @Override + @Override public void updateExecutionContext(StepExecution stepExecution) { validateStepExecution(stepExecution); Assert.notNull(stepExecution.getId(), "StepExecution must already be saved (have an id assigned)"); ecDao.updateExecutionContext(stepExecution); } - - @Override + + @Override public void updateExecutionContext(JobExecution jobExecution) { ecDao.updateExecutionContext(jobExecution); } - @Override + @Override public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) { List jobExecutions = jobExecutionDao.findJobExecutions(jobInstance); List stepExecutions = new ArrayList(jobExecutions.size()); @@ -226,7 +226,7 @@ public class SimpleJobRepository implements JobRepository { /** * @return number of executions of the step within given job instance */ - @Override + @Override public int getStepExecutionCount(JobInstance jobInstance, String stepName) { int count = 0; List jobExecutions = jobExecutionDao.findJobExecutions(jobInstance); @@ -246,7 +246,7 @@ public class SimpleJobRepository implements JobRepository { * the provided StepExecution has been interrupted. If, after synchronizing * the status with the database, the status has been updated to STOPPING, * then the job has been interrupted. - * + * * @param stepExecution */ private void checkForInterruption(StepExecution stepExecution) { @@ -258,14 +258,14 @@ public class SimpleJobRepository implements JobRepository { } } - @Override + @Override public JobExecution getLastJobExecution(String jobName, JobParameters jobParameters) { JobInstance jobInstance = jobInstanceDao.getJobInstance(jobName, jobParameters); if (jobInstance == null) { return null; } JobExecution jobExecution = jobExecutionDao.getLastJobExecution(jobInstance); - + if (jobExecution != null) { jobExecution.setExecutionContext(ecDao.getExecutionContext(jobExecution)); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/resource/ListPreparedStatementSetter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/resource/ListPreparedStatementSetter.java index e8be8af99..8b367bb54 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/resource/ListPreparedStatementSetter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/resource/ListPreparedStatementSetter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -29,21 +29,21 @@ import org.springframework.util.Assert; /** * Implementation of the {@link PreparedStatementSetter} interface that accepts * a list of values to be set on a PreparedStatement. This is usually used in - * conjunction with the {@link JdbcCursorItemReader} to allow for the replacement + * conjunction with the {@link JdbcCursorItemReader} to allow for the replacement * of bind variables when generating the cursor. The order of the list will be * used to determine the ordering of setting variables. For example, the first * item in the list will be the first bind variable set. (i.e. it will * correspond to the first '?' in the SQL statement) - * + * * @author Lucas Ward - * + * */ public class ListPreparedStatementSetter implements - PreparedStatementSetter, InitializingBean { +PreparedStatementSetter, InitializingBean { private List parameters; - @Override + @Override public void setValues(PreparedStatement ps) throws SQLException { for (int i = 0; i < parameters.size(); i++) { StatementCreatorUtils.setParameterValue(ps, i + 1, SqlTypeValue.TYPE_UNKNOWN, parameters.get(i)); @@ -59,7 +59,7 @@ public class ListPreparedStatementSetter implements this.parameters = parameters; } - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(parameters, "Parameters must be provided"); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicy.java index 391a335ec..a61393888 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -35,16 +35,16 @@ import org.springframework.util.Assert; * step. N.B. only after the step has started will the completion policy be * usable. *

    - * + * *

    * It is easier and probably preferable to simply declare the chunk with a * commit-interval that is a late-binding expression (e.g. * #{jobParameters['commit.interval']}). That feature is available * from of Spring Batch 2.1.7. *

    - * + * * @author Dave Syer - * + * * @see CompletionPolicy */ public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSupport implements CompletionPolicy { @@ -68,10 +68,10 @@ public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSu * the {@link JobParameters}. If there is a Long parameter with the given * key name, the intValue of this parameter is used. If not an exception * will be thrown. - * + * * @see org.springframework.batch.core.listener.StepExecutionListenerSupport#beforeStep(org.springframework.batch.core.StepExecution) */ - @Override + @Override public void beforeStep(StepExecution stepExecution) { JobParameters jobParameters = stepExecution.getJobParameters(); Assert.state(jobParameters.getParameters().containsKey(keyName), @@ -86,7 +86,7 @@ public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSu * indicates completion * @see CompletionPolicy#isComplete(RepeatContext, RepeatStatus) */ - @Override + @Override public boolean isComplete(RepeatContext context, RepeatStatus result) { Assert.state(delegate != null, "The delegate resource has not been initialised. " + "Remember to register this object as a StepListener."); @@ -98,7 +98,7 @@ public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSu * @return if the commit interval has been reached * @see org.springframework.batch.repeat.CompletionPolicy#isComplete(org.springframework.batch.repeat.RepeatContext) */ - @Override + @Override public boolean isComplete(RepeatContext context) { Assert.state(delegate != null, "The delegate resource has not been initialised. " + "Remember to register this object as a StepListener."); @@ -110,7 +110,7 @@ public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSu * @return a new {@link RepeatContext} * @see org.springframework.batch.repeat.CompletionPolicy#start(org.springframework.batch.repeat.RepeatContext) */ - @Override + @Override public RepeatContext start(RepeatContext parent) { Assert.state(delegate != null, "The delegate resource has not been initialised. " + "Remember to register this object as a StepListener."); @@ -121,7 +121,7 @@ public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSu * @param context * @see org.springframework.batch.repeat.CompletionPolicy#update(org.springframework.batch.repeat.RepeatContext) */ - @Override + @Override public void update(RepeatContext context) { Assert.state(delegate != null, "The delegate resource has not been initialised. " + "Remember to register this object as a StepListener."); @@ -132,7 +132,7 @@ public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSu * Delegates to the wrapped {@link CompletionPolicy} if set, otherwise * returns the value of {@link #setKeyName(String)}. */ - @Override + @Override public String toString() { return (delegate == null) ? keyName : delegate.toString(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScope.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScope.java index fb6ba5aeb..f2e45ef8d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScope.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -44,34 +44,34 @@ import org.springframework.util.StringValueResolver; * step. All objects in this scope are <aop:scoped-proxy/> (no need to * decorate the bean definitions).
    *
    - * + * * In addition, support is provided for late binding of references accessible * from the {@link StepContext} using #{..} placeholders. Using this feature, * bean properties can be pulled from the step or job execution context and the * job parameters. E.g. - * + * *
      * <bean id="..." class="..." scope="step">
      * 	<property name="parent" ref="#{stepExecutionContext[helper]}" />
      * </bean>
    - * 
    + *
      * <bean id="..." class="..." scope="step">
      * 	<property name="name" value="#{stepExecutionContext['input.name']}" />
      * </bean>
    - * 
    + *
      * <bean id="..." class="..." scope="step">
      * 	<property name="name" value="#{jobParameters[input]}" />
      * </bean>
    - * 
    + *
      * <bean id="..." class="..." scope="step">
      * 	<property name="name" value="#{jobExecutionContext['input.stem']}.txt" />
      * </bean>
      * 
    - * + * * The {@link StepContext} is referenced using standard bean property paths (as * per {@link BeanWrapper}). The examples above all show the use of the Map * accessors provided as a convenience for step and job attributes. - * + * * @author Dave Syer * @since 2.0 */ @@ -91,7 +91,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { this.order = order; } - @Override + @Override public int getOrder() { return order; } @@ -112,7 +112,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * Flag to indicate that proxies should use dynamic subclassing. This allows * classes with no interface to be proxied. Defaults to false. - * + * * @param proxyTargetClass set to true to have proxies created using dynamic * subclasses */ @@ -125,7 +125,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { * step-scoped beans. This method is part of the Scope SPI in Spring 3.0, * but should just be ignored by earlier versions of Spring. */ - @Override + @Override public Object resolveContextualObject(String key) { StepContext context = getContext(); // TODO: support for attributes as well maybe (setters not exposed yet @@ -136,7 +136,8 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * @see Scope#get(String, ObjectFactory) */ - @Override + @SuppressWarnings("rawtypes") + @Override public Object get(String name, ObjectFactory objectFactory) { StepContext context = getContext(); @@ -164,7 +165,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * @see Scope#getConversationId() */ - @Override + @Override public String getConversationId() { StepContext context = getContext(); return context.getId(); @@ -173,7 +174,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * @see Scope#registerDestructionCallback(String, Runnable) */ - @Override + @Override public void registerDestructionCallback(String name, Runnable callback) { StepContext context = getContext(); logger.debug(String.format("Registered destruction callback in scope=%s, name=%s", this.name, name)); @@ -183,7 +184,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * @see Scope#remove(String) */ - @Override + @Override public Object remove(String name) { StepContext context = getContext(); logger.debug(String.format("Removing from scope=%s, name=%s", this.name, name)); @@ -193,7 +194,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * Get an attribute accessor in the form of a {@link StepContext} that can * be used to store scoped bean instances. - * + * * @return the current step context which we can use as a scope storage * medium */ @@ -207,13 +208,13 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * Register this scope with the enclosing BeanFactory. - * + * * @see BeanFactoryPostProcessor#postProcessBeanFactory(ConfigurableListableBeanFactory) - * + * * @param beanFactory the BeanFactory to register with * @throws BeansException if there is a problem. */ - @Override + @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { beanFactory.registerScope(name, this); @@ -251,7 +252,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * Public setter for the name property. This can then be used as a bean * definition attribute, e.g. scope="step". Defaults to "step". - * + * * @param name the name to set for this scope. */ public void setName(String name) { @@ -264,7 +265,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { * <aop-auto-proxy/> to a step scoped bean. Also if Spring EL is not * available will enable a weak version of late binding as described in the * class-level docs. - * + * * @param beanName the bean name to replace * @param definition the bean definition to replace * @param registry the enclosing {@link BeanDefinitionRegistry} @@ -298,9 +299,9 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * Helper class to scan a bean definition hierarchy and force the use of * auto-proxy for step scoped beans. - * + * * @author Dave Syer - * + * */ private static class Scopifier extends BeanDefinitionVisitor { @@ -314,7 +315,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { public Scopifier(BeanDefinitionRegistry registry, String scope, boolean proxyTargetClass, boolean scoped) { super(new StringValueResolver() { - @Override + @Override public String resolveStringValue(String value) { return value; } @@ -364,9 +365,9 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { /** * Helper class to scan a bean definition hierarchy and hide placeholders * from Spring EL. - * + * * @author Dave Syer - * + * */ private static class ExpressionHider extends BeanDefinitionVisitor { @@ -382,7 +383,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { private ExpressionHider(String scope, final boolean scoped) { super(new StringValueResolver() { - @Override + @Override public String resolveStringValue(String value) { if (scoped && value.contains(PLACEHOLDER_PREFIX) && value.contains(PLACEHOLDER_SUFFIX)) { value = value.replace(PLACEHOLDER_PREFIX, REPLACEMENT_PREFIX); @@ -409,7 +410,7 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { boolean scopeChange = !scope.equals(otherScope); if (scopeChange) { new ExpressionHider(otherScope == null ? scope : otherScope, !scoped) - .visitBeanDefinition(definition); + .visitBeanDefinition(definition); // Exit here so that nested inner bean definitions are not // analysed by both visitors return value; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContextRepeatCallback.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContextRepeatCallback.java index 69e7ea273..b4a383e81 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContextRepeatCallback.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContextRepeatCallback.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -30,14 +30,14 @@ import org.springframework.util.ObjectUtils; /** * Convenient base class for clients who need to do something in a repeat * callback inside a {@link Step}. - * + * * @author Dave Syer - * + * */ public abstract class StepContextRepeatCallback implements RepeatCallback { private final Queue attributeQueue = new LinkedBlockingQueue(); - + private final StepExecution stepExecution; private final Log logger = LogFactory.getLog(StepContextRepeatCallback.class); @@ -56,12 +56,12 @@ public abstract class StepContextRepeatCallback implements RepeatCallback { * if the callback is executed in a pooled thread. Handles the registration * and de-registration of the step context, so clients should not duplicate * those calls. - * + * * @see RepeatCallback#doInIteration(RepeatContext) */ - @Override + @Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { - + // The StepContext has to be the same for all chunks, // otherwise step-scoped beans will be re-initialised for each chunk. StepContext stepContext = StepSynchronizationManager.register(stepExecution); @@ -95,7 +95,7 @@ public abstract class StepContextRepeatCallback implements RepeatCallback { * that they are finished with a context by removing all the attributes they * have added. If a worker does not remove them another thread might see * stale state. - * + * * @param context the current {@link RepeatContext} * @param chunkContext the chunk context in which to carry out the work * @return the repeat status from the execution diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/PlaceholderProxyFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/PlaceholderProxyFactoryBean.java index 4b58e1b43..515469274 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/PlaceholderProxyFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/PlaceholderProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -41,10 +41,11 @@ import org.springframework.util.ClassUtils; * Factory bean for proxies that can replace placeholders in their target. Just * a specialisation of {@link ScopedProxyFactoryBean}, with a different target * source type. - * + * * @author Dave Syer - * + * */ +@SuppressWarnings({ "serial", "rawtypes" }) public class PlaceholderProxyFactoryBean extends ProxyConfig implements FactoryBean, BeanFactoryAware { /** The TargetSource that manages scoping */ @@ -74,7 +75,7 @@ public class PlaceholderProxyFactoryBean extends ProxyConfig implements FactoryB this.scopedTargetSource.setTargetBeanName(targetBeanName); } - @Override + @Override public void setBeanFactory(BeanFactory beanFactory) { if (!(beanFactory instanceof ConfigurableBeanFactory)) { throw new IllegalStateException("Not running in a ConfigurableBeanFactory: " + beanFactory); @@ -105,13 +106,13 @@ public class PlaceholderProxyFactoryBean extends ProxyConfig implements FactoryB // proxy itself is not subject to auto-proxying! Only its target bean // is. pf.addInterface(AopInfrastructureBean.class); - + this.scopedTargetSource.afterPropertiesSet(); this.proxy = pf.getProxy(cbf.getBeanClassLoader()); } - @Override + @Override public Object getObject() { if (this.proxy == null) { throw new FactoryBeanNotInitializedException(); @@ -119,7 +120,7 @@ public class PlaceholderProxyFactoryBean extends ProxyConfig implements FactoryB return this.proxy; } - @Override + @Override public Class getObjectType() { if (this.proxy != null) { return this.proxy.getClass(); @@ -130,7 +131,7 @@ public class PlaceholderProxyFactoryBean extends ProxyConfig implements FactoryB return null; } - @Override + @Override public boolean isSingleton() { return true; } @@ -139,7 +140,7 @@ public class PlaceholderProxyFactoryBean extends ProxyConfig implements FactoryB * Convenience method to create a {@link BeanDefinition} for a target * wrapped in a placeholder tarrget source, able to defer binding of * placeholders until the bean is used. - * + * * @param definition a target bean definition * @param registry a {@link BeanDefinitionRegistry} * @param proxyTargetClass true if we need to use CGlib to create the diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/StepContextFactory.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/StepContextFactory.java index e388c0ac0..19f1cc560 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/StepContextFactory.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/StepContextFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -22,18 +22,18 @@ import org.springframework.batch.core.scope.context.StepSynchronizationManager; /** * Implementation of {@link ContextFactory} that provides the current * {@link StepContext} as a context object. - * + * * @author Dave Syer - * + * */ public class StepContextFactory implements ContextFactory { - @Override + @Override public Object getContext() { return StepSynchronizationManager.getContext(); } - @Override + @Override public String getContextId() { StepContext context = StepSynchronizationManager.getContext(); return context!=null ? (String) context.getId() : "sysinit"; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java index bfe1a1d7f..91bf92520 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -41,7 +41,7 @@ import org.springframework.util.ClassUtils; /** * A {@link Step} implementation that provides common behavior to subclasses, including registering and calling * listeners. - * + * * @author Dave Syer * @author Ben Hale * @author Robert Kasanicky @@ -67,20 +67,20 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw super(); } - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.state(name != null, "A Step must have a name"); Assert.state(jobRepository != null, "JobRepository is mandatory"); } - @Override + @Override public String getName() { return this.name; } /** * Set the name property. Always overrides the default value if this object is a Spring bean. - * + * * @see #setBeanName(java.lang.String) */ public void setName(String name) { @@ -91,31 +91,31 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw * Set the name property if it is not already set. Because of the order of the callbacks in a Spring container the * name property will be set first if it is present. Care is needed with bean definition inheritance - if a parent * bean has a name, then its children need an explicit name as well, otherwise they will not be unique. - * + * * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String) */ - @Override + @Override public void setBeanName(String name) { if (this.name == null) { this.name = name; } } - @Override + @Override public int getStartLimit() { return this.startLimit; } /** * Public setter for the startLimit. - * + * * @param startLimit the startLimit to set */ public void setStartLimit(int startLimit) { this.startLimit = startLimit; } - @Override + @Override public boolean isAllowStartIfComplete() { return this.allowStartIfComplete; } @@ -123,7 +123,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Public setter for flag that determines whether the step should start again if it is already complete. Defaults to * false. - * + * * @param allowStartIfComplete the value of the flag to set */ public void setAllowStartIfComplete(boolean allowStartIfComplete) { @@ -132,7 +132,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Convenient constructor for setting only the name property. - * + * * @param name */ public AbstractStep(String name) { @@ -142,7 +142,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Extension point for subclasses to execute business logic. Subclasses should set the {@link ExitStatus} on the * {@link StepExecution} before returning. - * + * * @param stepExecution the current step context * @throws Exception */ @@ -151,7 +151,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Extension point for subclasses to provide callbacks to their collaborators at the beginning of a step, to open or * acquire resources. Does nothing by default. - * + * * @param ctx the {@link ExecutionContext} to use * @throws Exception */ @@ -161,7 +161,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Extension point for subclasses to provide callbacks to their collaborators at the end of a step (right at the end * of the finally block), to close or release resources. Does nothing by default. - * + * * @param ctx the {@link ExecutionContext} to use * @throws Exception */ @@ -173,9 +173,9 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw * {@link #open(ExecutionContext)}), execution logic ({@link #doExecute(StepExecution)}) and resource closing ( * {@link #close(ExecutionContext)}). */ - @Override + @Override public final void execute(StepExecution stepExecution) throws JobInterruptedException, - UnexpectedJobExecutionException { + UnexpectedJobExecutionException { logger.debug("Executing: id=" + stepExecution.getId()); stepExecution.setStartTime(new Date()); @@ -288,7 +288,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Register a step listener for callbacks at the appropriate stages in a step execution. - * + * * @param listener a {@link StepExecutionListener} */ public void registerStepExecutionListener(StepExecutionListener listener) { @@ -297,7 +297,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Register each of the objects as listeners. - * + * * @param listeners an array of listener objects of known types. */ public void setStepExecutionListeners(StepExecutionListener[] listeners) { @@ -315,7 +315,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Public setter for {@link JobRepository}. - * + * * @param jobRepository is a mandatory dependence (no default). */ public void setJobRepository(JobRepository jobRepository) { @@ -326,7 +326,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw return jobRepository; } - @Override + @Override public String toString() { return ClassUtils.getShortName(getClass()) + ": [name=" + name + "]"; } @@ -334,7 +334,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw /** * Default mapping from throwable to {@link ExitStatus}. Clients can modify the exit code using a * {@link StepExecutionListener}. - * + * * @param ex the cause of the failure * @return an {@link ExitStatus} */ diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/NoWorkFoundStepExecutionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/NoWorkFoundStepExecutionListener.java index 63182b3d7..8aced0999 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/NoWorkFoundStepExecutionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/NoWorkFoundStepExecutionListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2013 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. @@ -22,12 +22,12 @@ import org.springframework.batch.core.listener.StepExecutionListenerSupport; /** * Fails the step if no items have been processed ( item count is 0). - * + * * @author Robert Kasanicky */ public class NoWorkFoundStepExecutionListener extends StepExecutionListenerSupport { - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { if (stepExecution.getReadCount() == 0) { return ExitStatus.FAILED; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/StepLocatorStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/StepLocatorStepFactoryBean.java index da0636330..7345c6d54 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/StepLocatorStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/StepLocatorStepFactoryBean.java @@ -1,3 +1,18 @@ +/* + * Copyright 2012-2013 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.core.step; import org.springframework.batch.core.Job; @@ -8,9 +23,9 @@ import org.springframework.beans.factory.FactoryBean; * Convenience factory for {@link Step} instances given a {@link StepLocator}. * Most implementations of {@link Job} implement StepLocator, so that can be a * good starting point. - * + * * @author Dave Syer - * + * */ public class StepLocatorStepFactoryBean implements FactoryBean { @@ -33,30 +48,30 @@ public class StepLocatorStepFactoryBean implements FactoryBean { } /** - * + * * @see FactoryBean#getObject() */ - @Override + @Override public Step getObject() throws Exception { return stepLocator.getStep(stepName); } /** * Tell clients that we are a factory for {@link Step} instances. - * + * * @see FactoryBean#getObjectType() */ - @Override + @Override public Class getObjectType() { return Step.class; } /** * Always return true as optimization for bean factory. - * + * * @see FactoryBean#isSingleton() */ - @Override + @Override public boolean isSingleton() { return true; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/ThreadStepInterruptionPolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/ThreadStepInterruptionPolicy.java index 6bc2077d6..daed5d7d1 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/ThreadStepInterruptionPolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/ThreadStepInterruptionPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 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. @@ -23,10 +23,10 @@ import org.springframework.batch.core.StepExecution; /** * Policy that checks the current thread to see if it has been interrupted. - * + * * @author Lucas Ward * @author Dave Syer - * + * */ public class ThreadStepInterruptionPolicy implements StepInterruptionPolicy { @@ -36,7 +36,7 @@ public class ThreadStepInterruptionPolicy implements StepInterruptionPolicy { * Returns if the current job lifecycle has been interrupted by checking if * the current thread is interrupted. */ - @Override + @Override public void checkInterrupted(StepExecution stepExecution) throws JobInterruptedException { if (isInterrupted(stepExecution)) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java index dd43ce27e..2e0dec69c 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2013 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. @@ -73,9 +73,9 @@ import org.springframework.util.Assert; /** * A step builder for fully fault tolerant chunk-oriented item processing steps. Extends {@link SimpleStepBuilder} with * additional properties for retry and skip of failed items. - * + * * @author Dave Syer - * + * * @since 2.2 */ public class FaultTolerantStepBuilder extends SimpleStepBuilder { @@ -116,7 +116,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Create a new builder initialized with any properties in the parent. The parent is copied, so it can be re-used. - * + * * @param parent a parent helper containing common step properties */ public FaultTolerantStepBuilder(StepBuilderHelper parent) { @@ -125,7 +125,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Create a new builder initialized with any properties in the parent. The parent is copied, so it can be re-used. - * + * * @param parent a parent helper containing common step properties */ protected FaultTolerantStepBuilder(SimpleStepBuilder parent) { @@ -134,7 +134,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Create a new chunk oriented tasklet with reader, writer and processor as provided. - * + * * @see org.springframework.batch.core.step.builder.SimpleStepBuilder#createTasklet() */ @Override @@ -152,7 +152,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Register a skip listener. - * + * * @param listener the listener to register * @return this for fluent chaining */ @@ -175,7 +175,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Register a retry listener. - * + * * @param listener the listener to register * @return this for fluent chaining */ @@ -190,7 +190,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { * own implementation to ensure that they can be identified. Often a key generator is not necessary as long as the * items have reliable hash code and equals implementations, or the reader is not transactional (the default) and * the item processor either is itself not transactional (not the default) or does not create new items. - * + * * @param keyGenerator a key generator for the stateful retry * @return this for fluent chaining */ @@ -202,7 +202,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * The maximum number of times to try a failed item. Zero and one both translate to try only once and do not retry. * Ignored if an explicit {@link #retryPolicy} is set. - * + * * @param retryLimit the retry limit (default 0) * @return this for fluent chaining */ @@ -214,7 +214,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Provide an explicit retry policy instead of using the {@link #retryLimit(int)} and retryable exceptions provided * elsewhere. Can be used to retry different exceptions a different number of times, for instance. - * + * * @param retryPolicy a retry policy * @return this for fluent chaining */ @@ -227,7 +227,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { * Provide a backoff policy to prevent items being retried immediately (e.g. in case the failure was caused by a * remote resource failure that might take some time to be resolved). Ignored if an explicit {@link #retryPolicy} is * set. - * + * * @param backOffPolicy the back off policy to use (default no backoff) * @return this for fluent chaining */ @@ -239,7 +239,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Provide an explicit retry context cache. Retry is stateful across transactions in the case of failures in item * processing or writing, so some information about the context for subsequent retries has to be stored. - * + * * @param retryContextCache cache for retry contexts in between transactions (default to standard in-memory * implementation) * @return this for fluent chaining @@ -252,7 +252,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Sets the maximium number of failed items to skip before the step fails. Ignored if an explicit * {@link #skipPolicy(SkipPolicy)} is provided. - * + * * @param skipLimit the skip limit to set * @return this for fluent chaining */ @@ -263,7 +263,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Explicitly prevent certain exceptions (and subclasses) from being skipped. - * + * * @param type the non-skippable exception * @return this for fluent chaining */ @@ -274,7 +274,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Explicitly request certain exceptions (and subclasses) to be skipped. - * + * * @param type * @return this for fluent chaining */ @@ -286,7 +286,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Provide an explicit policy for managing skips. A skip policy determines which exceptions are skippable and how * many times. - * + * * @param skipPolicy the skip policy * @return this for fluent chaining */ @@ -299,7 +299,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { * Mark this exception as ignorable during item read or processing operations. Processing continues with no * additional callbacks (use skips instead if you need to be notified). Ignored during write because there is no * guarantee of skip and retry without rollback. - * + * * @param type the exception to mark as no rollback * @return this for fluent chaining */ @@ -310,7 +310,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Explicitly ask for an exception (and subclasses) to be excluded from retry. - * + * * @param type the exception to exclude from retry * @return this for fluent chaining */ @@ -321,7 +321,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Explicitly ask for an exception (and subclasses) to be retried. - * + * * @param type the exception to retry * @return this for fluent chaining */ @@ -334,7 +334,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { * Mark the item processor as non-transactional (default is the opposite). If this flag is set the results of item * processing are cached across transactions in between retries and during skip processing, otherwise the processor * will be called in every transaction. - * + * * @return this for fluent chaining */ public FaultTolerantStepBuilder processorNonTransactional() { @@ -446,7 +446,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Convenience method to get an exception classifier based on the provided transaction attributes. - * + * * @return an exception classifier: maps to true if an exception should cause rollback */ private Classifier getRollbackClassifier() { @@ -466,7 +466,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { final Classifier panic = new BinaryExceptionClassifier(types, true); classifier = new Classifier() { - @Override + @Override public Boolean classify(Throwable classifiable) { // Rollback if either the user's list or our own applies return panic.classify(classifiable) || binary.classify(classifiable); @@ -479,6 +479,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { } + @SuppressWarnings("serial") private TransactionAttribute getTransactionAttribute(TransactionAttribute attribute) { final Classifier classifier = getRollbackClassifier(); @@ -584,7 +585,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Wrap a {@link SkipPolicy} and make it consistent with known fatal exceptions. - * + * * @param skipPolicy an existing skip policy * @return a skip policy that will not skip fatal exceptions */ @@ -627,16 +628,16 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { exceptions.add(fatal); } } - nonRetryableExceptionClasses = (List>) exceptions; + nonRetryableExceptionClasses = exceptions; } /** * ChunkListener that wraps exceptions thrown from the ChunkListener in {@link FatalStepExecutionException} to force * termination of StepExecution - * + * * ChunkListeners shoulnd't throw exceptions and expect continued processing, they must be handled in the * implementation or the step will terminate - * + * */ private class TerminateOnExceptionChunkListenerDelegate implements ChunkListener { @@ -646,7 +647,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { this.chunkListener = chunkListener; } - @Override + @Override public void beforeChunk() { try { chunkListener.beforeChunk(); @@ -656,7 +657,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { } } - @Override + @Override public void afterChunk() { try { chunkListener.afterChunk(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/FaultTolerantStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/FaultTolerantStepFactoryBean.java index 7a7ca8df9..566847214 100755 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/FaultTolerantStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/FaultTolerantStepFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -35,20 +35,18 @@ import org.springframework.retry.policy.MapRetryContextCache; import org.springframework.retry.policy.RetryContextCache; /** - * Factory bean for step that provides options for configuring skip behaviour. User can set {@link #setSkipLimit(int)} - * to set how many exceptions of {@link #setSkippableExceptionClasses(Collection)} types are tolerated. - * {@link #setFatalExceptionClasses(Collection)} will cause immediate termination of job - they are treated as higher - * priority than {@link #setSkippableExceptionClasses(Collection)}, so the two lists don't need to be exclusive. - * + * Factory bean for step that provides options for configuring skip behavior. User can set {@link #setSkipLimit(int)} + * to set how many exceptions of {@link #setSkippableExceptionClasses(Map)} types are tolerated. + * * Skippable exceptions on write will by default cause transaction rollback - to avoid rollback for specific exception * class include it in the transaction attribute as "no rollback for". - * + * * @see SimpleStepFactoryBean - * + * * @author Dave Syer * @author Robert Kasanicky * @author Morten Andersen-Gott - * + * */ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean { @@ -81,7 +79,7 @@ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean extends SimpleStepFactoryBean extends SimpleStepFactoryBeanretryLimit == 1 by default. - * + * * @param retryLimit the retry limit to set, must be greater or equal to 1. */ public void setRetryLimit(int retryLimit) { @@ -112,13 +110,13 @@ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean - * + * * The default value should be high enough and more for most purposes. To breach the limit in a single-threaded step * typically you have to have this many failures in a single transaction. Defaults to the value in the * {@link MapRetryContextCache}.
    - * + * * This property is ignored if the {@link #setRetryContextCache(RetryContextCache)} is set directly. - * + * * @param cacheCapacity the cache capacity to set (greater than 0 else ignored) */ public void setCacheCapacity(int cacheCapacity) { @@ -128,7 +126,7 @@ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean extends SimpleStepFactoryBean, Boolean> retryableExceptionClasses) { @@ -146,7 +144,7 @@ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean extends SimpleStepFactoryBean extends SimpleStepFactoryBean extends SimpleStepFactoryBean extends SimpleStepFactoryBean * Defaults to all no exception. - * + * * @param exceptionClasses defaults to Exception */ public void setSkippableExceptionClasses(Map, Boolean> exceptionClasses) { @@ -203,7 +201,7 @@ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean * Defaults is empty. - * + * * @param noRollbackExceptionClasses the exception classes to set */ public void setNoRollbackExceptionClasses(Collection> noRollbackExceptionClasses) { @@ -217,7 +215,7 @@ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean createBuilder(String name) { return new FaultTolerantStepBuilder(new StepBuilder(name)); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/SimpleStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/SimpleStepFactoryBean.java index 4d59bbfa0..f17e3dcf9 100755 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/SimpleStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/SimpleStepFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -50,16 +50,17 @@ import org.springframework.transaction.interceptor.TransactionAttribute; /** * Most common configuration options for simple steps should be found here. Use this factory bean instead of creating a * {@link Step} implementation manually. - * + * * This factory does not support configuration of fault-tolerant behavior, use appropriate subclass of this factory bean * to configure skip or retry. - * + * * @see FaultTolerantStepFactoryBean - * + * * @author Dave Syer * @author Robert Kasanicky - * + * */ +@SuppressWarnings("rawtypes") public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { private String name; @@ -118,7 +119,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * Flag to signal that the reader is transactional (usually a JMS consumer) so that items are re-presented after a * rollback. The default is false and readers are assumed to be forward-only. - * + * * @param isReaderTransactionalQueue the value of the flag */ public void setIsReaderTransactionalQueue(boolean isReaderTransactionalQueue) { @@ -135,10 +136,10 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * Set the bean name property, which will become the name of the {@link Step} when it is created. - * + * * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String) */ - @Override + @Override public void setBeanName(String name) { this.name = name; } @@ -153,7 +154,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * The timeout for an individual transaction in the step. - * + * * @param transactionTimeout the transaction timeout to set, defaults to infinite */ public void setTransactionTimeout(int transactionTimeout) { @@ -176,7 +177,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for the start limit for the step. - * + * * @param startLimit the startLimit to set */ public void setStartLimit(int startLimit) { @@ -186,7 +187,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for the flag to indicate that the step should be replayed on a restart, even if successful the * first time. - * + * * @param allowStartIfComplete the shouldAllowStartIfComplete to set */ public void setAllowStartIfComplete(boolean allowStartIfComplete) { @@ -217,7 +218,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * The streams to inject into the {@link Step}. Any instance of {@link ItemStream} can be used, and will then * receive callbacks at the appropriate stage in the step. - * + * * @param streams an array of listeners */ public void setStreams(ItemStream[] streams) { @@ -227,7 +228,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * The listeners to inject into the {@link Step}. Any instance of {@link StepListener} can be used, and will then * receive callbacks at the appropriate stage in the step. - * + * * @param listeners an array of listeners */ public void setListeners(StepListener[] listeners) { @@ -268,7 +269,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for {@link JobRepository}. - * + * * @param jobRepository is a mandatory dependence (no default). */ public void setJobRepository(JobRepository jobRepository) { @@ -277,7 +278,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for the {@link PlatformTransactionManager}. - * + * * @param transactionManager the transaction manager to set */ public void setTransactionManager(PlatformTransactionManager transactionManager) { @@ -312,10 +313,10 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * Create a {@link Step} from the configuration provided. - * + * * @see FactoryBean#getObject() */ - @Override + @Override public final Object getObject() throws Exception { SimpleStepBuilder builder = createBuilder(getName()); applyConfiguration(builder); @@ -327,7 +328,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { return new SimpleStepBuilder(new StepBuilder(name)); } - @Override + @Override public Class getObjectType() { return TaskletStep.class; } @@ -335,10 +336,10 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * Returns true by default, but in most cases a {@link Step} should not be treated as thread safe. Clients are * recommended to create a new step for each job execution. - * + * * @see org.springframework.beans.factory.FactoryBean#isSingleton() */ - @Override + @Override public boolean isSingleton() { return this.singleton; } @@ -353,7 +354,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * Set the commit interval. Either set this or the chunkCompletionPolicy but not both. - * + * * @param commitInterval 1 by default */ public void setCommitInterval(int commitInterval) { @@ -364,7 +365,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { * Public setter for the {@link CompletionPolicy} applying to the chunk level. A transaction will be committed when * this policy decides to complete. Defaults to a {@link SimpleCompletionPolicy} with chunk size equal to the * commitInterval property. - * + * * @param chunkCompletionPolicy the chunkCompletionPolicy to set */ public void setChunkCompletionPolicy(CompletionPolicy chunkCompletionPolicy) { @@ -422,7 +423,7 @@ public class SimpleStepFactoryBean implements FactoryBean, BeanNameAware { /** * Public setter for the {@link TaskExecutor}. If this is set, then it will be used to execute the chunk processing * inside the {@link Step}. - * + * * @param taskExecutor the taskExecutor to set */ public void setTaskExecutor(TaskExecutor taskExecutor) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/BatchRetryTemplate.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/BatchRetryTemplate.java index a15092aa1..50b5c2f97 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/BatchRetryTemplate.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/BatchRetryTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -51,9 +51,9 @@ import org.springframework.retry.support.RetryTemplate; * normal), but there may still be entries in the cache for the original failed * items. This might mean that an item that did not cause a failure is never * retried because other items in the same batch fail fatally first. - * + * * @author Dave Syer - * + * */ public class BatchRetryTemplate implements RetryOperations { @@ -68,6 +68,7 @@ public class BatchRetryTemplate implements RetryOperations { } + @SuppressWarnings("serial") private static class BatchRetryContext extends RetryContextSupport { private final Collection contexts; @@ -199,7 +200,7 @@ public class BatchRetryTemplate implements RetryOperations { private RetryPolicy retryPolicy; public T execute(RetryCallback retryCallback, Collection states) throws ExhaustedRetryException, - Exception { + Exception { RetryState batchState = new BatchRetryState(states); return delegate.execute(retryCallback, batchState); } @@ -209,25 +210,25 @@ public class BatchRetryTemplate implements RetryOperations { RetryState batchState = new BatchRetryState(states); return delegate.execute(retryCallback, recoveryCallback, batchState); } - - @Override + + @Override public final T execute(RetryCallback retryCallback, RecoveryCallback recoveryCallback, RetryState retryState) throws Exception, ExhaustedRetryException { return regular.execute(retryCallback, recoveryCallback, retryState); } - @Override + @Override public final T execute(RetryCallback retryCallback, RecoveryCallback recoveryCallback) throws Exception { return regular.execute(retryCallback, recoveryCallback); } - @Override + @Override public final T execute(RetryCallback retryCallback, RetryState retryState) throws Exception, - ExhaustedRetryException { + ExhaustedRetryException { return regular.execute(retryCallback, retryState); } - @Override + @Override public final T execute(RetryCallback retryCallback) throws Exception { return regular.execute(retryCallback); } @@ -273,7 +274,7 @@ public class BatchRetryTemplate implements RetryOperations { delegate.setRetryPolicy(retryPolicy); regular.setRetryPolicy(retryPolicy); } - + public boolean canRetry(RetryContext context) { return context==null ? true : retryPolicy.canRetry(context); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/Chunk.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/Chunk.java index 28d06ebf2..dfce3e0cd 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/Chunk.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/Chunk.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -28,7 +28,7 @@ import java.util.List; * over the chunk using the {@link #iterator()} method, and if there is a * failure call {@link org.springframework.batch.core.step.item.Chunk.ChunkIterator#remove()} on the iterator. * The skipped items are then available through the chunk. - * + * * @author Dave Syer * @since 2.0 */ @@ -105,7 +105,7 @@ public class Chunk implements Iterable { /** * Register an anonymous skip. To skip an individual item, use * {@link ChunkIterator#remove()}. - * + * * @param e the exception that caused the skip */ public void skip(Exception e) { @@ -123,7 +123,7 @@ public class Chunk implements Iterable { * Get an unmodifiable iterator for the underlying items. * @see java.lang.Iterable#iterator() */ - @Override + @Override public ChunkIterator iterator() { return new ChunkIterator(items); } @@ -137,7 +137,7 @@ public class Chunk implements Iterable { /** * Flag to indicate if the source data is exhausted. - * + * * @return true if there is no more data to process */ public boolean isEnd() { @@ -155,7 +155,7 @@ public class Chunk implements Iterable { /** * Query the chunk to see if anyone has registered an interest in keeping a * reference to it. - * + * * @return the busy flag */ public boolean isBusy() { @@ -165,7 +165,7 @@ public class Chunk implements Iterable { /** * Register an interest in the chunk to prevent it from being cleaned up * before the flag is reset to false. - * + * * @param busy the flag to set */ public void setBusy(boolean busy) { @@ -189,7 +189,7 @@ public class Chunk implements Iterable { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override @@ -198,11 +198,11 @@ public class Chunk implements Iterable { } /** - * Special iterator for a chunk providing the {@link #remove(Exception)} + * Special iterator for a chunk providing the {@link #remove(Throwable)} * method for dynamically removing an item and adding it to the skips. - * + * * @author Dave Syer - * + * */ public class ChunkIterator implements Iterator { @@ -214,12 +214,12 @@ public class Chunk implements Iterable { iterator = items.iterator(); } - @Override + @Override public boolean hasNext() { return iterator.hasNext(); } - @Override + @Override public W next() { next = iterator.next(); return next; @@ -230,7 +230,7 @@ public class Chunk implements Iterable { skips.add(new SkipWrapper(next, e)); } - @Override + @Override public void remove() { if (next == null) { if (iterator.hasNext()) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkMonitor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkMonitor.java index deaaa43be..ae99ac162 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkMonitor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkMonitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -28,14 +28,14 @@ import org.springframework.batch.item.support.CompositeItemStream; * an input chunk. Only works with single threaded steps because it has to use a * {@link ThreadLocal} to manage the state and co-ordinate between the caller * and the wrapped {@link ItemStream}. - * + * * @author Dave Syer * @since 2.0 */ public class ChunkMonitor implements ItemStream { - + private Log logger = LogFactory.getLog(getClass()); - + private boolean streamsRegistered = false; public static class ChunkMonitorData { @@ -93,7 +93,7 @@ public class ChunkMonitor implements ItemStream { resetOffset(); } - @Override + @Override public void close() throws ItemStreamException { holder.set(null); if (streamsRegistered) { @@ -101,7 +101,7 @@ public class ChunkMonitor implements ItemStream { } } - @Override + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { if (streamsRegistered) { stream.open(executionContext); @@ -122,7 +122,7 @@ public class ChunkMonitor implements ItemStream { } } - @Override + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { if (streamsRegistered) { ChunkMonitorData data = getData(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java index 6f2b79a3a..1fd2bcf8b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -26,9 +26,9 @@ import org.springframework.batch.repeat.RepeatStatus; /** * A {@link Tasklet} implementing variations on read-process-write item * handling. - * + * * @author Dave Syer - * + * * @param input item type */ public class ChunkOrientedTasklet implements Tasklet { @@ -53,14 +53,14 @@ public class ChunkOrientedTasklet implements Tasklet { * true, which is appropriate for forward-only, non-transactional item * readers. Main (or only) use case for setting this flag to false is a * transactional JMS item reader. - * + * * @param buffering */ public void setBuffering(boolean buffering) { this.buffering = buffering; } - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { @SuppressWarnings("unchecked") diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessor.java index e3a86551f..664db55a9 100755 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -25,8 +25,6 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.classify.BinaryExceptionClassifier; -import org.springframework.classify.Classifier; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.step.skip.LimitCheckingItemSkipPolicy; import org.springframework.batch.core.step.skip.NonSkippableProcessException; @@ -35,6 +33,8 @@ import org.springframework.batch.core.step.skip.SkipListenerFailedException; import org.springframework.batch.core.step.skip.SkipPolicy; import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.ItemWriter; +import org.springframework.classify.BinaryExceptionClassifier; +import org.springframework.classify.Classifier; import org.springframework.retry.ExhaustedRetryException; import org.springframework.retry.RecoveryCallback; import org.springframework.retry.RetryCallback; @@ -45,7 +45,7 @@ import org.springframework.retry.support.DefaultRetryState; /** * FaultTolerant implementation of the {@link ChunkProcessor} interface, that * allows for skipping or retry of items that cause exceptions during writing. - * + * */ public class FaultTolerantChunkProcessor extends SimpleChunkProcessor { @@ -71,7 +71,7 @@ public class FaultTolerantChunkProcessor extends SimpleChunkProcessor extends SimpleChunkProcessor rollbackClassifier) { @@ -114,7 +114,7 @@ public class FaultTolerantChunkProcessor extends SimpleChunkProcessor extends SimpleChunkProcessor extends SimpleChunkProcessor retryCallback = new RetryCallback() { - @Override + @Override public O doWithRetry(RetryContext context) throws Exception { O output = null; try { @@ -264,7 +264,7 @@ public class FaultTolerantChunkProcessor extends SimpleChunkProcessor recoveryCallback = new RecoveryCallback() { - @Override + @Override public O recover(RetryContext context) throws Exception { Throwable e = context.getLastThrowable(); if (shouldSkip(itemProcessSkipPolicy, e, contribution.getStepSkipCount())) { @@ -318,7 +318,7 @@ public class FaultTolerantChunkProcessor extends SimpleChunkProcessor contextHolder = new AtomicReference(); RetryCallback retryCallback = new RetryCallback() { - @Override + @Override public Object doWithRetry(RetryContext context) throws Exception { contextHolder.set(context); @@ -355,7 +355,7 @@ public class FaultTolerantChunkProcessor extends SimpleChunkProcessor batchRecoveryCallback = new RecoveryCallback() { - @Override + @Override public Object recover(RetryContext context) throws Exception { Throwable e = context.getLastThrowable(); @@ -393,7 +393,7 @@ public class FaultTolerantChunkProcessor extends SimpleChunkProcessor recoveryCallback = new RecoveryCallback() { - @Override + @Override public Object recover(RetryContext context) throws Exception { /* @@ -471,7 +471,7 @@ public class FaultTolerantChunkProcessor extends SimpleChunkProcessor extends SimpleChunkProcessor implements ChunkProcessor, InitializingBean { @@ -71,10 +71,10 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi /** * Check mandatory properties. - * + * * @see InitializingBean#afterPropertiesSet() */ - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(itemWriter, "ItemWriter must be set"); Assert.notNull(itemProcessor, "ItemProcessor must be set"); @@ -83,7 +83,7 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi /** * Register some {@link StepListener}s with the handler. Each will get the * callbacks in the order specified at the correct stage. - * + * * @param listeners */ public void setListeners(List listeners) { @@ -94,7 +94,7 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi /** * Register a listener for callbacks at the appropriate stages in a process. - * + * * @param listener a {@link StepListener} */ public void registerListener(StepListener listener) { @@ -136,7 +136,7 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi /** * Surrounds the actual write call with listener callbacks. - * + * * @param items * @throws Exception */ @@ -160,7 +160,7 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi /** * Call the listener's after write method. - * + * * @param items */ protected final void doAfterWrite(List items) { @@ -176,7 +176,7 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi } } - @Override + @Override public final void process(StepContribution contribution, Chunk inputs) throws Exception { // Allow temporary state to be stored in the user data field @@ -208,7 +208,7 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi * {@link #isComplete(Chunk)}, {@link #getFilterCount(Chunk, Chunk)} and * {@link #getAdjustedOutputs(Chunk, Chunk)} might also need to be, to * ensure that the user data is handled consistently. - * + * * @param inputs the inputs for the process */ protected void initializeUserData(Chunk inputs) { @@ -218,12 +218,12 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi /** * Extension point for subclasses to calculate the filter count. Defaults to * the difference between input size and output size. - * + * * @param inputs the inputs after transformation * @param outputs the outputs after transformation - * + * * @return the difference in sizes - * + * * @see #initializeUserData(Chunk) */ protected int getFilterCount(Chunk inputs, Chunk outputs) { @@ -233,10 +233,10 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi /** * Extension point for subclasses that want to store additional data in the * inputs. Default just checks if inputs are empty. - * + * * @param inputs the input chunk * @return true if it is empty - * + * * @see #initializeUserData(Chunk) */ protected boolean isComplete(Chunk inputs) { @@ -247,11 +247,11 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi * Extension point for subclasses that want to adjust the outputs based on * additional saved data in the inputs. Default implementation just returns * the outputs unchanged. - * + * * @param inputs the inputs for the transformation * @param outputs the result of the transformation * @return the outputs unchanged - * + * * @see #initializeUserData(Chunk) */ protected Chunk getAdjustedOutputs(Chunk inputs, Chunk outputs) { @@ -263,7 +263,7 @@ public class SimpleChunkProcessor implements ChunkProcessor, Initializi * increments the write count in the contribution. Subclasses can handle * more complicated scenarios, e.g.with fault tolerance. If output items are * skipped they should be removed from the inputs as well. - * + * * @param contribution the current step contribution * @param inputs the inputs that gave rise to the ouputs * @param outputs the outputs to write diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleChunkProvider.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleChunkProvider.java index e71c10b1a..0a18103d1 100755 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleChunkProvider.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleChunkProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012 the original author or authors. + * Copyright 2006-2013 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. @@ -101,13 +101,13 @@ public class SimpleChunkProvider implements ChunkProvider { } } - @Override + @Override public Chunk provide(final StepContribution contribution) throws Exception { final Chunk inputs = new Chunk(); repeatOperations.iterate(new RepeatCallback() { - @Override + @Override public RepeatStatus doInIteration(final RepeatContext context) throws Exception { I item = null; try { @@ -133,7 +133,7 @@ public class SimpleChunkProvider implements ChunkProvider { } - @Override + @Override public void postProcess(StepContribution contribution, Chunk chunk) { // do nothing } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandler.java index a520d60fb..7aedd7999 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -17,12 +17,12 @@ package org.springframework.batch.core.step.item; import java.util.Collection; -import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.Log; -import org.springframework.classify.BinaryExceptionClassifier; +import org.apache.commons.logging.LogFactory; import org.springframework.batch.repeat.RepeatContext; import org.springframework.batch.repeat.exception.ExceptionHandler; import org.springframework.batch.repeat.support.RepeatSynchronizationManager; +import org.springframework.classify.BinaryExceptionClassifier; import org.springframework.retry.RetryCallback; import org.springframework.retry.RetryContext; import org.springframework.retry.RetryPolicy; @@ -32,9 +32,9 @@ import org.springframework.retry.listener.RetryListenerSupport; * An {@link ExceptionHandler} that is aware of the retry context so that it can * distinguish between a fatal exception and one that can be retried. Delegates * the actual exception handling to another {@link ExceptionHandler}. - * + * * @author Dave Syer - * + * */ public class SimpleRetryExceptionHandler extends RetryListenerSupport implements ExceptionHandler { @@ -42,7 +42,7 @@ public class SimpleRetryExceptionHandler extends RetryListenerSupport implements * Attribute key, whose existence signals an exhausted retry. */ private static final String EXHAUSTED = SimpleRetryExceptionHandler.class.getName() + ".RETRY_EXHAUSTED"; - + private static final Log logger = LogFactory.getLog(SimpleRetryExceptionHandler.class); final private RetryPolicy retryPolicy; @@ -53,7 +53,7 @@ public class SimpleRetryExceptionHandler extends RetryListenerSupport implements /** * Create an exception handler from its mandatory properties. - * + * * @param retryPolicy the retry policy that will be under effect when an * exception is encountered * @param exceptionHandler the delegate to use if an exception actually @@ -70,11 +70,11 @@ public class SimpleRetryExceptionHandler extends RetryListenerSupport implements * Check if the exception is going to be retried, and veto the handling if * it is. If retry is exhausted or the exception is on the fatal list, then * handle using the delegate. - * + * * @see ExceptionHandler#handleException(org.springframework.batch.repeat.RepeatContext, * java.lang.Throwable) */ - @Override + @Override public void handleException(RepeatContext context, Throwable throwable) throws Throwable { // Only bother to check the delegate exception handler if we know that // retry is exhausted @@ -90,11 +90,11 @@ public class SimpleRetryExceptionHandler extends RetryListenerSupport implements /** * If retry is exhausted set up some state in the context that can be used * to signal that the exception should be handled. - * - * @see org.springframework.batch.retry.RetryListener#close(org.springframework.batch.retry.RetryContext, - * org.springframework.batch.retry.RetryCallback, java.lang.Throwable) + * + * @see org.springframework.retry.RetryListener#close(org.springframework.retry.RetryContext, + * org.springframework.retry.RetryCallback, java.lang.Throwable) */ - @Override + @Override public void close(RetryContext context, RetryCallback callback, Throwable throwable) { if (!retryPolicy.canRetry(context)) { logger.debug("Marking retry as exhausted: "+context); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/job/DefaultJobParametersExtractor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/job/DefaultJobParametersExtractor.java index 94502206a..8b778803a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/job/DefaultJobParametersExtractor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/job/DefaultJobParametersExtractor.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 the original author or authors. + * Copyright 2006-2013 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. @@ -32,9 +32,9 @@ import org.springframework.batch.item.ExecutionContext; * Simple implementation of {@link JobParametersExtractor} which pulls * parameters with named keys out of the step execution context and the job * parameters of the surrounding job. - * + * * @author Dave Syer - * + * */ public class DefaultJobParametersExtractor implements JobParametersExtractor { @@ -52,7 +52,7 @@ public class DefaultJobParametersExtractor implements JobParametersExtractor { * values of the respective type and assigned to job parameters accordingly * (there will be an error if they are not of the right type). Without a * special suffix in that form a parameter is assumed to be of type String. - * + * * @param keys the keys to set */ public void setKeys(String[] keys) { @@ -60,9 +60,9 @@ public class DefaultJobParametersExtractor implements JobParametersExtractor { } /** - * @see JobParametersExtractor#getJobParameters(StepExecution) + * @see JobParametersExtractor#getJobParameters(Job, StepExecution) */ - @Override + @Override public JobParameters getJobParameters(Job job, StepExecution stepExecution) { JobParametersBuilder builder = new JobParametersBuilder(); Map jobParameters = stepExecution.getJobParameters().getParameters(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/AlwaysSkipItemSkipPolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/AlwaysSkipItemSkipPolicy.java index d5e6d0ea2..9668dc5c8 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/AlwaysSkipItemSkipPolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/AlwaysSkipItemSkipPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -19,13 +19,13 @@ package org.springframework.batch.core.step.skip; /** * Implementation of the {@link SkipPolicy} interface that * will always return that an item should be skipped. - * + * * @author Ben Hale * @author Lucas Ward */ public class AlwaysSkipItemSkipPolicy implements SkipPolicy { - @Override + @Override public boolean shouldSkip(Throwable t, int skipCount) { return true; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/CompositeSkipPolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/CompositeSkipPolicy.java index 8d6d40767..bb75f1508 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/CompositeSkipPolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/CompositeSkipPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2011 the original author or authors. + * Copyright 2006-2013 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. @@ -22,7 +22,7 @@ package org.springframework.batch.core.step.skip; public class CompositeSkipPolicy implements SkipPolicy { private SkipPolicy[] skipPolicies; - + public CompositeSkipPolicy() { this(new SkipPolicy[0]); } @@ -30,12 +30,12 @@ public class CompositeSkipPolicy implements SkipPolicy { public CompositeSkipPolicy(SkipPolicy[] skipPolicies) { this.skipPolicies = skipPolicies; } - + public void setSkipPolicies(SkipPolicy[] skipPolicies) { this.skipPolicies = skipPolicies; } - @Override + @Override public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException { for (SkipPolicy policy : skipPolicies) { if (policy.shouldSkip(t, skipCount)) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/ExceptionClassifierSkipPolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/ExceptionClassifierSkipPolicy.java index df8169f19..a32be2db5 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/ExceptionClassifierSkipPolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/ExceptionClassifierSkipPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 the original author or authors. + * Copyright 2006-2013 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. @@ -23,9 +23,9 @@ import org.springframework.classify.SubclassClassifier; /** * A {@link SkipPolicy} that depends on an exception classifier to make its * decision, and then delegates to the classifier result. - * + * * @author Dave Syer - * + * * @see SubclassClassifier */ public class ExceptionClassifierSkipPolicy implements SkipPolicy { @@ -34,7 +34,7 @@ public class ExceptionClassifierSkipPolicy implements SkipPolicy { /** * The classifier that will be used to choose a delegate policy. - * + * * @param classifier the classifier to use to choose a delegate policy */ public void setExceptionClassifier(SubclassClassifier classifier) { @@ -46,7 +46,7 @@ public class ExceptionClassifierSkipPolicy implements SkipPolicy { * set it once, e.g. in configuration, and then don't change it during a * running application. Either this property or the exception classifier * directly should be set, but not both. - * + * * @param policyMap a map of String to {@link SkipPolicy} that will be used * to create a {@link Classifier} to locate a policy. */ @@ -59,13 +59,13 @@ public class ExceptionClassifierSkipPolicy implements SkipPolicy { /** * Consult the classifier and find a delegate policy, and then use that to * determine the outcome. - * + * * @param t the throwable to consider * @param skipCount the current skip count * @return true if the exception can be skipped * @throws SkipLimitExceededException if a limit is exceeded */ - @Override + @Override public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException { return classifier.classify(t).shouldSkip(t, skipCount); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/LimitCheckingItemSkipPolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/LimitCheckingItemSkipPolicy.java index b2fd620eb..e2024f34f 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/LimitCheckingItemSkipPolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/LimitCheckingItemSkipPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -19,11 +19,11 @@ import java.io.FileNotFoundException; import java.util.Collections; import java.util.Map; -import org.springframework.classify.BinaryExceptionClassifier; -import org.springframework.classify.Classifier; import org.springframework.batch.core.Step; import org.springframework.batch.core.StepExecution; import org.springframework.batch.item.file.FlatFileParseException; +import org.springframework.classify.BinaryExceptionClassifier; +import org.springframework.classify.Classifier; /** *

    @@ -35,7 +35,7 @@ import org.springframework.batch.item.file.FlatFileParseException; * however, if the vast majority of records are causing exceptions, the file is * likely bad. *

    - * + * *

    * Furthermore, it is also likely that you only want to skip certain exceptions. * {@link FlatFileParseException} is a good example of an exception you will @@ -43,7 +43,7 @@ import org.springframework.batch.item.file.FlatFileParseException; * immediate termination of the {@link Step}. A {@link Classifier} is used to * determine whether a particular exception is skippable or not. *

    - * + * * @author Ben Hale * @author Lucas Ward * @author Robert Kasanicky @@ -87,7 +87,7 @@ public class LimitCheckingItemSkipPolicy implements SkipPolicy { /** * The absolute number of skips (of skippable exceptions) that can be * tolerated before a failure. - * + * * @param skipLimit the skip limit to set */ public void setSkipLimit(int skipLimit) { @@ -97,7 +97,7 @@ public class LimitCheckingItemSkipPolicy implements SkipPolicy { /** * The classifier that will be used to decide on skippability. If an * exception classifies as "true" then it is skippable, and otherwise not. - * + * * @param skippableExceptionClassifier the skippableExceptionClassifier to * set */ @@ -108,7 +108,7 @@ public class LimitCheckingItemSkipPolicy implements SkipPolicy { /** * Set up the classifier through a convenient map from throwable class to * boolean (true if skippable). - * + * * @param skippableExceptions the skippable exceptions to set */ public void setSkippableExceptionMap(Map, Boolean> skippableExceptions) { @@ -123,7 +123,7 @@ public class LimitCheckingItemSkipPolicy implements SkipPolicy { * skipCount is greater than the skipLimit, then a * {@link SkipLimitExceededException} will be thrown. */ - @Override + @Override public boolean shouldSkip(Throwable t, int skipCount) { if (skippableExceptionClassifier.classify(t)) { if (skipCount < skipLimit) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/NeverSkipItemSkipPolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/NeverSkipItemSkipPolicy.java index f11bdace4..bf1ff0399 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/NeverSkipItemSkipPolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/skip/NeverSkipItemSkipPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -19,12 +19,12 @@ package org.springframework.batch.core.step.skip; /** * {@link SkipPolicy} implementation that always returns false, * indicating that an item should not be skipped. - * + * * @author Lucas Ward */ public class NeverSkipItemSkipPolicy implements SkipPolicy{ - @Override + @Override public boolean shouldSkip(Throwable t, int skipCount) { return false; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapter.java index 050847ccb..906af7753 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -26,9 +26,9 @@ import org.springframework.util.Assert; /** * Adapts a {@link Callable}<{@link RepeatStatus}> to the {@link Tasklet} * interface. - * + * * @author Dave Syer - * + * */ public class CallableTaskletAdapter implements Tasklet, InitializingBean { @@ -44,10 +44,10 @@ public class CallableTaskletAdapter implements Tasklet, InitializingBean { /** * Assert that the callable is set. - * + * * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(callable); } @@ -57,7 +57,7 @@ public class CallableTaskletAdapter implements Tasklet, InitializingBean { * the {@link StepContribution} and the attributes. * @see Tasklet#execute(StepContribution, ChunkContext) */ - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return callable.call(); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/ConfigurableSystemProcessExitCodeMapper.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/ConfigurableSystemProcessExitCodeMapper.java index 1c8030cfb..0f4dca290 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/ConfigurableSystemProcessExitCodeMapper.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/ConfigurableSystemProcessExitCodeMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -22,17 +22,17 @@ import org.springframework.batch.core.ExitStatus; import org.springframework.util.Assert; /** - * Maps exit codes to {@link org.springframework.batch.core.ExitStatus} - * according to injected map. The injected map is required to contain a value - * for 'else' key, this value will be returned if the injected map + * Maps exit codes to {@link org.springframework.batch.core.ExitStatus} + * according to injected map. The injected map is required to contain a value + * for 'else' key, this value will be returned if the injected map * does not contain value for the exit code returned by the system process. - * + * * @author Robert Kasanicky */ public class ConfigurableSystemProcessExitCodeMapper implements SystemProcessExitCodeMapper { - + public static final String ELSE_KEY = "else"; - + private Map mappings; @Override @@ -46,7 +46,7 @@ public class ConfigurableSystemProcessExitCodeMapper implements SystemProcessExi } /** - * @param mappings Integer exit code keys to + * @param mappings Integer exit code keys to * {@link org.springframework.batch.core.ExitStatus} values. */ public void setMappings(Map mappings) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/MethodInvokingTaskletAdapter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/MethodInvokingTaskletAdapter.java index bc9abc394..c713f76f6 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/MethodInvokingTaskletAdapter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/MethodInvokingTaskletAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -27,11 +27,11 @@ import org.springframework.batch.repeat.RepeatStatus; * an {@link ExitStatus}. The POJO method is usually going to have no arguments, * but a static argument or array of arguments can be used by setting the * arguments property. - * + * * @see AbstractMethodInvokingDelegator - * + * * @author Dave Syer - * + * */ public class MethodInvokingTaskletAdapter extends AbstractMethodInvokingDelegator implements Tasklet { @@ -39,10 +39,10 @@ public class MethodInvokingTaskletAdapter extends AbstractMethodInvokingDelegato * Delegate execution to the target object and translate the return value to * an {@link ExitStatus} by invoking a method in the delegate POJO. Ignores * the {@link StepContribution} and the attributes. - * + * * @see Tasklet#execute(StepContribution, ChunkContext) */ - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { contribution.setExitStatus(mapResult(invokeDelegateMethod())); return RepeatStatus.FINISHED; @@ -51,7 +51,7 @@ public class MethodInvokingTaskletAdapter extends AbstractMethodInvokingDelegato /** * If the result is an {@link ExitStatus} already just return that, * otherwise return {@link ExitStatus#COMPLETED}. - * + * * @param result the value returned by the delegate method * @return an {@link ExitStatus} consistent with the result */ diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SimpleSystemProcessExitCodeMapper.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SimpleSystemProcessExitCodeMapper.java index 439d388d8..ba27551f9 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SimpleSystemProcessExitCodeMapper.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SimpleSystemProcessExitCodeMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -20,14 +20,14 @@ import org.springframework.batch.core.ExitStatus; /** * Simple {@link SystemProcessExitCodeMapper} implementation that performs following mapping: - * + * * 0 -> ExitStatus.FINISHED * else -> ExitStatus.FAILED - * + * * @author Robert Kasanicky */ public class SimpleSystemProcessExitCodeMapper implements SystemProcessExitCodeMapper { - @Override + @Override public ExitStatus getExitStatus(int exitCode) { if (exitCode == 0) { return ExitStatus.COMPLETED; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java index c2a886798..397ef7578 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -36,23 +36,23 @@ import org.springframework.util.Assert; /** * {@link Tasklet} that executes a system command. - * + * * The system command is executed asynchronously using injected * {@link #setTaskExecutor(TaskExecutor)} - timeout value is required to be set, * so that the batch job does not hang forever if the external process hangs. - * + * * Tasklet periodically checks for termination status (i.e. * {@link #setCommand(String)} finished its execution or * {@link #setTimeout(long)} expired or job was interrupted). The check interval * is given by {@link #setTerminationCheckInterval(long)}. - * + * * When job interrupt is detected tasklet's execution is terminated immediately * by throwing {@link JobInterruptedException}. - * + * * {@link #setInterruptOnCancel(boolean)} specifies whether the tasklet should * attempt to interrupt the thread that executes the system command if it is * still running when tasklet exits (abnormally). - * + * * @author Robert Kasanicky */ public class SystemCommandTasklet extends StepExecutionListenerSupport implements Tasklet, InitializingBean { @@ -81,12 +81,12 @@ public class SystemCommandTasklet extends StepExecutionListenerSupport implement * Execute system command and map its exit code to {@link ExitStatus} using * {@link SystemProcessExitCodeMapper}. */ - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { FutureTask systemCommandTask = new FutureTask(new Callable() { - @Override + @Override public Integer call() throws Exception { Process process = Runtime.getRuntime().exec(command, environmentParams, workingDirectory); return process.waitFor(); @@ -146,7 +146,7 @@ public class SystemCommandTasklet extends StepExecutionListenerSupport implement } - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.hasLength(command, "'command' property value is required"); Assert.notNull(systemProcessExitCodeMapper, "SystemProcessExitCodeMapper must be set"); @@ -175,7 +175,7 @@ public class SystemCommandTasklet extends StepExecutionListenerSupport implement /** * The time interval how often the tasklet will check for termination * status. - * + * * @param checkInterval time interval in milliseconds (1 second by default). */ public void setTerminationCheckInterval(long checkInterval) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java index 69f3cb964..552cded4d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -60,17 +60,18 @@ import org.springframework.util.Assert; * loop is controlled by the step operations ( * {@link #setStepOperations(RepeatOperations)}).
    *
    - * + * * Clients can use interceptors in the step operations to intercept or listen to * the iteration on a step-wide basis, for instance to get a callback when the * step is complete. Those that want callbacks at the level of an individual * tasks, can specify interceptors for the chunk operations. - * + * * @author Dave Syer * @author Lucas Ward * @author Ben Hale * @author Robert Kasanicky */ +@SuppressWarnings("serial") public class TaskletStep extends AbstractStep { private static final Log logger = LogFactory.getLog(TaskletStep.class); @@ -113,7 +114,7 @@ public class TaskletStep extends AbstractStep { /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.step.AbstractStep#afterPropertiesSet() */ @@ -125,7 +126,7 @@ public class TaskletStep extends AbstractStep { /** * Public setter for the {@link PlatformTransactionManager}. - * + * * @param transactionManager the transaction manager to set */ public void setTransactionManager(PlatformTransactionManager transactionManager) { @@ -134,7 +135,7 @@ public class TaskletStep extends AbstractStep { /** * Public setter for the {@link TransactionAttribute}. - * + * * @param transactionAttribute the {@link TransactionAttribute} to set */ public void setTransactionAttribute(TransactionAttribute transactionAttribute) { @@ -143,7 +144,7 @@ public class TaskletStep extends AbstractStep { /** * Public setter for the {@link Tasklet}. - * + * * @param tasklet the {@link Tasklet} to set */ public void setTasklet(Tasklet tasklet) { @@ -156,7 +157,7 @@ public class TaskletStep extends AbstractStep { /** * Register a chunk listener for callbacks at the appropriate stages in a * step execution. - * + * * @param listener a {@link ChunkListener} */ public void registerChunkListener(ChunkListener listener) { @@ -165,7 +166,7 @@ public class TaskletStep extends AbstractStep { /** * Register each of the objects as listeners. - * + * * @param listeners an array of listener objects of known types. */ public void setChunkListeners(ChunkListener[] listeners) { @@ -182,7 +183,7 @@ public class TaskletStep extends AbstractStep { * so if you implement {@link ItemWriter} using delegation to another object * which itself is a {@link ItemStream}, you need to register the delegate * here. - * + * * @param streams an array of {@link ItemStream} objects. */ public void setStreams(ItemStream[] streams) { @@ -194,7 +195,7 @@ public class TaskletStep extends AbstractStep { /** * Register a single {@link ItemStream} for callbacks to the stream * interface. - * + * * @param stream */ public void registerStream(ItemStream stream) { @@ -205,7 +206,7 @@ public class TaskletStep extends AbstractStep { * The {@link RepeatOperations} to use for the outer loop of the batch * processing. Should be set up by the caller through a factory. Defaults to * a plain {@link RepeatTemplate}. - * + * * @param stepOperations a {@link RepeatOperations} instance. */ public void setStepOperations(RepeatOperations stepOperations) { @@ -216,7 +217,7 @@ public class TaskletStep extends AbstractStep { * Setter for the {@link StepInterruptionPolicy}. The policy is used to * check whether an external request has been made to interrupt the job * execution. - * + * * @param interruptionPolicy a {@link StepInterruptionPolicy} */ public void setInterruptionPolicy(StepInterruptionPolicy interruptionPolicy) { @@ -231,13 +232,14 @@ public class TaskletStep extends AbstractStep { * used to store the result. Various reporting information are also added to * the current context governing the step execution, which would normally be * available to the caller through the step's {@link ExecutionContext}.
    - * + * * @throws JobInterruptedException if the step or a chunk is interrupted * @throws RuntimeException if there is an exception during a chunk * execution - * + * */ @Override + @SuppressWarnings("unchecked") protected void doExecute(StepExecution stepExecution) throws Exception { stream.update(stepExecution.getExecutionContext()); @@ -262,7 +264,7 @@ public class TaskletStep extends AbstractStep { RepeatStatus result; try { result = (RepeatStatus) new TransactionTemplate(transactionManager, transactionAttribute) - .execute(new ChunkTransactionCallback(chunkContext, semaphore)); + .execute(new ChunkTransactionCallback(chunkContext, semaphore)); } catch (UncheckedTransactionException e) { // Allow checked exceptions to be thrown inside callback @@ -286,19 +288,19 @@ public class TaskletStep extends AbstractStep { /** * Extension point mainly for test purposes so that the behaviour of the * lock can be manipulated to simulate various pathologies. - * + * * @return a semaphore for locking access to the JobRepository */ protected Semaphore createSemaphore() { return new Semaphore(1); } - @Override + @Override protected void close(ExecutionContext ctx) throws Exception { stream.close(); } - @Override + @Override protected void open(ExecutionContext ctx) throws Exception { stream.open(ctx); } @@ -308,10 +310,11 @@ public class TaskletStep extends AbstractStep { * failures in the transaction commit and rollback, only panicking if the * transaction status is unknown (i.e. if a commit failure leads to a clean * rollback then we assume the state is consistent). - * + * * @author Dave Syer - * + * */ + @SuppressWarnings("rawtypes") private class ChunkTransactionCallback extends TransactionSynchronizationAdapter implements TransactionCallback { private final StepExecution stepExecution; @@ -366,7 +369,7 @@ public class TaskletStep extends AbstractStep { } } - @Override + @Override public Object doInTransaction(TransactionStatus status) { TransactionSynchronizationManager.registerSynchronization(this); @@ -486,9 +489,9 @@ public class TaskletStep extends AbstractStep { /** * Convenience wrapper for a checked exception so that it can cause a * rollback and be extracted afterwards. - * + * * @author Dave Syer - * + * */ private static class UncheckedTransactionException extends RuntimeException { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionExceptionTests.java index 8886c01cc..7596c3b6f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobExecutionExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -25,7 +25,7 @@ public class JobExecutionExceptionTests extends AbstractExceptionTests { /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ - @Override + @Override public Exception getException(String msg) throws Exception { return new JobExecutionException(msg); } @@ -33,7 +33,7 @@ public class JobExecutionExceptionTests extends AbstractExceptionTests { /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ - @Override + @Override public Exception getException(String msg, Throwable t) throws Exception { return new JobExecutionException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/JobInterruptedExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/JobInterruptedExceptionTests.java index 2536575e8..12b540731 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/JobInterruptedExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/JobInterruptedExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -25,7 +25,7 @@ public class JobInterruptedExceptionTests extends AbstractExceptionTests { /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ - @Override + @Override public Exception getException(String msg) throws Exception { return new JobInterruptedException(msg); } @@ -33,7 +33,7 @@ public class JobInterruptedExceptionTests extends AbstractExceptionTests { /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ - @Override + @Override public Exception getException(String msg, Throwable t) throws Exception { return new RuntimeException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/DuplicateJobExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/DuplicateJobExceptionTests.java index c81703619..52a7a80a7 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/DuplicateJobExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/DuplicateJobExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -16,11 +16,10 @@ package org.springframework.batch.core.configuration; import org.springframework.batch.core.AbstractExceptionTests; -import org.springframework.batch.core.configuration.DuplicateJobException; /** * @author Dave Syer - * + * */ public class DuplicateJobExceptionTests extends AbstractExceptionTests { @@ -28,7 +27,7 @@ public class DuplicateJobExceptionTests extends AbstractExceptionTests { * (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ - @Override + @Override public Exception getException(String msg) throws Exception { return new DuplicateJobException(msg); } @@ -38,7 +37,7 @@ public class DuplicateJobExceptionTests extends AbstractExceptionTests { * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, * java.lang.Throwable) */ - @Override + @Override public Exception getException(String msg, Throwable t) throws Exception { return new DuplicateJobException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactoryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactoryTests.java index 72fbaeb51..2b7b8960c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactoryTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/ApplicationContextJobFactoryTests.java @@ -27,7 +27,7 @@ public class ApplicationContextJobFactoryTests { } private static class StubApplicationContextFactory implements ApplicationContextFactory { - @Override + @Override public ConfigurableApplicationContext createApplicationContext() { StaticApplicationContext context = new StaticApplicationContext(); context.registerSingleton("job", JobSupport.class); @@ -37,7 +37,7 @@ public class ApplicationContextJobFactoryTests { } private static class PostProcessingApplicationContextFactory implements ApplicationContextFactory { - @Override + @Override public ConfigurableApplicationContext createApplicationContext() { StaticApplicationContext context = new StaticApplicationContext(); context.registerSingleton("job", JobSupport.class); @@ -50,7 +50,7 @@ public class ApplicationContextJobFactoryTests { private static class TestBeanPostProcessor implements BeanPostProcessor { - @Override + @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof JobSupport) { ((JobSupport) bean).setName("bar"); @@ -58,7 +58,7 @@ public class ApplicationContextJobFactoryTests { return bean; } - @Override + @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { return bean; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/JobFactoryRegistrationListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/JobFactoryRegistrationListenerTests.java index 340e7fed4..1f6590486 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/JobFactoryRegistrationListenerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/JobFactoryRegistrationListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -15,7 +15,7 @@ */ package org.springframework.batch.core.configuration.support; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import org.junit.Test; import org.springframework.batch.core.Job; @@ -23,7 +23,7 @@ import org.springframework.batch.core.configuration.JobFactory; /** * @author Dave Syer - * + * */ public class JobFactoryRegistrationListenerTests { @@ -40,12 +40,12 @@ public class JobFactoryRegistrationListenerTests { public void testBind() throws Exception { listener.setJobRegistry(registry); listener.bind(new JobFactory() { - @Override + @Override public Job createJob() { return null; } - @Override + @Override public String getJobName() { return "foo"; } @@ -56,18 +56,18 @@ public class JobFactoryRegistrationListenerTests { /** * Test method for * {@link org.springframework.batch.core.configuration.support.JobFactoryRegistrationListener#unbind(org.springframework.batch.core.configuration.JobFactory, java.util.Map)}. - * @throws Exception + * @throws Exception */ @Test public void testUnbind() throws Exception { testBind(); listener.unbind(new JobFactory() { - @Override + @Override public Job createJob() { return null; } - @Override + @Override public String getJobName() { return "foo"; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DecisionJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DecisionJobParserTests.java index d9530d2ee..329b901e8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DecisionJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DecisionJobParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -35,7 +35,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Dave Syer - * + * */ @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) @@ -58,7 +58,7 @@ public class DecisionJobParserTests { } public static class TestDecider implements JobExecutionDecider { - @Override + @Override public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { return new FlowExecutionStatus("FOO"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyCompletionPolicy.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyCompletionPolicy.java index 386aded90..e27f05073 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyCompletionPolicy.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyCompletionPolicy.java @@ -10,22 +10,22 @@ import org.springframework.batch.repeat.RepeatStatus; */ public class DummyCompletionPolicy implements CompletionPolicy { - @Override + @Override public boolean isComplete(RepeatContext context, RepeatStatus result) { return false; } - @Override + @Override public boolean isComplete(RepeatContext context) { return false; } - @Override + @Override public RepeatContext start(RepeatContext parent) { return null; } - @Override + @Override public void update(RepeatContext context) { } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemProcessor.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemProcessor.java index 0fd6fa618..c8fd3e1a8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemProcessor.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemProcessor.java @@ -8,7 +8,7 @@ import org.springframework.batch.item.ItemProcessor; */ public class DummyItemProcessor implements ItemProcessor { - @Override + @Override public Object process(Object item) throws Exception { return item; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemReader.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemReader.java index 90fe87d6d..8b6b580ef 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemReader.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemReader.java @@ -10,7 +10,7 @@ import org.springframework.batch.item.UnexpectedInputException; */ public class DummyItemReader implements ItemReader { - @Override + @Override public Object read() throws Exception, UnexpectedInputException, ParseException { return null; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemWriter.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemWriter.java index 5f003480f..7374d52ff 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemWriter.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemWriter.java @@ -10,7 +10,7 @@ import org.springframework.batch.item.ItemWriter; */ public class DummyItemWriter implements ItemWriter { - @Override + @Override public void write(List items) throws Exception { } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyJobRepository.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyJobRepository.java index e17937e1f..894a89b18 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyJobRepository.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyJobRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -37,54 +37,54 @@ public class DummyJobRepository implements JobRepository, BeanNameAware { return name; } - @Override + @Override public void setBeanName(String name) { this.name = name; } - @Override + @Override public void add(StepExecution stepExecution) { } - @Override + @Override public JobExecution createJobExecution(String jobName, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException { return null; } - @Override + @Override public JobExecution getLastJobExecution(String jobName, JobParameters jobParameters) { return null; } - @Override + @Override public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) { return null; } - @Override + @Override public int getStepExecutionCount(JobInstance jobInstance, String stepName) { return 0; } - @Override + @Override public boolean isJobInstanceExists(String jobName, JobParameters jobParameters) { return false; } - @Override + @Override public void update(JobExecution jobExecution) { } - @Override + @Override public void update(StepExecution stepExecution) { } - @Override + @Override public void updateExecutionContext(StepExecution stepExecution) { } - @Override + @Override public void updateExecutionContext(JobExecution jobExecution) { } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyPlatformTransactionManager.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyPlatformTransactionManager.java index db0d89873..aeec5b5c2 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyPlatformTransactionManager.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyPlatformTransactionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -33,20 +33,20 @@ public class DummyPlatformTransactionManager implements PlatformTransactionManag return name; } - @Override + @Override public void setBeanName(String name) { this.name = name; } - @Override + @Override public void commit(TransactionStatus status) throws TransactionException { } - @Override + @Override public void rollback(TransactionStatus status) throws TransactionException { } - @Override + @Override public TransactionStatus getTransaction(TransactionDefinition definition) throws TransactionException { return null; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyRetryListener.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyRetryListener.java index a575e10ff..e4220e547 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyRetryListener.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyRetryListener.java @@ -10,16 +10,16 @@ import org.springframework.retry.RetryListener; */ public class DummyRetryListener implements RetryListener { - @Override + @Override public boolean open(RetryContext context, RetryCallback callback) { return false; } - @Override + @Override public void close(RetryContext context, RetryCallback callback, Throwable throwable) { } - @Override + @Override public void onError(RetryContext context, RetryCallback callback, Throwable throwable) { } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyStep.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyStep.java index b4b254903..95333c05c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyStep.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyStep.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -28,27 +28,27 @@ public class DummyStep implements Step, BeanNameAware { private String name; - @Override + @Override public String getName() { return name; } - @Override + @Override public void setBeanName(String name) { this.name = name; } - @Override + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException { System.out.println("EXECUTING " + getName()); } - @Override + @Override public int getStartLimit() { return 100; } - @Override + @Override public boolean isAllowStartIfComplete() { return false; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyTasklet.java index 9d60c6704..232888dca 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyTasklet.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyTasklet.java @@ -11,7 +11,7 @@ import org.springframework.batch.repeat.RepeatStatus; */ public class DummyTasklet implements Tasklet { - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return null; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FailingTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FailingTasklet.java index 0044d31ee..dd3fbad06 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FailingTasklet.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FailingTasklet.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -23,13 +23,13 @@ import org.springframework.batch.repeat.RepeatStatus; * This tasklet will call * {@link NameStoringTasklet#execute(StepContribution, ChunkContext)} and then * throw an exeception. - * + * * @author Dan Garrette * @since 2.0 */ public class FailingTasklet extends NameStoringTasklet { - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { super.execute(contribution, chunkContext); throw new RuntimeException(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FlowStepParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FlowStepParserTests.java index c9d0efe26..d0f598895 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FlowStepParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FlowStepParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -40,7 +40,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Dave Syer - * + * */ @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) @@ -137,7 +137,7 @@ public class FlowStepParserTests { int count = 0; - @Override + @Override public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { if (count++ < 2) { return new FlowExecutionStatus("OK"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/InterruptibleTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/InterruptibleTasklet.java index c625680fe..444d7f865 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/InterruptibleTasklet.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/InterruptibleTasklet.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -23,15 +23,15 @@ import org.springframework.batch.repeat.RepeatStatus; * This tasklet will call * {@link NameStoringTasklet#execute(StepContribution, ChunkContext)} and then * return CONTINUABLE, so it needs to be interrupted for it to stop. - * + * * @author Dave Syer * @since 2.0 */ public class InterruptibleTasklet extends NameStoringTasklet { - + private volatile boolean started = false; - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { if (!started) { super.execute(contribution, chunkContext); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobRegistryJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobRegistryJobParserTests.java index 761a77388..5be6ae14e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobRegistryJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/JobRegistryJobParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -36,17 +36,17 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) public class JobRegistryJobParserTests implements ApplicationContextAware { - + @Autowired private ListableJobLocator jobRegistry; private ApplicationContext applicationContext; - - @Override + + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } - + @Test public void testOneStep() throws Exception { assertEquals(2, applicationContext.getBeanNamesForType(Job.class).length); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NameStoringTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NameStoringTasklet.java index 2104f12c0..63861a7a3 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NameStoringTasklet.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NameStoringTasklet.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -26,7 +26,7 @@ import org.springframework.batch.repeat.RepeatStatus; /** * This class will store the step name when it is executed. - * + * * @author Dan Garrette * @since 2.0 */ @@ -35,12 +35,12 @@ public class NameStoringTasklet extends StepExecutionListenerSupport implements private String stepName = null; private List stepNamesList = null; - @Override + @Override public void beforeStep(StepExecution stepExecution) { stepName = stepExecution.getStepName(); } - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { if (stepNamesList != null) { stepNamesList.add(stepName); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepParserTests.java index 8784accfb..04a5da4ef 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -28,7 +28,11 @@ import java.util.List; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.batch.core.*; +import org.springframework.batch.core.BatchStatus; +import org.springframework.batch.core.Job; +import org.springframework.batch.core.JobExecution; +import org.springframework.batch.core.JobParameters; +import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.partition.PartitionHandler; import org.springframework.batch.core.partition.StepExecutionSplitter; import org.springframework.batch.core.partition.support.PartitionStep; @@ -88,7 +92,7 @@ public class PartitionStepParserTests implements ApplicationContextAware { private List savedStepNames = new ArrayList(); - @Override + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } @@ -152,7 +156,7 @@ public class PartitionStepParserTests implements ApplicationContextAware { for (StepExecution se : jobExecution.getStepExecutions()) { String stepExecutionName = se.getStepName(); // the partitioned step - if (stepExecutionName.equalsIgnoreCase("j3s1")) { + if (stepExecutionName.equalsIgnoreCase("j3s1")) { PartitionStep partitionStep = (PartitionStep) this.applicationContext.getBean(stepExecutionName); // prove that the reference in the {@link // TaskExecutorPartitionHandler} is the step configured inline @@ -187,7 +191,7 @@ public class PartitionStepParserTests implements ApplicationContextAware { for (StepExecution se : jobExecution.getStepExecutions()) { String stepExecutionName = se.getStepName(); if (stepExecutionName.equalsIgnoreCase("j4s1")) { // the partitioned - // step + // step PartitionStep partitionStep = (PartitionStep) this.applicationContext.getBean(stepExecutionName); // prove that the reference in the {@link @@ -227,23 +231,23 @@ public class PartitionStepParserTests implements ApplicationContextAware { Collections.sort(list); return list; } - + public static class CustomPartitionHandler implements PartitionHandler { - @Override + @Override public Collection handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { return Arrays.asList(stepExecution); } - + } public static class CustomStepExecutionAggregator implements StepExecutionAggregator { - @Override + @Override public void aggregate(StepExecution result, Collection executions) { result.getJobExecution().getExecutionContext().put("foo", "bar"); } - + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepWithFlowParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepWithFlowParserTests.java index 006ce04ff..4252c3e14 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepWithFlowParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepWithFlowParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -73,7 +73,7 @@ public class PartitionStepWithFlowParserTests { public void testRepeatedFlowStep() throws Exception { assertNotNull(job1); JobExecution jobExecution = jobRepository.createJobExecution(job1.getName(), new JobParametersBuilder() - .addLong("gridSize", 1L).toJobParameters()); + .addLong("gridSize", 1L).toJobParameters()); job1.execute(jobExecution); assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); Collections.sort(savedStepNames); @@ -95,10 +95,10 @@ public class PartitionStepWithFlowParserTests { public static class Decider implements JobExecutionDecider { int count = 0; - @Override + @Override public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { if (count++<2) { - return new FlowExecutionStatus("OK"); + return new FlowExecutionStatus("OK"); } return new FlowExecutionStatus("END"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SplitInterruptedJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SplitInterruptedJobParserTests.java index f54a52e0d..c185e8ee4 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SplitInterruptedJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/SplitInterruptedJobParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -40,12 +40,12 @@ public class SplitInterruptedJobParserTests extends AbstractJobParserTests { final JobExecution jobExecution = createJobExecution(); new Thread(new Runnable() { - @Override + @Override public void run() { job.execute(jobExecution); } }).start(); - + Thread.sleep(100L); jobExecution.setStatus(BatchStatus.STOPPING); Thread.sleep(200L); @@ -54,7 +54,7 @@ public class SplitInterruptedJobParserTests extends AbstractJobParserTests { Thread.sleep(200L); } assertTrue("Timed out waiting for job to stop: "+jobExecution, count<10); - + assertEquals(BatchStatus.STOPPED, jobExecution.getStatus()); assertEquals(ExitStatus.STOPPED.getExitCode(), jobExecution.getExitStatus().getExitCode()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StopJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StopJobParserTests.java index a8eacb552..95cc8f239 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StopJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StopJobParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -31,7 +31,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Dave Syer - * + * */ @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) @@ -74,7 +74,7 @@ public class StopJobParserTests extends AbstractJobParserTests { } public static class TestDecider implements JobExecutionDecider { - @Override + @Override public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { return new FlowExecutionStatus("FOO"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestCustomStatusListener.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestCustomStatusListener.java index 9766d6798..424814218 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestCustomStatusListener.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestCustomStatusListener.java @@ -6,14 +6,14 @@ import org.springframework.batch.core.StepExecutionListener; public class TestCustomStatusListener extends AbstractTestComponent implements StepExecutionListener { - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { return new ExitStatus("FOO").and(stepExecution.getExitStatus()); } - @Override + @Override public void beforeStep(StepExecution stepExecution) { executed = true; } - + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestIncrementer.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestIncrementer.java index 80518aa85..1fea100df 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestIncrementer.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestIncrementer.java @@ -5,7 +5,7 @@ import org.springframework.batch.core.JobParametersIncrementer; public class TestIncrementer implements JobParametersIncrementer{ - @Override + @Override public JobParameters getNext(JobParameters parameters) { return null; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestListener.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestListener.java index 360d6e24b..ba24f7e67 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestListener.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestListener.java @@ -7,7 +7,7 @@ import org.springframework.batch.core.annotation.AfterRead; public class TestListener extends AbstractTestComponent implements StepExecutionListener { - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; } @@ -17,14 +17,14 @@ public class TestListener extends AbstractTestComponent implements StepExecution return stepExecution.getExitStatus(); } - @Override + @Override public void beforeStep(StepExecution stepExecution) { executed = true; } - + @AfterRead public void logItem(){ - + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestProcessor.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestProcessor.java index f7af92543..731ec465d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestProcessor.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestProcessor.java @@ -4,7 +4,7 @@ import org.springframework.batch.item.ItemProcessor; public class TestProcessor extends AbstractTestComponent implements ItemProcessor{ - @Override + @Override public String process(String item) throws Exception { executed = true; return item; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestReader.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestReader.java index fb76f97da..15b9d8ae6 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestReader.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestReader.java @@ -32,7 +32,7 @@ public class TestReader extends AbstractTestComponent implements ItemReader void close(RetryContext context, RetryCallback callback, Throwable throwable) { } - @Override + @Override public void onError(RetryContext context, RetryCallback callback, Throwable throwable) { } - @Override + @Override public boolean open(RetryContext context, RetryCallback callback) { executed = true; return true; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestTasklet.java index d2a65345f..3e526e515 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestTasklet.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestTasklet.java @@ -8,18 +8,18 @@ import org.springframework.batch.repeat.RepeatStatus; public class TestTasklet extends AbstractTestComponent implements Tasklet { private String name; - - @Override + + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { executed = true; - return RepeatStatus.FINISHED; - } + return RepeatStatus.FINISHED; + } public String getName() { return name; } - + public void setName(String name) { this.name = name; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestWriter.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestWriter.java index efa0b799c..b4e1ae90d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestWriter.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestWriter.java @@ -6,7 +6,7 @@ import org.springframework.batch.item.ItemWriter; public class TestWriter extends AbstractTestComponent implements ItemWriter { - @Override + @Override public void write(List items) throws Exception { executed = true; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerIntegrationTests.java index 6ddb2fd17..1f0987506 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -24,7 +24,6 @@ import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParametersBuilder; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.explore.JobExplorer; -import org.springframework.batch.core.explore.support.MapJobExplorerFactoryBean; import org.springframework.batch.core.job.SimpleJob; import org.springframework.batch.core.launch.support.SimpleJobLauncher; import org.springframework.batch.core.repository.JobRepository; @@ -37,7 +36,7 @@ import org.springframework.core.task.SimpleAsyncTaskExecutor; /** * @author Dave Syer - * + * */ public class MapJobExplorerIntegrationTests { @@ -57,7 +56,7 @@ public class MapJobExplorerIntegrationTests { SimpleJob job = new SimpleJob("job"); TaskletStep step = new TaskletStep("step"); step.setTasklet(new Tasklet() { - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { while (block) { Thread.sleep(100L); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java index 160b7c6c9..f046a2cdb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -41,13 +41,13 @@ import org.springframework.batch.core.step.StepSupport; /** * @author Dave Syer - * + * */ public class ExtendedAbstractJobTests { private AbstractJob job; private JobRepository jobRepository; - + @Before public void setUp() throws Exception { MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); @@ -118,7 +118,7 @@ public class ExtendedAbstractJobTests { assertTrue(e.getMessage().contains("JobRepository")); } } - + @Test public void testValidatorWithNotNullParameters() throws Exception { JobExecution execution = jobRepository.createJobExecution("job", new JobParameters()); @@ -147,7 +147,7 @@ public class ExtendedAbstractJobTests { */ @Test public void testHandleStep() throws Exception { - + class StubStep extends StepSupport { static final String value = "message for next steps"; @@ -158,12 +158,12 @@ public class ExtendedAbstractJobTests { setName("StubStep"); } - @Override + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException { stepExecution.getJobExecution().getExecutionContext().put(key, value); } } - + MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); factory.afterPropertiesSet(); JobRepository repository = (JobRepository) factory.getObject(); @@ -186,12 +186,12 @@ public class ExtendedAbstractJobTests { /** * @author Dave Syer - * + * */ private static class StubJob extends AbstractJob { /** * @param name - * @param jobRepository + * @param jobRepository */ private StubJob(String name, JobRepository jobRepository) { super(name); @@ -218,7 +218,7 @@ public class ExtendedAbstractJobTests { public Step getStep(String stepName) { return null; } - + @Override public Collection getStepNames() { return Collections. emptySet(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/JobSupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/JobSupport.java index f54364671..f7143557f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/JobSupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/JobSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -37,7 +37,7 @@ import org.springframework.util.ClassUtils; * representing the configuration of a job specified by a developer. It should * be noted that restart policy is applied to the job as a whole and not to a * step. - * + * * @author Lucas Ward * @author Dave Syer */ @@ -63,7 +63,7 @@ public class JobSupport implements BeanNameAware, Job, StepLocator { /** * Convenience constructor to immediately add name (which is mandatory but * not final). - * + * * @param name */ public JobSupport(String name) { @@ -77,10 +77,10 @@ public class JobSupport implements BeanNameAware, Job, StepLocator { * if it is present. Care is needed with bean definition inheritance - if a * parent bean has a name, then its children need an explicit name as well, * otherwise they will not be unique. - * + * * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String) */ - @Override + @Override public void setBeanName(String name) { if (this.name == null) { this.name = name; @@ -90,7 +90,7 @@ public class JobSupport implements BeanNameAware, Job, StepLocator { /** * Set the name property. Always overrides the default value if this object * is a Spring bean. - * + * * @see #setBeanName(java.lang.String) */ public void setName(String name) { @@ -99,14 +99,14 @@ public class JobSupport implements BeanNameAware, Job, StepLocator { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.IJob#getName() */ - @Override + @Override public String getName() { return name; } - + /** * @param jobParametersValidator the jobParametersValidator to set */ @@ -116,9 +116,9 @@ public class JobSupport implements BeanNameAware, Job, StepLocator { public void setSteps(List steps) { this.steps.clear(); - for (Step step : steps) { - this.steps.put(step.getName(), step); - } + for (Step step : steps) { + this.steps.put(step.getName(), step); + } } public void addStep(Step step) { @@ -127,7 +127,7 @@ public class JobSupport implements BeanNameAware, Job, StepLocator { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.IJob#getStartLimit() */ public int getStartLimit() { @@ -144,58 +144,58 @@ public class JobSupport implements BeanNameAware, Job, StepLocator { /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.domain.IJob#isRestartable() */ - @Override + @Override public boolean isRestartable() { return restartable; } - + /* * (non-Javadoc) - * + * * @see * org.springframework.batch.core.domain.Job#run(org.springframework.batch * .core.domain.JobExecution) */ - @Override + @Override public void execute(JobExecution execution) throws UnexpectedJobExecutionException { throw new UnsupportedOperationException( "JobSupport does not provide an implementation of execute(). Use a smarter subclass."); } - @Override + @Override public String toString() { return ClassUtils.getShortName(getClass()) + ": [name=" + name + "]"; } /* * (non-Javadoc) - * + * * @see org.springframework.batch.core.Job#getJobParametersIncrementer() */ - @Override + @Override public JobParametersIncrementer getJobParametersIncrementer() { return null; } - - @Override + + @Override public JobParametersValidator getJobParametersValidator() { return jobParametersValidator; } - @Override - public Collection getStepNames() { - return steps.keySet(); - } + @Override + public Collection getStepNames() { + return steps.keySet(); + } - @Override - public Step getStep(String stepName) throws NoSuchStepException { - final Step step = steps.get(stepName); - if (step == null) { - throw new NoSuchStepException("Step ["+stepName+"] does not exist for job with name ["+getName()+"]"); - } - return step; - } + @Override + public Step getStep(String stepName) throws NoSuchStepException { + final Step step = steps.get(stepName); + if (step == null) { + throw new NoSuchStepException("Step ["+stepName+"] does not exist for job with name ["+getName()+"]"); + } + return step; + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java index 573cd746e..7dc93f4e6 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -64,7 +64,7 @@ import org.springframework.batch.item.ExecutionContext; /** * Tests for DefaultJobLifecycle. MapJobDao and MapStepExecutionDao are used * instead of a mock repository to test that status is being stored correctly. - * + * * @author Lucas Ward */ public class SimpleJobTests { @@ -110,14 +110,14 @@ public class SimpleJobTests { step1 = new StubStep("TestStep1", jobRepository); step1.setCallback(new Runnable() { - @Override + @Override public void run() { list.add("default"); } }); step2 = new StubStep("TestStep2", jobRepository); step2.setCallback(new Runnable() { - @Override + @Override public void run() { list.add("default"); } @@ -175,22 +175,22 @@ public class SimpleJobTests { Step testStep = new Step() { - @Override + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException { stepExecution.setExitStatus(customStatus); } - @Override + @Override public String getName() { return "test"; } - @Override + @Override public int getStartLimit() { return 1; } - @Override + @Override public boolean isAllowStartIfComplete() { return false; } @@ -219,12 +219,12 @@ public class SimpleJobTests { @Test public void testRunNormallyWithListener() throws Exception { job.setJobExecutionListeners(new JobExecutionListenerSupport[] { new JobExecutionListenerSupport() { - @Override + @Override public void beforeJob(JobExecution jobExecution) { list.add("before"); } - @Override + @Override public void afterJob(JobExecution jobExecution) { list.add("after"); } @@ -299,7 +299,7 @@ public class SimpleJobTests { @Test public void testFailedWithListener() throws Exception { job.setJobExecutionListeners(new JobExecutionListenerSupport[] { new JobExecutionListenerSupport() { - @Override + @Override public void afterJob(JobExecution jobExecution) { list.add("afterJob"); } @@ -487,9 +487,9 @@ public class SimpleJobTests { step1 = new StubStep("interruptStep", jobRepository) { - @Override + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException, - UnexpectedJobExecutionException { + UnexpectedJobExecutionException { stepExecution.getJobExecution().stop(); super.execute(stepExecution); } @@ -580,13 +580,13 @@ public class SimpleJobTests { /* * (non-Javadoc) - * + * * @seeorg.springframework.batch.core.step.StepSupport#execute(org. * springframework.batch.core.StepExecution) */ - @Override + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException, - UnexpectedJobExecutionException { + UnexpectedJobExecutionException { passedInJobContext = new ExecutionContext(stepExecution.getJobExecution().getExecutionContext()); passedInStepContext = new ExecutionContext(stepExecution.getExecutionContext()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleStepHandlerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleStepHandlerTests.java index c09a52d66..2764c69a9 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleStepHandlerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleStepHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -32,7 +32,7 @@ import org.springframework.batch.core.step.StepSupport; /** * @author Dave Syer - * + * */ public class SimpleStepHandlerTests { @@ -77,7 +77,7 @@ public class SimpleStepHandlerTests { super(name); } - @Override + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException { stepExecution.setStatus(BatchStatus.COMPLETED); stepExecution.setExitStatus(ExitStatus.COMPLETED); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/builder/FlowJobBuilderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/builder/FlowJobBuilderTests.java index 0da463ff3..daead9e30 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/builder/FlowJobBuilderTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/builder/FlowJobBuilderTests.java @@ -48,7 +48,7 @@ public class FlowJobBuilderTests { private StepSupport step1 = new StepSupport("step1") { @Override public void execute(StepExecution stepExecution) throws JobInterruptedException, - UnexpectedJobExecutionException { + UnexpectedJobExecutionException { stepExecution.upgradeStatus(BatchStatus.COMPLETED); stepExecution.setExitStatus(ExitStatus.COMPLETED); jobRepository.update(stepExecution); @@ -58,7 +58,7 @@ public class FlowJobBuilderTests { private StepSupport fails = new StepSupport("fails") { @Override public void execute(StepExecution stepExecution) throws JobInterruptedException, - UnexpectedJobExecutionException { + UnexpectedJobExecutionException { stepExecution.upgradeStatus(BatchStatus.FAILED); stepExecution.setExitStatus(ExitStatus.FAILED); jobRepository.update(stepExecution); @@ -68,7 +68,7 @@ public class FlowJobBuilderTests { private StepSupport step2 = new StepSupport("step2") { @Override public void execute(StepExecution stepExecution) throws JobInterruptedException, - UnexpectedJobExecutionException { + UnexpectedJobExecutionException { stepExecution.upgradeStatus(BatchStatus.COMPLETED); stepExecution.setExitStatus(ExitStatus.COMPLETED); jobRepository.update(stepExecution); @@ -78,7 +78,7 @@ public class FlowJobBuilderTests { private StepSupport step3 = new StepSupport("step3") { @Override public void execute(StepExecution stepExecution) throws JobInterruptedException, - UnexpectedJobExecutionException { + UnexpectedJobExecutionException { stepExecution.upgradeStatus(BatchStatus.COMPLETED); stepExecution.setExitStatus(ExitStatus.COMPLETED); jobRepository.update(stepExecution); @@ -143,7 +143,7 @@ public class FlowJobBuilderTests { public void testBuildDecision() throws Exception { JobExecutionDecider decider = new JobExecutionDecider() { private int count = 0; - @Override + @Override public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { count++; return count<2 ? new FlowExecutionStatus("ONGOING") : FlowExecutionStatus.COMPLETED; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java index fdbb3e7d8..e9a09856a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -49,7 +49,7 @@ import org.springframework.batch.core.step.StepSupport; /** * @author Dave Syer - * + * */ public class FlowJobTests { @@ -361,7 +361,7 @@ public class FlowJobTests { List transitions = new ArrayList(); transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "end")); transitions - .add(StateTransition.createStateTransition(new EndState(FlowExecutionStatus.FAILED, "end"), "step2")); + .add(StateTransition.createStateTransition(new EndState(FlowExecutionStatus.FAILED, "end"), "step2")); transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step2")), ExitStatus.FAILED .getExitCode(), "end0")); transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step2")), @@ -450,7 +450,7 @@ public class FlowJobTests { SimpleFlow flow = new SimpleFlow("job"); JobExecutionDecider decider = new JobExecutionDecider() { - @Override + @Override public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { assertNotNull(stepExecution); return new FlowExecutionStatus("SWITCH"); @@ -491,7 +491,7 @@ public class FlowJobTests { SimpleFlow flow = new SimpleFlow("job"); JobExecutionDecider decider = new JobExecutionDecider() { - @Override + @Override public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { assertNotNull(stepExecution); throw new RuntimeException("Foo"); @@ -669,7 +669,7 @@ public class FlowJobTests { /** /** * @author Dave Syer - * + * */ private class StubStep extends StepSupport { @@ -677,7 +677,7 @@ public class FlowJobTests { super(name); } - @Override + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException { stepExecution.setStatus(BatchStatus.COMPLETED); stepExecution.setExitStatus(ExitStatus.COMPLETED); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowStepTests.java index 51a8d3a88..a4c084114 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowStepTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -43,7 +43,7 @@ import org.springframework.batch.core.step.StepSupport; * */ public class FlowStepTests { - + private JobRepository jobRepository; private JobExecution jobExecution; @@ -164,7 +164,7 @@ public class FlowStepTests { /** * @author Dave Syer - * + * */ private class StubStep extends StepSupport { @@ -179,7 +179,7 @@ public class FlowStepTests { this.fail = fail; } - @Override + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException { BatchStatus status = BatchStatus.COMPLETED; ExitStatus exitStatus = ExitStatus.COMPLETED; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/StateSupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/StateSupport.java index 26dcd1c3e..317cf0d90 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/StateSupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/StateSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -20,14 +20,14 @@ import org.springframework.batch.core.job.flow.support.state.AbstractState; /** * Base class for {@link State} implementations in test cases. - * + * * @author Dave Syer * */ public class StateSupport extends AbstractState { private FlowExecutionStatus status; - + public StateSupport(String name) { this(name, FlowExecutionStatus.COMPLETED); } @@ -45,8 +45,8 @@ public class StateSupport extends AbstractState { } return this.status; } - - @Override + + @Override public boolean isEndState() { return false; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/support/JobFlowExecutorSupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/support/JobFlowExecutorSupport.java index 88818e8a6..c4be052e0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/support/JobFlowExecutorSupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/support/JobFlowExecutorSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -28,44 +28,44 @@ import org.springframework.batch.core.repository.JobRestartException; /** * @author Dave Syer - * + * */ public class JobFlowExecutorSupport implements FlowExecutor { - @Override + @Override public String executeStep(Step step) throws JobInterruptedException, JobRestartException, - StartLimitExceededException { + StartLimitExceededException { return ExitStatus.COMPLETED.getExitCode(); } - @Override + @Override public JobExecution getJobExecution() { return null; } - @Override + @Override public StepExecution getStepExecution() { return null; } - @Override + @Override public void close(FlowExecution result) { } - @Override + @Override public void abandonStepExecution() { } - - @Override + + @Override public void updateJobExecutionStatus(FlowExecutionStatus status) { } - - @Override + + @Override public boolean isRestart() { return false; } - - @Override + + @Override public void addExitStatus(String code) { } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/EmptyItemWriter.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/EmptyItemWriter.java index 8f0806047..3a49d2a60 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/EmptyItemWriter.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/EmptyItemWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -39,7 +39,7 @@ public class EmptyItemWriter implements ItemWriter, InitializingBean { List list; - @Override + @Override public void afterPropertiesSet() throws Exception { list = TransactionAwareProxyFactory.createTransactionalList(); } @@ -48,7 +48,7 @@ public class EmptyItemWriter implements ItemWriter, InitializingBean { this.failurePoint = failurePoint; } - @Override + @Override public void write(List items) { for (T data : items) { if (!failed && list.size() == failurePoint) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobExecutionNotFailedExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobExecutionNotFailedExceptionTests.java index 5330d9ad8..7de6f10de 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobExecutionNotFailedExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobExecutionNotFailedExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -26,7 +26,7 @@ public class JobExecutionNotFailedExceptionTests extends AbstractExceptionTests /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ - @Override + @Override public Exception getException(String msg) throws Exception { return new JobExecutionNotFailedException(msg); } @@ -34,7 +34,7 @@ public class JobExecutionNotFailedExceptionTests extends AbstractExceptionTests /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ - @Override + @Override public Exception getException(String msg, Throwable t) throws Exception { return new JobExecutionNotFailedException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobInstanceAlreadyExistsExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobInstanceAlreadyExistsExceptionTests.java index 6a3d7963f..3921e4d89 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobInstanceAlreadyExistsExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobInstanceAlreadyExistsExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -16,7 +16,6 @@ package org.springframework.batch.core.launch; import org.springframework.batch.core.AbstractExceptionTests; -import org.springframework.batch.core.launch.JobInstanceAlreadyExistsException; /** * @author Dave Syer @@ -27,7 +26,7 @@ public class JobInstanceAlreadyExistsExceptionTests extends AbstractExceptionTes /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ - @Override + @Override public Exception getException(String msg) throws Exception { return new JobInstanceAlreadyExistsException(msg); } @@ -35,7 +34,7 @@ public class JobInstanceAlreadyExistsExceptionTests extends AbstractExceptionTes /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ - @Override + @Override public Exception getException(String msg, Throwable t) throws Exception { return new JobInstanceAlreadyExistsException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobParametersNotFoundExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobParametersNotFoundExceptionTests.java index 1c257e164..003e33e0b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobParametersNotFoundExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/JobParametersNotFoundExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -26,7 +26,7 @@ public class JobParametersNotFoundExceptionTests extends AbstractExceptionTests /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ - @Override + @Override public Exception getException(String msg) throws Exception { return new JobParametersNotFoundException(msg); } @@ -34,7 +34,7 @@ public class JobParametersNotFoundExceptionTests extends AbstractExceptionTests /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ - @Override + @Override public Exception getException(String msg, Throwable t) throws Exception { return new JobParametersNotFoundException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobExecutionExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobExecutionExceptionTests.java index 934f8f705..46fdab4d2 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobExecutionExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobExecutionExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -16,7 +16,6 @@ package org.springframework.batch.core.launch; import org.springframework.batch.core.AbstractExceptionTests; -import org.springframework.batch.core.launch.NoSuchJobExecutionException; /** * @author Dave Syer @@ -27,7 +26,7 @@ public class NoSuchJobExecutionExceptionTests extends AbstractExceptionTests { /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ - @Override + @Override public Exception getException(String msg) throws Exception { return new NoSuchJobExecutionException(msg); } @@ -35,7 +34,7 @@ public class NoSuchJobExecutionExceptionTests extends AbstractExceptionTests { /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ - @Override + @Override public Exception getException(String msg, Throwable t) throws Exception { return new NoSuchJobExecutionException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobInstanceExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobInstanceExceptionTests.java index 5bc2f5af9..1a1a4e300 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobInstanceExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/NoSuchJobInstanceExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -16,7 +16,6 @@ package org.springframework.batch.core.launch; import org.springframework.batch.core.AbstractExceptionTests; -import org.springframework.batch.core.launch.NoSuchJobInstanceException; /** * @author Dave Syer @@ -27,7 +26,7 @@ public class NoSuchJobInstanceExceptionTests extends AbstractExceptionTests { /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ - @Override + @Override public Exception getException(String msg) throws Exception { return new NoSuchJobInstanceException(msg); } @@ -35,7 +34,7 @@ public class NoSuchJobInstanceExceptionTests extends AbstractExceptionTests { /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ - @Override + @Override public Exception getException(String msg, Throwable t) throws Exception { return new NoSuchJobInstanceException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/SimpleJobLauncherTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/SimpleJobLauncherTests.java index 76bee6abe..d53681e01 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/SimpleJobLauncherTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/SimpleJobLauncherTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -47,7 +47,7 @@ import org.springframework.core.task.TaskRejectedException; /** * @author Lucas Ward - * + * */ public class SimpleJobLauncherTests { @@ -162,7 +162,7 @@ public class SimpleJobLauncherTests { public void testTaskExecutor() throws Exception { final List list = new ArrayList(); jobLauncher.setTaskExecutor(new TaskExecutor() { - @Override + @Override public void execute(Runnable task) { list.add("execute"); task.run(); @@ -177,7 +177,7 @@ public class SimpleJobLauncherTests { final List list = new ArrayList(); jobLauncher.setTaskExecutor(new TaskExecutor() { - @Override + @Override public void execute(Runnable task) { list.add("execute"); throw new TaskRejectedException("Planned failure"); @@ -209,7 +209,7 @@ public class SimpleJobLauncherTests { @Test public void testRunWithException() throws Exception { job = new JobSupport() { - @Override + @Override public void execute(JobExecution execution) { execution.setExitStatus(ExitStatus.FAILED); throw new RuntimeException("foo"); @@ -227,7 +227,7 @@ public class SimpleJobLauncherTests { @Test public void testRunWithError() throws Exception { job = new JobSupport() { - @Override + @Override public void execute(JobExecution execution) { execution.setExitStatus(ExitStatus.FAILED); throw new Error("foo"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java index 7b399e579..f9f328054 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -48,7 +48,7 @@ import org.springframework.util.ClassUtils; /** * @author Lucas Ward - * + * */ public class CommandLineJobRunnerTests { @@ -75,7 +75,7 @@ public class CommandLineJobRunnerTests { StubJobLauncher.jobExecution = jobExecution; stdin = System.in; System.setIn(new InputStream() { - @Override + @Override public int read() { return -1; } @@ -141,12 +141,12 @@ public class CommandLineJobRunnerTests { @Test public void testWithInvalidStdin() throws Throwable { System.setIn(new InputStream() { - @Override - public int available() throws IOException { - throw new IOException("Planned"); - } + @Override + public int available() throws IOException { + throw new IOException("Planned"); + } - @Override + @Override public int read() { return -1; } @@ -163,12 +163,12 @@ public class CommandLineJobRunnerTests { int index = 0; - @Override - public int available() { - return input.length - index; - } + @Override + public int available() { + return input.length - index; + } - @Override + @Override public int read() { return index findRunningJobExecutions(String jobName) { throw new UnsupportedOperationException(); } - @Override + @Override public JobExecution getJobExecution(Long executionId) { if (jobExecution != null) { return jobExecution; @@ -429,7 +429,7 @@ public class CommandLineJobRunnerTests { throw new UnsupportedOperationException(); } - @Override + @Override public List getJobExecutions(JobInstance jobInstance) { if (jobInstance.getId() == 0) { return Arrays.asList(createJobExecution(jobInstance, BatchStatus.FAILED)); @@ -463,12 +463,12 @@ public class CommandLineJobRunnerTests { return jobExecution; } - @Override + @Override public JobInstance getJobInstance(Long instanceId) { throw new UnsupportedOperationException(); } - @Override + @Override public List getJobInstances(String jobName, int start, int count) { if (jobInstances == null) { return new ArrayList(); @@ -478,12 +478,12 @@ public class CommandLineJobRunnerTests { return result; } - @Override + @Override public StepExecution getStepExecution(Long jobExecutionId, Long stepExecutionId) { throw new UnsupportedOperationException(); } - @Override + @Override public List getJobNames() { throw new UnsupportedOperationException(); } @@ -496,13 +496,13 @@ public class CommandLineJobRunnerTests { static boolean called = false; - @Override + @Override public JobParameters getJobParameters(Properties properties) { called = true; return delegate.getJobParameters(properties); } - @Override + @Override public Properties getProperties(JobParameters params) { throw new UnsupportedOperationException(); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/ScheduledJobParametersFactoryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/ScheduledJobParametersFactoryTests.java index 2af2c947e..32521bd16 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/ScheduledJobParametersFactoryTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/ScheduledJobParametersFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -24,12 +24,11 @@ import junit.framework.TestCase; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.JobParametersBuilder; -import org.springframework.batch.core.launch.support.ScheduledJobParametersFactory; import org.springframework.util.StringUtils; /** * @author Lucas Ward - * + * */ public class ScheduledJobParametersFactoryTests extends TestCase { @@ -37,7 +36,7 @@ public class ScheduledJobParametersFactoryTests extends TestCase { DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); - @Override + @Override protected void setUp() throws Exception { super.setUp(); @@ -63,7 +62,7 @@ public class ScheduledJobParametersFactoryTests extends TestCase { public void testGetProperties() throws Exception { JobParameters parameters = new JobParametersBuilder().addDate("schedule.date", dateFormat.parse("01/23/2008")) - .addString("job.key", "myKey").addString("vendor.id", "33243243").toJobParameters(); + .addString("job.key", "myKey").addString("vendor.id", "33243243").toJobParameters(); Properties props = factory.getProperties(parameters); assertNotNull(props); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJobOperatorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJobOperatorTests.java index 1e15d170b..114e87d24 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJobOperatorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJobOperatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -58,7 +58,7 @@ import org.springframework.batch.support.PropertiesConverter; /** * @author Dave Syer - * + * */ public class SimpleJobOperatorTests { @@ -67,14 +67,14 @@ public class SimpleJobOperatorTests { protected Job job; private JobExplorer jobExplorer; - + private JobRepository jobRepository; private JobParameters jobParameters; /** * @throws Exception - * + * */ @Before public void setUp() throws Exception { @@ -83,7 +83,7 @@ public class SimpleJobOperatorTests { @Override public JobParametersIncrementer getJobParametersIncrementer() { return new JobParametersIncrementer() { - @Override + @Override public JobParameters getNext(JobParameters parameters) { return jobParameters; } @@ -94,7 +94,7 @@ public class SimpleJobOperatorTests { jobOperator = new SimpleJobOperator(); jobOperator.setJobRegistry(new MapJobRegistry() { - @Override + @Override public Job getJob(String name) throws NoSuchJobException { if (name.equals("foo")) { return job; @@ -102,6 +102,7 @@ public class SimpleJobOperatorTests { throw new NoSuchJobException("foo"); } + @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public Set getJobNames() { return new HashSet(Arrays.asList(new String[] { "foo", "bar" })); @@ -109,9 +110,9 @@ public class SimpleJobOperatorTests { }); jobOperator.setJobLauncher(new JobLauncher() { - @Override + @Override public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, - JobRestartException, JobInstanceAlreadyCompleteException { + JobRestartException, JobInstanceAlreadyCompleteException { return new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 999L); } }); @@ -119,7 +120,7 @@ public class SimpleJobOperatorTests { jobExplorer = EasyMock.createNiceMock(JobExplorer.class); jobOperator.setJobExplorer(jobExplorer); - + jobRepository = createMock(JobRepository.class); jobOperator.setJobRepository(jobRepository); @@ -201,7 +202,7 @@ public class SimpleJobOperatorTests { jobParameters = new JobParameters(); jobExplorer.getJobExecution(111L); EasyMock.expectLastCall() - .andReturn(new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L)); + .andReturn(new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L)); EasyMock.replay(jobExplorer); Long value = jobOperator.restart(111L); assertEquals(999, value.longValue()); @@ -297,7 +298,7 @@ public class SimpleJobOperatorTests { final JobParameters jobParameters = new JobParameters(); jobExplorer.getJobExecution(111L); EasyMock.expectLastCall() - .andReturn(new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L)); + .andReturn(new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L)); EasyMock.replay(jobExplorer); String value = jobOperator.getParameters(111L); assertEquals("a=b", value); @@ -381,7 +382,7 @@ public class SimpleJobOperatorTests { } EasyMock.verify(jobExplorer); } - + @Test public void testStop() throws Exception{ JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName()); @@ -397,29 +398,29 @@ public class SimpleJobOperatorTests { assertEquals(BatchStatus.STOPPING, jobExecution.getStatus()); } - @Test - public void testAbort() throws Exception { - JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName()); - JobExecution jobExecution = new JobExecution(jobInstance, 111L); - jobExecution.setStatus(BatchStatus.STOPPING); - jobExplorer.getJobExecution(123L); - expectLastCall().andReturn(jobExecution); - jobRepository.update(jobExecution); - replay(jobExplorer); - jobOperator.abandon(123L); - assertEquals(BatchStatus.ABANDONED, jobExecution.getStatus()); - assertNotNull(jobExecution.getEndTime()); - } + @Test + public void testAbort() throws Exception { + JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName()); + JobExecution jobExecution = new JobExecution(jobInstance, 111L); + jobExecution.setStatus(BatchStatus.STOPPING); + jobExplorer.getJobExecution(123L); + expectLastCall().andReturn(jobExecution); + jobRepository.update(jobExecution); + replay(jobExplorer); + jobOperator.abandon(123L); + assertEquals(BatchStatus.ABANDONED, jobExecution.getStatus()); + assertNotNull(jobExecution.getEndTime()); + } - @Test(expected = JobExecutionAlreadyRunningException.class) - public void testAbortNonStopping() throws Exception { - JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName()); - JobExecution jobExecution = new JobExecution(jobInstance, 111L); - jobExecution.setStatus(BatchStatus.STARTED); - jobExplorer.getJobExecution(123L); - expectLastCall().andReturn(jobExecution); - jobRepository.update(jobExecution); - replay(jobExplorer); - jobOperator.abandon(123L); - } + @Test(expected = JobExecutionAlreadyRunningException.class) + public void testAbortNonStopping() throws Exception { + JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName()); + JobExecution jobExecution = new JobExecution(jobInstance, 111L); + jobExecution.setStatus(BatchStatus.STARTED); + jobExplorer.getJobExecution(123L); + expectLastCall().andReturn(jobExecution); + jobRepository.update(jobExecution); + replay(jobExplorer); + jobOperator.abandon(123L); + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapperTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapperTests.java index f2ca2eabe..0546cbd98 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapperTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJvmExitCodeMapperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -22,21 +22,19 @@ import java.util.Map; import junit.framework.TestCase; import org.springframework.batch.core.ExitStatus; -import org.springframework.batch.core.launch.support.ExitCodeMapper; -import org.springframework.batch.core.launch.support.SimpleJvmExitCodeMapper; public class SimpleJvmExitCodeMapperTests extends TestCase { private SimpleJvmExitCodeMapper ecm; private SimpleJvmExitCodeMapper ecm2; - - @Override + + @Override protected void setUp() throws Exception { ecm = new SimpleJvmExitCodeMapper(); Map ecmMap = new HashMap(); ecmMap.put("MY_CUSTOM_CODE", new Integer(3)); ecm.setMapping(ecmMap); - + ecm2 = new SimpleJvmExitCodeMapper(); Map ecm2Map = new HashMap(); ecm2Map.put(ExitStatus.COMPLETED.getExitCode(), new Integer(-1)); @@ -46,7 +44,7 @@ public class SimpleJvmExitCodeMapperTests extends TestCase { ecm2.setMapping(ecm2Map); } - @Override + @Override protected void tearDown() throws Exception { super.tearDown(); } @@ -60,12 +58,12 @@ public class SimpleJvmExitCodeMapperTests extends TestCase { ExitCodeMapper.JVM_EXITCODE_GENERIC_ERROR); assertEquals( ecm.intValue(ExitCodeMapper.JOB_NOT_PROVIDED), - ExitCodeMapper.JVM_EXITCODE_JOB_ERROR); + ExitCodeMapper.JVM_EXITCODE_JOB_ERROR); assertEquals( ecm.intValue(ExitCodeMapper.NO_SUCH_JOB), - ExitCodeMapper.JVM_EXITCODE_JOB_ERROR); + ExitCodeMapper.JVM_EXITCODE_JOB_ERROR); } - + public void testGetExitCodeWithPredefinedCodesOverridden() { System.out.println(ecm2.intValue(ExitStatus.COMPLETED.getExitCode())); assertEquals( @@ -73,20 +71,20 @@ public class SimpleJvmExitCodeMapperTests extends TestCase { assertEquals( ecm2.intValue(ExitStatus.FAILED.getExitCode()), -2); assertEquals( - ecm2.intValue(ExitCodeMapper.JOB_NOT_PROVIDED), -3); + ecm2.intValue(ExitCodeMapper.JOB_NOT_PROVIDED), -3); assertEquals( - ecm2.intValue(ExitCodeMapper.NO_SUCH_JOB), -3); + ecm2.intValue(ExitCodeMapper.NO_SUCH_JOB), -3); } public void testGetExitCodeWithCustomCode() { - assertEquals(ecm.intValue("MY_CUSTOM_CODE"),3); + assertEquals(ecm.intValue("MY_CUSTOM_CODE"),3); } public void testGetExitCodeWithDefaultCode() { assertEquals( ecm.intValue("UNDEFINED_CUSTOM_CODE"), - ExitCodeMapper.JVM_EXITCODE_GENERIC_ERROR); + ExitCodeMapper.JVM_EXITCODE_GENERIC_ERROR); } - - + + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/StubJobLauncher.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/StubJobLauncher.java index 1b8c5d2cf..a28fa153f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/StubJobLauncher.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/StubJobLauncher.java @@ -30,7 +30,7 @@ public class StubJobLauncher implements JobLauncher { return isRunning; } - @Override + @Override public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException { lastRunCalled = RUN_JOB_IDENTIFIER; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/TestJobParametersIncrementer.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/TestJobParametersIncrementer.java index cc97e9a98..bde47fef7 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/TestJobParametersIncrementer.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/TestJobParametersIncrementer.java @@ -6,7 +6,7 @@ import org.springframework.batch.core.JobParametersIncrementer; public class TestJobParametersIncrementer implements JobParametersIncrementer { - @Override + @Override public JobParameters getNext(JobParameters parameters) { return new JobParametersBuilder().addString("foo", "spam").toJobParameters(); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeJobExecutionListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeJobExecutionListenerTests.java index 414b5e8ad..98aa545ce 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeJobExecutionListenerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeJobExecutionListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -26,7 +26,7 @@ import org.springframework.batch.core.JobInstance; /** * @author Dave Syer - * + * */ public class CompositeJobExecutionListenerTests extends TestCase { @@ -40,12 +40,12 @@ public class CompositeJobExecutionListenerTests extends TestCase { */ public void testSetListeners() { listener.setListeners(Arrays.asList(new JobExecutionListenerSupport() { - @Override + @Override public void afterJob(JobExecution jobExecution) { list.add("fail"); } }, new JobExecutionListenerSupport() { - @Override + @Override public void afterJob(JobExecution jobExecution) { list.add("continue"); } @@ -61,7 +61,7 @@ public class CompositeJobExecutionListenerTests extends TestCase { */ public void testSetListener() { listener.register(new JobExecutionListenerSupport() { - @Override + @Override public void afterJob(JobExecution jobExecution) { list.add("fail"); } @@ -77,7 +77,7 @@ public class CompositeJobExecutionListenerTests extends TestCase { */ public void testOpen() { listener.register(new JobExecutionListenerSupport() { - @Override + @Override public void beforeJob(JobExecution stepExecution) { list.add("foo"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeStepExecutionListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeStepExecutionListenerTests.java index 1a9cb5278..723d85bc3 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeStepExecutionListenerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeStepExecutionListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -26,7 +26,7 @@ import org.springframework.batch.core.StepExecutionListener; /** * @author Dave Syer - * + * */ public class CompositeStepExecutionListenerTests extends TestCase { @@ -41,13 +41,13 @@ public class CompositeStepExecutionListenerTests extends TestCase { */ public void testSetListeners() { listener.setListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() { - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("fail"); return ExitStatus.FAILED; } }, new StepExecutionListenerSupport() { - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("continue"); return ExitStatus.EXECUTING; @@ -64,7 +64,7 @@ public class CompositeStepExecutionListenerTests extends TestCase { */ public void testSetListener() { listener.register(new StepExecutionListenerSupport() { - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("fail"); return ExitStatus.FAILED; @@ -81,7 +81,7 @@ public class CompositeStepExecutionListenerTests extends TestCase { */ public void testOpen() { listener.register(new StepExecutionListenerSupport() { - @Override + @Override public void beforeStep(StepExecution stepExecution) { list.add("foo"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/JobListenerFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/JobListenerFactoryBeanTests.java index 0fda435c0..d6323ac62 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/JobListenerFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/JobListenerFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2013 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. @@ -36,7 +36,7 @@ import org.springframework.core.Ordered; /** * @author Lucas Ward - * + * */ public class JobListenerFactoryBeanTests { @@ -105,7 +105,6 @@ public class JobListenerFactoryBeanTests { @Test public void testAnnotationsIsListener() throws Exception { assertTrue(JobListenerFactoryBean.isListener(new Object() { - @SuppressWarnings("unused") @BeforeJob public void foo(JobExecution execution) { } @@ -120,12 +119,11 @@ public class JobListenerFactoryBeanTests { @Test public void testAnnotationsWithOrdered() throws Exception { Object delegate = new Ordered() { - @SuppressWarnings("unused") @BeforeJob public void foo(JobExecution execution) { } - @Override + @Override public int getOrder() { return 3; } @@ -146,7 +144,6 @@ public class JobListenerFactoryBeanTests { @Test public void testEmptySignatureAnnotation() { AbstractTestComponent delegate = new AbstractTestComponent() { - @SuppressWarnings("unused") @AfterJob public void aMethod() { executed = true; @@ -161,7 +158,6 @@ public class JobListenerFactoryBeanTests { @Test public void testRightSignatureAnnotation() { AbstractTestComponent delegate = new AbstractTestComponent() { - @SuppressWarnings("unused") @AfterJob public void aMethod(JobExecution jobExecution) { executed = true; @@ -177,7 +173,6 @@ public class JobListenerFactoryBeanTests { @Test(expected = IllegalArgumentException.class) public void testWrongSignatureAnnotation() { AbstractTestComponent delegate = new AbstractTestComponent() { - @SuppressWarnings("unused") @AfterJob public void aMethod(Integer item) { executed = true; @@ -243,19 +238,18 @@ public class JobListenerFactoryBeanTests { boolean afterJobCalled = false; - @Override + @Override public void afterJob(JobExecution jobExecution) { afterJobCalled = true; } - @Override + @Override public void beforeJob(JobExecution jobExecution) { beforeJobCalled = true; } } - @SuppressWarnings("unused") private class AnnotatedTestClass { boolean beforeJobCalled = false; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/OrderedCompositeTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/OrderedCompositeTests.java index 9d5440bd9..99ef203ee 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/OrderedCompositeTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/OrderedCompositeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -27,7 +27,7 @@ import org.springframework.core.annotation.Order; /** * @author Dave Syer - * + * */ public class OrderedCompositeTests { @@ -62,7 +62,7 @@ public class OrderedCompositeTests { public void testAddOrdered() { list.setItems(Arrays.asList((Object) "1")); list.add(new Ordered() { - @Override + @Override public int getOrder() { return 0; } @@ -76,13 +76,13 @@ public class OrderedCompositeTests { public void testAddMultipleOrdered() { list.setItems(Arrays.asList((Object) "1")); list.add(new Ordered() { - @Override + @Override public int getOrder() { return 1; } }); list.add(new Ordered() { - @Override + @Override public int getOrder() { return 0; } @@ -97,13 +97,13 @@ public class OrderedCompositeTests { public void testAddDuplicateOrdered() { list.setItems(Arrays.asList((Object) "1")); list.add(new Ordered() { - @Override + @Override public int getOrder() { return 1; } }); list.add(new Ordered() { - @Override + @Override public int getOrder() { return 1; } @@ -117,7 +117,7 @@ public class OrderedCompositeTests { @Test public void testAddAnnotationOrdered() { list.add(new Ordered() { - @Override + @Override public int getOrder() { return 1; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerFactoryBeanTests.java index 08abbe6c9..3288289ef 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2013 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. @@ -63,7 +63,7 @@ import org.springframework.util.Assert; /** * @author Lucas Ward - * + * */ public class StepListenerFactoryBeanTests { @@ -186,12 +186,11 @@ public class StepListenerFactoryBeanTests { @Test public void testAnnotationsWithOrdered() throws Exception { Object delegate = new Ordered() { - @SuppressWarnings("unused") @BeforeStep public void foo(StepExecution execution) { } - @Override + @Override public int getOrder() { return 3; } @@ -204,12 +203,11 @@ public class StepListenerFactoryBeanTests { @Test public void testProxiedAnnotationsFactoryMethod() throws Exception { Object delegate = new InitializingBean() { - @SuppressWarnings("unused") @BeforeStep public void foo(StepExecution execution) { } - @Override + @Override public void afterPropertiesSet() throws Exception { } }; @@ -226,7 +224,6 @@ public class StepListenerFactoryBeanTests { @Test public void testAnnotationsIsListener() throws Exception { assertTrue(StepListenerFactoryBean.isListener(new Object() { - @SuppressWarnings("unused") @BeforeStep public void foo(StepExecution execution) { } @@ -238,7 +235,7 @@ public class StepListenerFactoryBeanTests { ProxyFactory factory = new ProxyFactory(); factory.addInterface(DataSource.class); factory.addAdvice(new MethodInterceptor() { - @Override + @Override public Object invoke(MethodInvocation invocation) throws Throwable { return null; } @@ -250,12 +247,11 @@ public class StepListenerFactoryBeanTests { @Test public void testProxiedAnnotationsIsListener() throws Exception { Object delegate = new InitializingBean() { - @SuppressWarnings("unused") @BeforeStep public void foo(StepExecution execution) { } - @Override + @Override public void afterPropertiesSet() throws Exception { } }; @@ -280,7 +276,6 @@ public class StepListenerFactoryBeanTests { @Test public void testEmptySignatureAnnotation() { AbstractTestComponent delegate = new AbstractTestComponent() { - @SuppressWarnings("unused") @AfterWrite public void aMethod() { executed = true; @@ -296,7 +291,6 @@ public class StepListenerFactoryBeanTests { @Test public void testRightSignatureAnnotation() { AbstractTestComponent delegate = new AbstractTestComponent() { - @SuppressWarnings("unused") @AfterWrite public void aMethod(List items) { executed = true; @@ -314,7 +308,6 @@ public class StepListenerFactoryBeanTests { @Test(expected = IllegalArgumentException.class) public void testWrongSignatureAnnotation() { AbstractTestComponent delegate = new AbstractTestComponent() { - @SuppressWarnings("unused") @AfterWrite public void aMethod(Integer item) { executed = true; @@ -381,7 +374,7 @@ public class StepListenerFactoryBeanTests { int callcount = 0; - @Override + @Override @AfterStep public ExitStatus afterStep(StepExecution stepExecution) { Assert.notNull(stepExecution); @@ -389,7 +382,7 @@ public class StepListenerFactoryBeanTests { return null; } - @Override + @Override public void beforeStep(StepExecution stepExecution) { callcount++; } @@ -401,14 +394,14 @@ public class StepListenerFactoryBeanTests { int callcount = 0; - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { Assert.notNull(stepExecution); callcount++; return null; } - @Override + @Override public void beforeStep(StepExecution stepExecution) { callcount++; } @@ -523,17 +516,17 @@ public class StepListenerFactoryBeanTests { onWriteErrorCalled = true; } - @Override + @Override public void onSkipInProcess(String item, Throwable t) { onSkipInProcessCalled = true; } - @Override + @Override public void onSkipInRead(Throwable t) { onSkipInReadCalled = true; } - @Override + @Override public void onSkipInWrite(Integer item, Throwable t) { onSkipInWriteCalled = true; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerMethodInterceptorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerMethodInterceptorTests.java index 6137138fc..297c9cea0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerMethodInterceptorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerMethodInterceptorTests.java @@ -21,15 +21,15 @@ public class StepListenerMethodInterceptorTests { MethodInvokerMethodInterceptor interceptor; TestClass testClass; - + @Before public void setUp(){ testClass = new TestClass(); } - + @Test public void testNormalCase() throws Throwable{ - + Map> invokerMap = new HashMap>(); for(Method method : TestClass.class.getMethods()){ invokerMap.put(method.getName(), asSet( new SimpleMethodInvoker(testClass, method))); @@ -40,10 +40,10 @@ public class StepListenerMethodInterceptorTests { interceptor.invoke(new StubMethodInvocation(TestClass.class.getMethod("method2"))); assertEquals(1, testClass.method2Count); } - + @Test public void testMultipleInvokersPerName() throws Throwable{ - + Map> invokerMap = new HashMap>(); Set invokers = asSet(MethodInvokerUtils.getMethodInvokerByName(testClass, "method1", false)); invokers.add(MethodInvokerUtils.getMethodInvokerByName(testClass, "method2", false)); @@ -54,7 +54,7 @@ public class StepListenerMethodInterceptorTests { interceptor.invoke(new StubMethodInvocation(TestClass.class.getMethod("method2"))); assertEquals(1, testClass.method2Count); } - + @Test public void testExitStatusReturn() throws Throwable{ Map> invokerMap = new HashMap>(); @@ -64,69 +64,69 @@ public class StepListenerMethodInterceptorTests { interceptor = new MethodInvokerMethodInterceptor(invokerMap); assertEquals(ExitStatus.COMPLETED, interceptor.invoke(new StubMethodInvocation(TestClass.class.getMethod("method3")))); } - + public Set asSet(MethodInvoker methodInvoker){ Set invokerSet = new HashSet(); invokerSet.add(methodInvoker); return invokerSet; } - + @SuppressWarnings("unused") private class TestClass{ - + int method1Count = 0; int method2Count = 0; int method3Count = 0; - + public void method1(){ method1Count++; } - + public void method2(){ method2Count++; } - + public ExitStatus method3(){ method3Count++; return ExitStatus.COMPLETED; } } - + @SuppressWarnings("unused") private class StubMethodInvocation implements MethodInvocation{ Method method; Object[] args; - + public StubMethodInvocation(Method method, Object... args) { this.method = method; this.args = args; } - - @Override + + @Override public Method getMethod() { return method; } - @Override + @Override public Object[] getArguments() { return null; } - @Override + @Override public AccessibleObject getStaticPart() { return null; } - @Override + @Override public Object getThis() { return null; } - @Override + @Override public Object proceed() throws Throwable { return null; } - + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemReader.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemReader.java index 70481b054..6c17abb9e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemReader.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemReader.java @@ -41,7 +41,7 @@ public class ExampleItemReader implements ItemReader, ItemStream { /** * Reads next record from input */ - @Override + @Override public String read() throws Exception { if (index >= input.length || index >= max) { return null; @@ -62,16 +62,16 @@ public class ExampleItemReader implements ItemReader, ItemStream { return input[index++]; } - @Override + @Override public void close() throws ItemStreamException { } - @Override + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { index = (int) executionContext.getLong("POSITION", min); } - @Override + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { executionContext.putLong("POSITION", index); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemWriter.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemWriter.java index 97c7beeea..9026a8e04 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemWriter.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemWriter.java @@ -13,9 +13,9 @@ import org.springframework.batch.item.ItemWriter; public class ExampleItemWriter implements ItemWriter { private static final Log log = LogFactory.getLog(ExampleItemWriter.class); - + private static List items = new ArrayList(); - + public static void clear() { items.clear(); } @@ -27,7 +27,7 @@ public class ExampleItemWriter implements ItemWriter { /** * @see ItemWriter#write(List) */ - @Override + @Override public void write(List data) throws Exception { log.info(data); items.addAll(data); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/MinMaxPartitioner.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/MinMaxPartitioner.java index db3522017..c8c12aaa5 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/MinMaxPartitioner.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/MinMaxPartitioner.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -27,17 +27,17 @@ import org.springframework.batch.item.ExecutionContext; */ public class MinMaxPartitioner extends SimplePartitioner { - @Override + @Override public Map partition(int gridSize) { Map partition = super.partition(gridSize); int total = 8; // The number of items in the ExampleItemReader int range = total/gridSize; int i = 0; for (ExecutionContext context : partition.values()) { - int min = (i++)*range; - int max = Math.min(total, (min+1)*range); - context.putInt("min", min); - context.putInt("max", max); + int min = (i++)*range; + int max = Math.min(total, (min+1)*range); + context.putInt("min", min); + context.putInt("max", max); } return partition; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/PartitionStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/PartitionStepTests.java index 953a0dae4..5e2118e15 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/PartitionStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/PartitionStepTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -37,7 +37,7 @@ import org.springframework.batch.core.repository.support.MapJobRepositoryFactory /** * @author Dave Syer - * + * */ public class PartitionStepTests { @@ -57,7 +57,7 @@ public class PartitionStepTests { public void testVanillaStepExecution() throws Exception { step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { - @Override + @Override public Collection handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { Set executions = stepSplitter.split(stepExecution, 2); @@ -82,7 +82,7 @@ public class PartitionStepTests { public void testFailedStepExecution() throws Exception { step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { - @Override + @Override public Collection handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { Set executions = stepSplitter.split(stepExecution, 2); @@ -108,7 +108,7 @@ public class PartitionStepTests { final AtomicBoolean started = new AtomicBoolean(false); step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { - @Override + @Override public Collection handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { Set executions = stepSplitter.split(stepExecution, 2); @@ -155,7 +155,7 @@ public class PartitionStepTests { public void testStoppedStepExecution() throws Exception { step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { - @Override + @Override public Collection handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { Set executions = stepSplitter.split(stepExecution, 2); @@ -187,7 +187,7 @@ public class PartitionStepTests { }); step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { - @Override + @Override public Collection handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { return Arrays.asList(stepExecution); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java index 84313c3dc..2824334f9 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitterTests.java @@ -59,11 +59,11 @@ public class SimpleStepExecutionSplitterTests { final Map map = Collections.singletonMap("foo", new ExecutionContext()); SimpleStepExecutionSplitter splitter = new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new Partitioner() { - @Override - public Map partition(int gridSize) { - return map; - } - }); + @Override + public Map partition(int gridSize) { + return map; + } + }); assertEquals(1, splitter.split(stepExecution, 2).size()); } @@ -80,12 +80,12 @@ public class SimpleStepExecutionSplitterTests { @Test public void testRememberPartitionNames() throws Exception { class CustomPartitioner implements Partitioner, PartitionNameProvider { - @Override + @Override public Map partition(int gridSize) { return Collections.singletonMap("foo", new ExecutionContext()); } - @Override + @Override public Collection getPartitionNames(int gridSize) { return Arrays.asList("foo"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandlerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandlerTests.java index 0b8d51cd1..b6287cdd1 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandlerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandlerTests.java @@ -27,19 +27,19 @@ public class TaskExecutorPartitionHandlerTests { private TaskExecutorPartitionHandler handler = new TaskExecutorPartitionHandler(); private int count = 0; - + private Collection stepExecutions = new TreeSet(); private StepExecution stepExecution = new StepExecution("step", new JobExecution(1L)); private StepExecutionSplitter stepExecutionSplitter = new StepExecutionSplitter() { - @Override + @Override public String getStepName() { return stepExecution.getStepName(); } - @Override + @Override public Set split(StepExecution stepExecution, int gridSize) throws JobExecutionException { HashSet result = new HashSet(); for (int i = gridSize; i-- > 0;) { @@ -94,7 +94,7 @@ public class TaskExecutorPartitionHandlerTests { public void testTaskExecutorFailure() throws Exception { handler.setGridSize(2); handler.setTaskExecutor(new TaskExecutor() { - @Override + @Override public void execute(Runnable task) { if (count > 0) { throw new TaskRejectedException("foo"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobExecutionAlreadyRunningExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobExecutionAlreadyRunningExceptionTests.java index 5a448c420..ab2d70511 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobExecutionAlreadyRunningExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobExecutionAlreadyRunningExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -26,7 +26,7 @@ public class JobExecutionAlreadyRunningExceptionTests extends AbstractExceptionT /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ - @Override + @Override public Exception getException(String msg) throws Exception { return new JobExecutionAlreadyRunningException(msg); } @@ -34,7 +34,7 @@ public class JobExecutionAlreadyRunningExceptionTests extends AbstractExceptionT /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ - @Override + @Override public Exception getException(String msg, Throwable t) throws Exception { return new JobExecutionAlreadyRunningException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobInstanceAlreadyCompleteExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobInstanceAlreadyCompleteExceptionTests.java index a3060309f..3d824c05a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobInstanceAlreadyCompleteExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobInstanceAlreadyCompleteExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -26,7 +26,7 @@ public class JobInstanceAlreadyCompleteExceptionTests extends AbstractExceptionT /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ - @Override + @Override public Exception getException(String msg) throws Exception { return new JobInstanceAlreadyCompleteException(msg); } @@ -34,7 +34,7 @@ public class JobInstanceAlreadyCompleteExceptionTests extends AbstractExceptionT /* (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable) */ - @Override + @Override public Exception getException(String msg, Throwable t) throws Exception { return new JobInstanceAlreadyCompleteException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobRestartExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobRestartExceptionTests.java index 9adb278bf..20d7db314 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobRestartExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/JobRestartExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -19,7 +19,7 @@ import org.springframework.batch.core.AbstractExceptionTests; /** * @author Dave Syer - * + * */ public class JobRestartExceptionTests extends AbstractExceptionTests { @@ -27,7 +27,7 @@ public class JobRestartExceptionTests extends AbstractExceptionTests { * (non-Javadoc) * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String) */ - @Override + @Override public Exception getException(String msg) throws Exception { return new JobRestartException(msg); } @@ -37,7 +37,7 @@ public class JobRestartExceptionTests extends AbstractExceptionTests { * @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, * java.lang.Throwable) */ - @Override + @Override public Exception getException(String msg, Throwable t) throws Exception { return new JobRestartException(msg, t); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobDaoQueryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobDaoQueryTests.java index 76a74479f..6bdab8cbb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobDaoQueryTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobDaoQueryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -29,7 +29,7 @@ import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer /** * @author Dave Syer - * + * */ public class JdbcJobDaoQueryTests extends TestCase { @@ -41,23 +41,23 @@ public class JdbcJobDaoQueryTests extends TestCase { * (non-Javadoc) * @see junit.framework.TestCase#setUp() */ - @Override + @Override protected void setUp() throws Exception { jobExecutionDao = new JdbcJobExecutionDao(); jobExecutionDao.setJobExecutionIncrementer(new DataFieldMaxValueIncrementer() { - @Override + @Override public int nextIntValue() throws DataAccessException { return 0; } - @Override + @Override public long nextLongValue() throws DataAccessException { return 0; } - @Override + @Override public String nextStringValue() throws DataAccessException { return "bar"; } @@ -68,7 +68,7 @@ public class JdbcJobDaoQueryTests extends TestCase { public void testTablePrefix() throws Exception { jobExecutionDao.setTablePrefix("FOO_"); jobExecutionDao.setJdbcTemplate(new JdbcTemplate() { - @Override + @Override public int update(String sql, Object[] args, int[] argTypes) throws DataAccessException { list.add(sql); return 1; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDaoTests.java index ff430c7c3..59fcc7e0d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDaoTests.java @@ -13,11 +13,11 @@ import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobInstance; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.support.JdbcTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.batch.support.JdbcTestUtils; import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @@ -25,23 +25,23 @@ import org.springframework.transaction.annotation.Transactional; public class JdbcJobInstanceDaoTests extends AbstractJobInstanceDaoTests { private JdbcTemplate jdbcTemplate; - + @Autowired public void setDataSource(DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); } - + @Autowired private JobInstanceDao jobInstanceDao; @Autowired private JobExecutionDao jobExecutionDao; - @Override + @Override protected JobInstanceDao getJobInstanceDao() { JdbcTestUtils.deleteFromTables(jdbcTemplate, "BATCH_JOB_EXECUTION_CONTEXT", - "BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION", - "BATCH_JOB_EXECUTION", "BATCH_JOB_PARAMS", "BATCH_JOB_INSTANCE"); + "BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION", + "BATCH_JOB_EXECUTION", "BATCH_JOB_PARAMS", "BATCH_JOB_INSTANCE"); return jobInstanceDao; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java index 0e981f557..e5dabff17 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java @@ -15,12 +15,12 @@ import org.springframework.transaction.annotation.Transactional; @ContextConfiguration(locations = "sql-dao-test.xml") public class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests { - @Override + @Override protected StepExecutionDao getStepExecutionDao() { return (StepExecutionDao) applicationContext.getBean("stepExecutionDao"); } - @Override + @Override protected JobRepository getJobRepository() { deleteFromTables("BATCH_JOB_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION", "BATCH_JOB_EXECUTION", "BATCH_JOB_PARAMS", "BATCH_JOB_INSTANCE"); @@ -32,15 +32,15 @@ public class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests { */ @Transactional @Test public void testTruncateExitDescription() { - + StringBuffer sb = new StringBuffer(); for (int i = 0; i < 100; i++) { sb.append("too long exit description"); } String longDescription = sb.toString(); - + ExitStatus exitStatus = ExitStatus.FAILED.addExitDescription(longDescription); - + stepExecution.setExitStatus(exitStatus); ((JdbcStepExecutionDao) dao).setExitMessageLength(250); @@ -58,5 +58,5 @@ public class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests { assertTrue("Exit description should be truncated", retrievedAfterUpdate.getExitStatus().getExitDescription() .length() < stepExecution.getExitStatus().getExitDescription().length()); } - + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobExecutionDaoTests.java index 616da0ea9..507ce01bd 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobExecutionDaoTests.java @@ -1,12 +1,13 @@ package org.springframework.batch.core.repository.dao; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + import java.util.Collections; import java.util.Date; import java.util.SortedSet; import java.util.TreeSet; - import java.util.concurrent.CountDownLatch; - import java.util.concurrent.atomic.AtomicReference; import org.junit.Test; @@ -16,8 +17,6 @@ import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobInstance; import org.springframework.batch.core.JobParameters; -import static org.junit.Assert.*; - @RunWith(JUnit4.class) public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests { @@ -25,7 +24,7 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests { protected JobExecutionDao getJobExecutionDao() { return new MapJobExecutionDao(); } - + @Override protected JobInstanceDao getJobInstanceDao() { return new MapJobInstanceDao(); @@ -38,23 +37,23 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests { public void testPersistentCopy() { JobExecutionDao tested = new MapJobExecutionDao(); JobExecution jobExecution = new JobExecution(new JobInstance((long) 1, new JobParameters(), "mapJob")); - + assertNull(jobExecution.getStartTime()); tested.saveJobExecution(jobExecution); jobExecution.setStartTime(new Date()); - + JobExecution retrieved = tested.getJobExecution(jobExecution.getId()); assertNull(retrieved.getStartTime()); - + tested.updateJobExecution(jobExecution); jobExecution.setEndTime(new Date()); assertNull(retrieved.getEndTime()); - + } /** - * Verify that the ids are properly generated even under heavy concurrent load - */ + * Verify that the ids are properly generated even under heavy concurrent load + */ @Test public void testConcurrentSaveJobExecution() throws Exception { final int iterations = 100; @@ -69,7 +68,7 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests { // Implementation of the high-concurrency code final Runnable codeUnderTest = new Runnable() { - @Override + @Override public void run() { try { JobExecution jobExecution = new JobExecution(new JobInstance((long) -1, new JobParameters(), "mapJob")); @@ -98,11 +97,13 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests { for(Thread t : threads) { t.join(); } // Ensure no general exceptions arose - if(exception.get() != null) throw new RuntimeException("Excepion occurred under high concurrency usage", exception.get()); + if(exception.get() != null) { + throw new RuntimeException("Excepion occurred under high concurrency usage", exception.get()); + } // Validate the ids: we'd expect one of these three things to fail if(ids.size() < iterations) { - fail("Duplicate id generated during high concurrency usage"); + fail("Duplicate id generated during high concurrency usage"); } if(ids.first() < 0) { fail("Generated an id less than zero during high concurrency usage: " + ids.first()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobInstanceDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobInstanceDaoTests.java index 462410b9c..4314df6ec 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobInstanceDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapJobInstanceDaoTests.java @@ -6,7 +6,7 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public class MapJobInstanceDaoTests extends AbstractJobInstanceDaoTests { - @Override + @Override protected JobInstanceDao getJobInstanceDao() { return new MapJobInstanceDao(); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapStepExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapStepExecutionDaoTests.java index b4744ee92..5f2d8422c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapStepExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/MapStepExecutionDaoTests.java @@ -7,8 +7,8 @@ import static org.junit.Assert.assertNull; import java.util.Date; import org.junit.Test; -import org.junit.runners.JUnit4; import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.batch.core.BatchStatus; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.StepExecution; @@ -18,17 +18,17 @@ import org.springframework.batch.core.repository.support.SimpleJobRepository; @RunWith(JUnit4.class) public class MapStepExecutionDaoTests extends AbstractStepExecutionDaoTests { - @Override + @Override protected StepExecutionDao getStepExecutionDao() { return new MapStepExecutionDao(); } - @Override + @Override protected JobRepository getJobRepository() { return new SimpleJobRepository(new MapJobInstanceDao(), new MapJobExecutionDao(), new MapStepExecutionDao(), new MapExecutionContextDao()); } - + /** * Modifications to saved entity do not affect the persisted object. */ @@ -37,18 +37,18 @@ public class MapStepExecutionDaoTests extends AbstractStepExecutionDaoTests { StepExecutionDao tested = new MapStepExecutionDao(); JobExecution jobExecution = new JobExecution(77L); StepExecution stepExecution = new StepExecution("stepName", jobExecution); - + assertNull(stepExecution.getEndTime()); tested.saveStepExecution(stepExecution); stepExecution.setEndTime(new Date()); - + StepExecution retrieved = tested.getStepExecution(jobExecution, stepExecution.getId()); assertNull(retrieved.getEndTime()); - + stepExecution.setEndTime(null); tested.updateStepExecution(stepExecution); stepExecution.setEndTime(new Date()); - + StepExecution stored = tested.getStepExecution(jobExecution, stepExecution.getId()); assertNull(stored.getEndTime()); } @@ -56,50 +56,50 @@ public class MapStepExecutionDaoTests extends AbstractStepExecutionDaoTests { @Test public void testAddStepExecutions() { StepExecutionDao tested = new MapStepExecutionDao(); - + JobExecution jobExecution = new JobExecution(88L); - + // Create step execution with status STARTED - StepExecution stepExecution = new StepExecution("Step one", jobExecution); + StepExecution stepExecution = new StepExecution("Step one", jobExecution); stepExecution.setStatus(BatchStatus.STARTED); - + // Save and check id tested.saveStepExecution(stepExecution); assertNotNull(stepExecution.getId()); - - // Job execution instance doesn't contain step execution instances + + // Job execution instance doesn't contain step execution instances assertEquals(0, jobExecution.getStepExecutions().size()); - + // Load all execution steps and check tested.addStepExecutions(jobExecution); assertEquals(1, jobExecution.getStepExecutions().size()); - - // Check the first (and only) step execution instance of the job instance + + // Check the first (and only) step execution instance of the job instance StepExecution jobStepExecution = jobExecution.getStepExecutions().iterator().next(); assertEquals(BatchStatus.STARTED, jobStepExecution.getStatus()); assertEquals(stepExecution.getId(), jobStepExecution.getId()); - - // Load the step execution instance from the repository and check is it the same + + // Load the step execution instance from the repository and check is it the same StepExecution repoStepExecution = tested.getStepExecution(jobExecution, stepExecution.getId()); assertEquals(stepExecution.getId(), repoStepExecution.getId()); assertEquals(BatchStatus.STARTED, repoStepExecution.getStatus()); - + // Update the step execution instance repoStepExecution.setStatus(BatchStatus.COMPLETED); - + // Update the step execution in the repository and check tested.updateStepExecution(repoStepExecution); StepExecution updatedStepExecution = tested.getStepExecution(jobExecution, stepExecution.getId()); assertEquals(stepExecution.getId(), updatedStepExecution.getId()); assertEquals(BatchStatus.COMPLETED, updatedStepExecution.getStatus()); - + // Now, add step executions from the repository and check tested.addStepExecutions(jobExecution); - + jobStepExecution = jobExecution.getStepExecutions().iterator().next(); assertEquals(1, jobExecution.getStepExecutions().size()); assertEquals(stepExecution.getId(), jobStepExecution.getId()); - assertEquals(BatchStatus.COMPLETED, jobStepExecution.getStatus()); + assertEquals(BatchStatus.COMPLETED, jobStepExecution.getStatus()); } - + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/TablePrefixTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/TablePrefixTests.java index 63fba2e36..4e896ae9c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/TablePrefixTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/TablePrefixTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -30,11 +30,11 @@ import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.batch.support.JdbcTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.batch.support.JdbcTestUtils; @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) @@ -62,7 +62,7 @@ public class TablePrefixTests { public static class TestTasklet implements Tasklet { - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return RepeatStatus.FINISHED; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBeanTests.java index 63b075449..68037d135 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/JobRepositoryFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -332,17 +332,17 @@ public class JobRepositoryFactoryBeanTests { private static class StubIncrementer implements DataFieldMaxValueIncrementer { - @Override + @Override public int nextIntValue() throws DataAccessException { return 0; } - @Override + @Override public long nextLongValue() throws DataAccessException { return 0; } - @Override + @Override public String nextStringValue() throws DataAccessException { return null; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryProxyTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryProxyTests.java index c566eb1a8..94ce39d5d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryProxyTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/SimpleJobRepositoryProxyTests.java @@ -20,7 +20,7 @@ import org.springframework.transaction.annotation.Transactional; /** * Repository tests using JDBC DAOs (rather than mocks). - * + * * @author Robert Kasanicky */ @RunWith(SpringJUnit4ClassRunner.class) @@ -58,7 +58,7 @@ public class SimpleJobRepositoryProxyTests { private boolean invoked; - @Override + @Override public Object invoke(MethodInvocation invocation) throws Throwable { invoked = true; return invocation.proceed(); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/Foo.java b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/Foo.java index ba32c20fe..6f6efec71 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/Foo.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/Foo.java @@ -5,19 +5,19 @@ package org.springframework.batch.core.resource; * Simple domain object for testing purposes. */ public class Foo { - + private int id; private String name; private int value; - + public Foo(){} - + public Foo(int id, String name, int value) { this.id = id; this.name = name; this.value = value; } - + public String getName() { return name; } @@ -36,8 +36,8 @@ public class Foo { public void setId(int id) { this.id = id; } - - @Override + + @Override public String toString() { return "Foo[id=" +id +",name=" + name + ",value=" + value + "]"; } @@ -54,24 +54,31 @@ public class Foo { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Foo other = (Foo) obj; - if (id != other.id) - return false; - if (name == null) { - if (other.name != null) - return false; } - else if (!name.equals(other.name)) + if (obj == null) { return false; - if (value != other.value) + } + if (getClass() != obj.getClass()) { return false; + } + Foo other = (Foo) obj; + if (id != other.id) { + return false; + } + if (name == null) { + if (other.name != null) { + return false; + } + } + else if (!name.equals(other.name)) { + return false; + } + if (value != other.value) { + return false; + } return true; } - + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/FooRowMapper.java b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/FooRowMapper.java index e158466b6..983f22135 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/FooRowMapper.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/FooRowMapper.java @@ -6,16 +6,17 @@ import java.sql.SQLException; import org.springframework.jdbc.core.RowMapper; +@SuppressWarnings("rawtypes") public class FooRowMapper implements RowMapper { - @Override - public Object mapRow(ResultSet rs, int rowNum) throws SQLException { + @Override + public Object mapRow(ResultSet rs, int rowNum) throws SQLException { - Foo foo = new Foo(); - foo.setId(rs.getInt(1)); - foo.setName(rs.getString(2)); - foo.setValue(rs.getInt(3)); - - return foo; - } + Foo foo = new Foo(); + foo.setId(rs.getInt(1)); + foo.setName(rs.getString(2)); + foo.setValue(rs.getInt(3)); + + return foo; + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/ListPreparedStatementSetterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/ListPreparedStatementSetterTests.java index 02f1bee8f..cbca871e8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/ListPreparedStatementSetterTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/ListPreparedStatementSetterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -35,20 +35,20 @@ import org.springframework.batch.core.job.AbstractJob; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; /** * @author Lucas Ward - * + * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/org/springframework/batch/core/resource/ListPreparedStatementSetterTests-context.xml", - "/org/springframework/batch/core/repository/dao/data-source-context.xml" }) +"/org/springframework/batch/core/repository/dao/data-source-context.xml" }) public class ListPreparedStatementSetterTests { ListPreparedStatementSetter pss; @@ -88,11 +88,11 @@ public class ListPreparedStatementSetterTests { final List results = new ArrayList(); jdbcTemplate.query("SELECT NAME from T_FOOS where ID > ? and ID < ?", pss, new RowCallbackHandler() { - @Override - public void processRow(ResultSet rs) throws SQLException { - results.add(rs.getString(1)); - } - }); + @Override + public void processRow(ResultSet rs) throws SQLException { + results.add(rs.getString(1)); + } + }); assertEquals(2, results.size()); assertEquals("bar2", results.get(0)); @@ -134,7 +134,7 @@ public class ListPreparedStatementSetterTests { public static class FooStoringItemWriter implements ItemWriter { private List foos = new ArrayList(); - @Override + @Override public void write(List items) throws Exception { foos.addAll(items); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicyTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicyTests.java index f2dd3c9d4..27a1de1ac 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicyTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -31,7 +31,7 @@ import org.springframework.batch.repeat.RepeatContext; /** * Unit tests for {@link StepExecutionSimpleCompletionPolicy} - * + * * @author Dave Syer */ public class StepExecutionSimpleCompletionPolicyTests extends TestCase { @@ -49,7 +49,7 @@ public class StepExecutionSimpleCompletionPolicyTests extends TestCase { * mock step context */ - @Override + @Override protected void setUp() throws Exception { JobParameters jobParameters = new JobParametersBuilder().addLong("commit.interval", 2L).toJobParameters(); @@ -60,7 +60,7 @@ public class StepExecutionSimpleCompletionPolicyTests extends TestCase { policy.beforeStep(stepExecution); } - + public void testToString() throws Exception { String msg = policy.toString(); assertTrue("String does not contain chunk size", msg.indexOf("chunkSize=2")>=0); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/AsyncStepScopeIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/AsyncStepScopeIntegrationTests.java index c0bab53ec..2fa1ca891 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/AsyncStepScopeIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/AsyncStepScopeIntegrationTests.java @@ -45,7 +45,7 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware { private int beanCount; - @Override + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = (ListableBeanFactory) beanFactory; } @@ -81,7 +81,7 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware { final String value = "foo" + i; final Long id = 123L + i; FutureTask task = new FutureTask(new Callable() { - @Override + @Override public String call() throws Exception { StepExecution stepExecution = new StepExecution(value, new JobExecution(0L), id); ExecutionContext executionContext = stepExecution.getExecutionContext(); @@ -121,7 +121,7 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware { for (int i = 0; i < 12; i++) { final String value = "foo" + i; FutureTask task = new FutureTask(new Callable() { - @Override + @Override public String call() throws Exception { ExecutionContext executionContext = stepExecution.getExecutionContext(); executionContext.put("foo", value); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/JobStartupRunner.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/JobStartupRunner.java index dc876e01c..d67b72a15 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/JobStartupRunner.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/JobStartupRunner.java @@ -8,12 +8,12 @@ import org.springframework.beans.factory.InitializingBean; public class JobStartupRunner implements InitializingBean { private Step step; - + public void setStep(Step step) { this.step = step; } - - @Override + + @Override public void afterPropertiesSet() throws Exception { StepExecution stepExecution = new StepExecution("step", new JobExecution(1L), 0L); step.execute(stepExecution); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeClassIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeClassIntegrationTests.java index e32a3b7dc..a007ae5a1 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeClassIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeClassIntegrationTests.java @@ -40,7 +40,7 @@ public class StepScopeClassIntegrationTests implements BeanFactoryAware { private int beanCount; - @Override + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = (ListableBeanFactory) beanFactory; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePerformanceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePerformanceTests.java index 1ed71c1af..e24b20453 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePerformanceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePerformanceTests.java @@ -21,12 +21,12 @@ import org.springframework.util.StopWatch; @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) public class StepScopePerformanceTests implements ApplicationContextAware { - + private Log logger = LogFactory.getLog(getClass()); private ApplicationContext applicationContext; - @Override + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePlaceholderIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePlaceholderIntegrationTests.java index 6a4e16927..79a919ff8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePlaceholderIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopePlaceholderIntegrationTests.java @@ -61,7 +61,7 @@ public class StepScopePlaceholderIntegrationTests implements BeanFactoryAware { private int beanCount; - @Override + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = (ListableBeanFactory) beanFactory; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeProxyTargetClassIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeProxyTargetClassIntegrationTests.java index 67eae4195..a3e0944fb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeProxyTargetClassIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeProxyTargetClassIntegrationTests.java @@ -33,7 +33,7 @@ public class StepScopeProxyTargetClassIntegrationTests implements BeanFactoryAwa private int beanCount; - @Override + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = (ListableBeanFactory) beanFactory; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeTests.java index 43879b4fc..b46166cd0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/StepScopeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -38,8 +38,9 @@ import org.springframework.context.support.StaticApplicationContext; /** * @author Dave Syer - * + * */ +@SuppressWarnings("rawtypes") public class StepScopeTests { private StepScope scope = new StepScope(); @@ -64,7 +65,7 @@ public class StepScopeTests { StepSynchronizationManager.close(); try { scope.get("foo", new ObjectFactory() { - @Override + @Override public Object getObject() throws BeansException { return foo; } @@ -81,7 +82,7 @@ public class StepScopeTests { public void testGetWithNothingAlreadyThere() { final String foo = "bar"; Object value = scope.get("foo", new ObjectFactory() { - @Override + @Override public Object getObject() throws BeansException { return foo; } @@ -94,7 +95,7 @@ public class StepScopeTests { public void testGetWithSomethingAlreadyThere() { context.setAttribute("foo", "bar"); Object value = scope.get("foo", new ObjectFactory() { - @Override + @Override public Object getObject() throws BeansException { return null; } @@ -108,7 +109,7 @@ public class StepScopeTests { context.setAttribute("foo", "bar"); StepContext context = StepSynchronizationManager.register(new StepExecution("bar", new JobExecution(0L))); Object value = scope.get("foo", new ObjectFactory() { - @Override + @Override public Object getObject() throws BeansException { return "spam"; } @@ -137,7 +138,7 @@ public class StepScopeTests { final List list = new ArrayList(); context.setAttribute("foo", "bar"); scope.registerDestructionCallback("foo", new Runnable() { - @Override + @Override public void run() { list.add("foo"); } @@ -154,13 +155,13 @@ public class StepScopeTests { final List list = new ArrayList(); context.setAttribute("foo", "bar"); scope.registerDestructionCallback("foo", new Runnable() { - @Override + @Override public void run() { list.add("foo"); } }); scope.registerDestructionCallback("foo", new Runnable() { - @Override + @Override public void run() { list.add("bar"); } @@ -186,6 +187,7 @@ public class StepScopeTests { assertEquals(11, scope.getOrder()); } + @SuppressWarnings("resource") @Test public void testName() throws Exception { scope.setName("foo"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestCollaborator.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestCollaborator.java index 3de8861c1..3cf7c5759 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestCollaborator.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestCollaborator.java @@ -4,15 +4,16 @@ import java.io.Serializable; import java.util.List; +@SuppressWarnings("serial") public class TestCollaborator implements Collaborator, Serializable { private String name; - + private Collaborator parent; - + private List list; - @Override + @Override public List getList() { return list; } @@ -21,7 +22,7 @@ public class TestCollaborator implements Collaborator, Serializable { this.list = list; } - @Override + @Override public Collaborator getParent() { return parent; } @@ -30,7 +31,7 @@ public class TestCollaborator implements Collaborator, Serializable { this.parent = parent; } - @Override + @Override public String getName() { return name; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestDisposableCollaborator.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestDisposableCollaborator.java index e69f714f3..b801e1337 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestDisposableCollaborator.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestDisposableCollaborator.java @@ -2,11 +2,12 @@ package org.springframework.batch.core.scope; import org.springframework.beans.factory.DisposableBean; +@SuppressWarnings("serial") public class TestDisposableCollaborator extends TestCollaborator implements DisposableBean { public static volatile String message = "none"; - @Override + @Override public void destroy() throws Exception { message = (message.equals("none") ? "" : message + ",") + getName() + ":destroyed"; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestStep.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestStep.java index 3b9768e36..0062d8828 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestStep.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestStep.java @@ -24,7 +24,7 @@ public class TestStep implements Step { context = null; } - @Override + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException { context = StepSynchronizationManager.getContext(); setContextFromCollaborator(); @@ -43,17 +43,17 @@ public class TestStep implements Step { } } - @Override + @Override public String getName() { return "foo"; } - @Override + @Override public int getStartLimit() { return Integer.MAX_VALUE; } - @Override + @Override public boolean isAllowStartIfComplete() { return false; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java index feff5d554..0a9e523c7 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -30,12 +30,11 @@ import org.springframework.batch.core.JobInstance; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.JobParametersBuilder; import org.springframework.batch.core.StepExecution; -import org.springframework.batch.core.scope.context.StepContext; import org.springframework.batch.item.ExecutionContext; /** * @author Dave Syer - * + * */ public class StepContextTests { @@ -81,7 +80,7 @@ public class StepContextTests { public void testDestructionCallbackSunnyDay() throws Exception { context.setAttribute("foo", "FOO"); context.registerDestructionCallback("foo", new Runnable() { - @Override + @Override public void run() { list.add("bar"); } @@ -94,7 +93,7 @@ public class StepContextTests { @Test public void testDestructionCallbackMissingAttribute() throws Exception { context.registerDestructionCallback("foo", new Runnable() { - @Override + @Override public void run() { list.add("bar"); } @@ -110,14 +109,14 @@ public class StepContextTests { context.setAttribute("foo", "FOO"); context.setAttribute("bar", "BAR"); context.registerDestructionCallback("bar", new Runnable() { - @Override + @Override public void run() { list.add("spam"); throw new RuntimeException("fail!"); } }); context.registerDestructionCallback("foo", new Runnable() { - @Override + @Override public void run() { list.add("bar"); throw new RuntimeException("fail!"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepSynchronizationManagerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepSynchronizationManagerTests.java index 1ab6d6d83..188c40e3b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepSynchronizationManagerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/context/StepSynchronizationManagerTests.java @@ -45,7 +45,7 @@ public class StepSynchronizationManagerTests { final List list = new ArrayList(); StepContext context = StepSynchronizationManager.register(stepExecution); context.registerDestructionCallback("foo", new Runnable() { - @Override + @Override public void run() { list.add("foo"); } @@ -70,7 +70,7 @@ public class StepSynchronizationManagerTests { StepContext context = StepSynchronizationManager.register(stepExecution); ExecutorService executorService = Executors.newFixedThreadPool(2); FutureTask task = new FutureTask(new Callable() { - @Override + @Override public StepContext call() throws Exception { try { StepSynchronizationManager.register(stepExecution); @@ -95,7 +95,7 @@ public class StepSynchronizationManagerTests { StepContext context = StepSynchronizationManager.register(stepExecution); final List list = new ArrayList(); context.registerDestructionCallback("foo", new Runnable() { - @Override + @Override public void run() { list.add("foo"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/AsyncPlaceholderTargetSourceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/AsyncPlaceholderTargetSourceTests.java index 874254fba..7ec92fa59 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/AsyncPlaceholderTargetSourceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/AsyncPlaceholderTargetSourceTests.java @@ -47,7 +47,7 @@ public class AsyncPlaceholderTargetSourceTests implements BeanFactoryAware { private int beanCount; - @Override + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = (ListableBeanFactory) beanFactory; } @@ -80,7 +80,7 @@ public class AsyncPlaceholderTargetSourceTests implements BeanFactoryAware { for (int i = 0; i < 12; i++) { final String value = "foo" + i; FutureTask task = new FutureTask(new Callable() { - @Override + @Override public String call() throws Exception { attributes.set(Collections.singletonMap("foo", value)); try { @@ -107,7 +107,7 @@ public class AsyncPlaceholderTargetSourceTests implements BeanFactoryAware { private Object root; - @Override + @Override public Object getContext() { return root; } @@ -132,7 +132,7 @@ public class AsyncPlaceholderTargetSourceTests implements BeanFactoryAware { private Log logger = LogFactory.getLog(getClass()); - @Override + @Override public String getName() { return name; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/ContextFactorySupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/ContextFactorySupport.java index b5ff6793c..d50da3cc0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/ContextFactorySupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/ContextFactorySupport.java @@ -6,20 +6,20 @@ public class ContextFactorySupport implements ContextFactory { /** * Returns this. Override for more sensible behaviour. - * + * * @see org.springframework.batch.core.scope.util.ContextFactory#getContext() */ - @Override + @Override public Object getContext() { return this; } /** * Returns the context plus a counter, so each call is unique. - * + * * @see org.springframework.batch.core.scope.util.ContextFactory#getContextId() */ - @Override + @Override public String getContextId() { return getContext()+"#"+(count ++); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests.java index d1a81fadb..47fd03bd0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -34,7 +34,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Dave Syer - * + * */ @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) @@ -165,13 +165,13 @@ public class MultipleContextPlaceholderTargetSourceTests { public static class TestBean { private String name; - + private TestBean parent; private List names = new ArrayList(); private Map map = new HashMap(); - + public TestBean getParent() { return parent; } @@ -203,14 +203,14 @@ public class MultipleContextPlaceholderTargetSourceTests { public void setMap(Map map) { this.map.putAll(map); } - + } public static class SimpleContextFactory extends ContextFactorySupport { private Object root; - @Override + @Override public Object getContext() { return root; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceCustomEditorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceCustomEditorTests.java index afd7f15eb..3a8c0dd1f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceCustomEditorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceCustomEditorTests.java @@ -22,7 +22,7 @@ public class PlaceholderTargetSourceCustomEditorTests extends ContextFactorySupp private Date date = new Date(1L); - @Override + @Override public Object getContext() { return this; } @@ -49,7 +49,7 @@ public class PlaceholderTargetSourceCustomEditorTests extends ContextFactorySupp public Foo() { } - @Override + @Override public String getName() { return name; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceErrorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceErrorTests.java index 102052aa6..2a9718c5f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceErrorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceErrorTests.java @@ -23,7 +23,7 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport { private Date date = new Date(1L); - @Override + @Override public Object getContext() { return this; } @@ -58,7 +58,7 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport { private PlaceholderTargetSource createValue(String name, String value) throws Exception { String input = IOUtils.toString(new ClassPathResource(getClass().getSimpleName() + "-context.xml", getClass()) - .getInputStream()); + .getInputStream()); input = input.replace("", String.format("", name, value)); Resource resource = new ByteArrayResource(input.getBytes()); GenericApplicationContext context = new GenericApplicationContext(); @@ -108,8 +108,8 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport { @Test public void testPartialReplaceIntegerToString() throws Exception { - Node target = (Node) createValue("name", "foo-%{integer}").getTarget(); - assertEquals("foo-4321", target.getName()); + Node target = (Node) createValue("name", "foo-%{integer}").getTarget(); + assertEquals("foo-4321", target.getName()); } @Test @@ -160,7 +160,7 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport { public Foo() { } - @Override + @Override public long getValue() { return value; } @@ -173,12 +173,12 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport { this.name = name; } - @Override + @Override public String getName() { return name; } - @Override + @Override public Date getDate() { return date; } @@ -191,7 +191,7 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport { this.name = name; } - @Override + @Override public Node getParent() { return parent; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceTests.java index 3e5816f12..a34f7519c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/PlaceholderTargetSourceTests.java @@ -80,7 +80,7 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport { private Date date = new Date(1L); - @Override + @Override public Object getContext() { return this; } @@ -223,9 +223,9 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport { Date getDate(); Node getParent(); - + List getList(); - + Map getMap(); } @@ -236,7 +236,7 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport { private Date date; private Node parent; - + private List list; private Map map; @@ -248,12 +248,12 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport { this.name = name; } - @Override + @Override public String getName() { return name; } - @Override + @Override public Date getDate() { return date; } @@ -266,7 +266,7 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport { this.name = name; } - @Override + @Override public Node getParent() { return parent; } @@ -279,12 +279,12 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport { this.list = list; } - @Override + @Override public List getList() { return list; } - @Override + @Override public Map getMap() { return map; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/SimplePlaceholderTargetSourceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/SimplePlaceholderTargetSourceTests.java index e9a9b218b..720bd7eaa 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/SimplePlaceholderTargetSourceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/SimplePlaceholderTargetSourceTests.java @@ -12,26 +12,26 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) public class SimplePlaceholderTargetSourceTests { - + @Autowired @Qualifier("simple") private Node simple; - + @Autowired private SimpleContextFactory contextFactory; - + @Test public void testGetSimple() { contextFactory.set("bar"); assertEquals("bar", simple.getName()); contextFactory.clear(); } - + public static class SimpleContextFactory extends ContextFactorySupport { private ThreadLocal fooHolder = new ThreadLocal(); - - @Override + + @Override public Object getContext() { return this; } @@ -47,18 +47,18 @@ public class SimplePlaceholderTargetSourceTests { public String getFoo() { return fooHolder.get(); } - + } public static interface Node { String getName(); } - + public static class Foo implements Node { private String name; - - @Override + + @Override public String getName() { return name; } @@ -66,7 +66,7 @@ public class SimplePlaceholderTargetSourceTests { public void setName(String name) { this.name = name; } - + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java index 09f177c38..37fdee424 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -30,7 +30,7 @@ public class JobRepositorySupport implements JobRepository { /* (non-Javadoc) * @see org.springframework.batch.container.common.repository.JobRepository#findOrCreateJob(org.springframework.batch.container.common.domain.JobConfiguration) */ - @Override + @Override public JobExecution createJobExecution(String jobName, JobParameters jobParameters) { JobInstance jobInstance = new JobInstance(0L, jobParameters, jobName); return new JobExecution(jobInstance, 11L); @@ -39,7 +39,7 @@ public class JobRepositorySupport implements JobRepository { /* (non-Javadoc) * @see org.springframework.batch.container.common.repository.JobRepository#saveOrUpdate(org.springframework.batch.container.common.domain.JobExecution) */ - @Override + @Override public void update(JobExecution jobExecution) { } @@ -49,12 +49,12 @@ public class JobRepositorySupport implements JobRepository { public void update(JobInstance job) { } - @Override + @Override public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) { return null; } - @Override + @Override public int getStepExecutionCount(JobInstance jobInstance, String stepName) { return 0; } @@ -67,32 +67,32 @@ public class JobRepositorySupport implements JobRepository { return null; } - @Override + @Override public void add(StepExecution stepExecution) { } - @Override + @Override public void update(StepExecution stepExecution) { } - @Override + @Override public void updateExecutionContext(StepExecution stepExecution) { } /* (non-Javadoc) * @see org.springframework.batch.core.repository.JobRepository#isJobInstanceExists(java.lang.String, org.springframework.batch.core.JobParameters) */ - @Override + @Override public boolean isJobInstanceExists(String jobName, JobParameters jobParameters) { return false; } - @Override + @Override public JobExecution getLastJobExecution(String jobName, JobParameters jobParameters) { return null; } - @Override + @Override public void updateExecutionContext(JobExecution jobExecution) { } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/NonAbstractStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/NonAbstractStepTests.java index 8be90358f..87001db72 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/NonAbstractStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/NonAbstractStepTests.java @@ -4,7 +4,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.List; @@ -51,7 +50,7 @@ public class NonAbstractStepTests { setBeanName("eventTrackingStep"); } - @Override + @Override protected void open(ExecutionContext ctx) throws Exception { events.add("open"); } @@ -63,7 +62,7 @@ public class NonAbstractStepTests { context.setExitStatus(ExitStatus.COMPLETED); } - @Override + @Override protected void close(ExecutionContext ctx) throws Exception { events.add("close"); } @@ -84,7 +83,7 @@ public class NonAbstractStepTests { return name + "#" + event; } - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { assertSame(execution, stepExecution); events.add(getEvent("afterStep(" + stepExecution.getExitStatus().getExitCode() + ")")); @@ -92,7 +91,7 @@ public class NonAbstractStepTests { return stepExecution.getExitStatus(); } - @Override + @Override public void beforeStep(StepExecution stepExecution) { assertSame(execution, stepExecution); events.add(getEvent("beforeStep")); @@ -110,7 +109,7 @@ public class NonAbstractStepTests { static long counter = 0; - @Override + @Override public void updateExecutionContext(StepExecution stepExecution) { Assert.state(stepExecution.getId() != null, "StepExecution must already be saved"); saved = stepExecution.getExecutionContext(); @@ -291,7 +290,7 @@ public class NonAbstractStepTests { } }; repository = new JobRepositoryStub() { - @Override + @Override public void updateExecutionContext(StepExecution stepExecution) { throw new RuntimeException("Bad context!"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/StepLocatorStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/StepLocatorStepFactoryBeanTests.java index 82b617f70..0e5b74734 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/StepLocatorStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/StepLocatorStepFactoryBeanTests.java @@ -1,64 +1,64 @@ package org.springframework.batch.core.step; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.springframework.batch.core.JobInterruptedException; import org.springframework.batch.core.Step; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.job.SimpleJob; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - /** * Tests for StepLocatorStepFactoryBean. - * + * * @author tvaughan */ public class StepLocatorStepFactoryBeanTests { - - @Test - public void testFoo() throws Exception { - Step testStep1 = buildTestStep("foo"); - Step testStep2 = buildTestStep("bar"); - Step testStep3 = buildTestStep("baz"); - - SimpleJob simpleJob = new SimpleJob(); // is a StepLocator - simpleJob.addStep(testStep1); - simpleJob.addStep(testStep2); - simpleJob.addStep(testStep3); - - StepLocatorStepFactoryBean stepLocatorStepFactoryBean = new StepLocatorStepFactoryBean(); - stepLocatorStepFactoryBean.setStepLocator(simpleJob); - stepLocatorStepFactoryBean.setStepName("bar"); - assertEquals(testStep2, stepLocatorStepFactoryBean.getObject()); - } - - private Step buildTestStep(final String stepName) { - return new Step() { - @Override - public String getName() { - return stepName; - } - @Override - public boolean isAllowStartIfComplete() { - throw new UnsupportedOperationException("Not supported yet."); - } + @Test + public void testFoo() throws Exception { + Step testStep1 = buildTestStep("foo"); + Step testStep2 = buildTestStep("bar"); + Step testStep3 = buildTestStep("baz"); - @Override - public int getStartLimit() { - throw new UnsupportedOperationException("Not supported yet."); - } + SimpleJob simpleJob = new SimpleJob(); // is a StepLocator + simpleJob.addStep(testStep1); + simpleJob.addStep(testStep2); + simpleJob.addStep(testStep3); - @Override - public void execute(StepExecution stepExecution) throws JobInterruptedException { - throw new UnsupportedOperationException("Not supported yet."); - } - }; - } - - @Test - public void testGetObjectType() { - assertTrue((new StepLocatorStepFactoryBean()).getObjectType().isAssignableFrom(Step.class)); - } + StepLocatorStepFactoryBean stepLocatorStepFactoryBean = new StepLocatorStepFactoryBean(); + stepLocatorStepFactoryBean.setStepLocator(simpleJob); + stepLocatorStepFactoryBean.setStepName("bar"); + assertEquals(testStep2, stepLocatorStepFactoryBean.getObject()); + } + + private Step buildTestStep(final String stepName) { + return new Step() { + @Override + public String getName() { + return stepName; + } + + @Override + public boolean isAllowStartIfComplete() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getStartLimit() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void execute(StepExecution stepExecution) throws JobInterruptedException { + throw new UnsupportedOperationException("Not supported yet."); + } + }; + } + + @Test + public void testGetObjectType() { + assertTrue((new StepLocatorStepFactoryBean()).getObjectType().isAssignableFrom(Step.class)); + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/StepSupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/StepSupport.java index 5d51a889e..f36816aeb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/StepSupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/StepSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -15,18 +15,18 @@ */ package org.springframework.batch.core.step; -import org.springframework.batch.core.UnexpectedJobExecutionException; import org.springframework.batch.core.JobInterruptedException; import org.springframework.batch.core.Step; import org.springframework.batch.core.StepExecution; +import org.springframework.batch.core.UnexpectedJobExecutionException; import org.springframework.beans.factory.BeanNameAware; /** * Basic no-op support implementation for use as base class for {@link Step}. Implements {@link BeanNameAware} so that * if no name is provided explicitly it will be inferred from the bean definition in Spring configuration. - * + * * @author Dave Syer - * + * */ public class StepSupport implements Step, BeanNameAware { @@ -51,7 +51,7 @@ public class StepSupport implements Step, BeanNameAware { this.name = string; } - @Override + @Override public String getName() { return this.name; } @@ -60,10 +60,10 @@ public class StepSupport implements Step, BeanNameAware { * Set the name property if it is not already set. Because of the order of the callbacks in a Spring container the * name property will be set first if it is present. Care is needed with bean definition inheritance - if a parent * bean has a name, then its children need an explicit name as well, otherwise they will not be unique. - * + * * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String) */ - @Override + @Override public void setBeanName(String name) { if (this.name == null) { this.name = name; @@ -72,35 +72,35 @@ public class StepSupport implements Step, BeanNameAware { /** * Set the name property. Always overrides the default value if this object is a Spring bean. - * + * * @see #setBeanName(java.lang.String) */ public void setName(String name) { this.name = name; } - @Override + @Override public int getStartLimit() { return this.startLimit; } /** * Public setter for the startLimit. - * + * * @param startLimit the startLimit to set */ public void setStartLimit(int startLimit) { this.startLimit = startLimit; } - @Override + @Override public boolean isAllowStartIfComplete() { return this.allowStartIfComplete; } /** * Public setter for the shouldAllowStartIfComplete. - * + * * @param allowStartIfComplete the shouldAllowStartIfComplete to set */ public void setAllowStartIfComplete(boolean allowStartIfComplete) { @@ -109,14 +109,14 @@ public class StepSupport implements Step, BeanNameAware { /** * Not supported but provided so that tests can easily create a step. - * + * * @throws UnsupportedOperationException always - * + * * @see org.springframework.batch.core.Step#execute(org.springframework.batch.core.StepExecution) */ - @Override + @Override public void execute(StepExecution stepExecution) throws JobInterruptedException, UnexpectedJobExecutionException { throw new UnsupportedOperationException( - "Cannot process a StepExecution. Use a smarter subclass of StepSupport."); + "Cannot process a StepExecution. Use a smarter subclass of StepSupport."); } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/StepBuilderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/StepBuilderTests.java index c1830934e..a5ebfca8a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/StepBuilderTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/StepBuilderTests.java @@ -29,7 +29,7 @@ import org.springframework.transaction.PlatformTransactionManager; /** * @author Dave Syer - * + * */ public class StepBuilderTests { @@ -42,7 +42,7 @@ public class StepBuilderTests { PlatformTransactionManager transactionManager = new ResourcelessTransactionManager(); TaskletStepBuilder builder = new StepBuilder("step").repository(jobRepository) .transactionManager(transactionManager).tasklet(new Tasklet() { - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return null; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/BatchRetryTemplateTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/BatchRetryTemplateTests.java index bbc364d4d..31a8e34d6 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/BatchRetryTemplateTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/BatchRetryTemplateTests.java @@ -20,6 +20,7 @@ import org.springframework.retry.support.DefaultRetryState; public class BatchRetryTemplateTests { + @SuppressWarnings("serial") private static class RecoverableException extends Exception { public RecoverableException(String message) { @@ -38,7 +39,7 @@ public class BatchRetryTemplateTests { BatchRetryTemplate template = new BatchRetryTemplate(); String result = template.execute(new RetryCallback() { - @Override + @Override public String doWithRetry(RetryContext context) throws Exception { assertTrue("Wrong context type: " + context.getClass().getSimpleName(), context.getClass() .getSimpleName().contains("Batch")); @@ -56,7 +57,7 @@ public class BatchRetryTemplateTests { BatchRetryTemplate template = new BatchRetryTemplate(); RetryCallback retryCallback = new RetryCallback() { - @Override + @Override public String[] doWithRetry(RetryContext context) throws Exception { assertEquals(count, context.getRetryCount()); if (count++ == 0) { @@ -88,7 +89,7 @@ public class BatchRetryTemplateTests { ., Boolean> singletonMap(Exception.class, true))); RetryCallback retryCallback = new RetryCallback() { - @Override + @Override public String[] doWithRetry(RetryContext context) throws Exception { if (count++ < 2) { throw new RecoverableException("Recoverable"); @@ -118,7 +119,7 @@ public class BatchRetryTemplateTests { ., Boolean> singletonMap(Exception.class, true))); RetryCallback retryCallback = new RetryCallback() { - @Override + @Override public String[] doWithRetry(RetryContext context) throws Exception { if (count++ < 1) { throw new RecoverableException("Recoverable"); @@ -173,7 +174,7 @@ public class BatchRetryTemplateTests { ., Boolean> singletonMap(Exception.class, true))); RetryCallback retryCallback = new RetryCallback() { - @Override + @Override public String[] doWithRetry(RetryContext context) throws Exception { if (count++ < 2) { throw new RecoverableException("Recoverable"); @@ -183,7 +184,7 @@ public class BatchRetryTemplateTests { }; RecoveryCallback recoveryCallback = new RecoveryCallback() { - @Override + @Override public String[] recover(RetryContext context) throws Exception { List recovered = new ArrayList(); for (String item : outputs) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java index bc1cb91c2..13fd1c23a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -29,12 +29,12 @@ import org.springframework.batch.item.UnexpectedInputException; /** * @author Dave Syer - * + * */ public class ChunkMonitorTests { /** - * + * */ private static final int CHUNK_SIZE = 5; @@ -47,7 +47,7 @@ public class ChunkMonitorTests { @Before public void setUp() { monitor.setItemReader(new ItemReader() { - @Override + @Override public String read() throws Exception, UnexpectedInputException, ParseException { return "" + (count++); } @@ -110,7 +110,7 @@ public class ChunkMonitorTests { @Test(expected = ItemStreamException.class) public void testOpenWithErrorInReader() { monitor.setItemReader(new ItemReader() { - @Override + @Override public String read() throws Exception, UnexpectedInputException, ParseException { throw new IllegalStateException("Expected"); } @@ -140,7 +140,7 @@ public class ChunkMonitorTests { public void testUpdateWithNoStream() throws Exception { monitor = new ChunkMonitor(); monitor.setItemReader(new ItemReader() { - @Override + @Override public String read() throws Exception, UnexpectedInputException, ParseException { return "" + (count++); } @@ -149,6 +149,6 @@ public class ChunkMonitorTests { monitor.incrementOffset(); ExecutionContext executionContext = new ExecutionContext(); monitor.update(executionContext); - assertEquals(0, executionContext.size()); + assertEquals(0, executionContext.size()); } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkOrientedTaskletTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkOrientedTaskletTests.java index 7162aef58..348234a0f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkOrientedTaskletTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkOrientedTaskletTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -29,7 +29,7 @@ import org.springframework.batch.core.scope.context.ChunkContext; /** * @author Dave Syer - * + * */ public class ChunkOrientedTaskletTests { @@ -38,17 +38,17 @@ public class ChunkOrientedTaskletTests { @Test public void testHandle() throws Exception { ChunkOrientedTasklet handler = new ChunkOrientedTasklet(new ChunkProvider() { - @Override + @Override public Chunk provide(StepContribution contribution) throws Exception { contribution.incrementReadCount(); Chunk chunk = new Chunk(); chunk.add("foo"); return chunk; } - @Override + @Override public void postProcess(StepContribution contribution, Chunk chunk) {}; }, new ChunkProcessor() { - @Override + @Override public void process(StepContribution contribution, Chunk chunk) { contribution.incrementWriteCount(1); } @@ -64,14 +64,14 @@ public class ChunkOrientedTaskletTests { @Test public void testFail() throws Exception { ChunkOrientedTasklet handler = new ChunkOrientedTasklet(new ChunkProvider() { - @Override + @Override public Chunk provide(StepContribution contribution) throws Exception { throw new RuntimeException("Foo!"); } - @Override + @Override public void postProcess(StepContribution contribution, Chunk chunk) {}; }, new ChunkProcessor() { - @Override + @Override public void process(StepContribution contribution, Chunk chunk) { fail("Not expecting to get this far"); } @@ -91,7 +91,7 @@ public class ChunkOrientedTaskletTests { @Test public void testExitCode() throws Exception { ChunkOrientedTasklet handler = new ChunkOrientedTasklet(new ChunkProvider() { - @Override + @Override public Chunk provide(StepContribution contribution) throws Exception { contribution.incrementReadCount(); Chunk chunk = new Chunk(); @@ -99,10 +99,10 @@ public class ChunkOrientedTaskletTests { chunk.setEnd(); return chunk; } - @Override + @Override public void postProcess(StepContribution contribution, Chunk chunk) {}; }, new ChunkProcessor() { - @Override + @Override public void process(StepContribution contribution, Chunk chunk) { contribution.incrementWriteCount(1); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ExceptionThrowingTaskletStub.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ExceptionThrowingTaskletStub.java index 90426e278..c0fc4550a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ExceptionThrowingTaskletStub.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ExceptionThrowingTaskletStub.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -31,7 +31,7 @@ import org.springframework.batch.support.transaction.TransactionAwareProxyFactor * @since 2.0.2 */ public class ExceptionThrowingTaskletStub implements Tasklet { - + private int maxTries = 4; protected Log logger = LogFactory.getLog(getClass()); @@ -56,7 +56,7 @@ public class ExceptionThrowingTaskletStub implements Tasklet { committed.clear(); } - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { committed.add(1); if (committed.size()>=maxTries) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessorTests.java index 39e40ff8c..e94bcbf72 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessorTests.java @@ -47,7 +47,7 @@ public class FaultTolerantChunkProcessorTests { processor = new FaultTolerantChunkProcessor( new PassThroughItemProcessor(), new ItemWriter() { - @Override + @Override public void write(List items) throws Exception { if (items.contains("fail")) { @@ -69,7 +69,7 @@ public class FaultTolerantChunkProcessorTests { @Test public void testTransform() throws Exception { processor.setItemProcessor(new ItemProcessor() { - @Override + @Override public String process(String item) throws Exception { return item.equals("1") ? null : item; } @@ -84,7 +84,7 @@ public class FaultTolerantChunkProcessorTests { public void testFilterCountOnSkip() throws Exception { processor.setProcessSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemProcessor(new ItemProcessor() { - @Override + @Override public String process(String item) throws Exception { if (item.equals("1")) { throw new RuntimeException("Skippable"); @@ -110,14 +110,14 @@ public class FaultTolerantChunkProcessorTests { /** * An Error can be retried or skipped but by default it is just propagated - * + * * @throws Exception */ @Test public void testWriteSkipOnError() throws Exception { processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemWriter(new ItemWriter() { - @Override + @Override public void write(List items) throws Exception { if (items.contains("fail")) { assertFalse("Expected Error!", true); @@ -139,7 +139,7 @@ public class FaultTolerantChunkProcessorTests { public void testWriteSkipOnException() throws Exception { processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemWriter(new ItemWriter() { - @Override + @Override public void write(List items) throws Exception { if (items.contains("fail")) { throw new RuntimeException("Expected Exception!"); @@ -170,7 +170,7 @@ public class FaultTolerantChunkProcessorTests { public void testWriteSkipOnExceptionWithTrivialChunk() throws Exception { processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemWriter(new ItemWriter() { - @Override + @Override public void write(List items) throws Exception { if (items.contains("fail")) { throw new RuntimeException("Expected Exception!"); @@ -201,19 +201,20 @@ public class FaultTolerantChunkProcessorTests { @Test public void testTransformWithExceptionAndNoRollback() throws Exception { processor.setItemProcessor(new ItemProcessor() { - @Override + @Override public String process(String item) throws Exception { - if (item.equals("1")) + if (item.equals("1")) { throw new DataIntegrityViolationException("Planned"); + } return item; } }); processor.setProcessSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor - .setRollbackClassifier(new BinaryExceptionClassifier( - Collections - .> singleton(DataIntegrityViolationException.class), - false)); + .setRollbackClassifier(new BinaryExceptionClassifier( + Collections + .> singleton(DataIntegrityViolationException.class), + false)); Chunk inputs = new Chunk(Arrays.asList("1", "2")); processor.process(contribution, inputs); assertEquals(1, list.size()); @@ -252,7 +253,7 @@ public class FaultTolerantChunkProcessorTests { processor = new FaultTolerantChunkProcessor( new PassThroughItemProcessor(), new ItemWriter() { - @Override + @Override public void write(List items) throws Exception { // Fail if there is more than one item @@ -306,7 +307,7 @@ public class FaultTolerantChunkProcessorTests { processor = new FaultTolerantChunkProcessor( new PassThroughItemProcessor(), new ItemWriter() { - @Override + @Override public void write(List items) throws Exception { // Always fail in writer @@ -337,7 +338,7 @@ public class FaultTolerantChunkProcessorTests { batchRetryTemplate.setRetryPolicy(retryPolicy); processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemWriter(new ItemWriter() { - @Override + @Override public void write(List items) throws Exception { if (items.contains("fail")) { throw new IllegalArgumentException("Expected Exception!"); @@ -382,7 +383,7 @@ public class FaultTolerantChunkProcessorTests { batchRetryTemplate.setRetryPolicy(retryPolicy); processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemWriter(new ItemWriter() { - @Override + @Override public void write(List items) throws Exception { if (items.contains("fail")) { throw new IllegalArgumentException("Expected Exception!"); @@ -437,7 +438,7 @@ public class FaultTolerantChunkProcessorTests { Collections., Boolean> singletonMap( IllegalArgumentException.class, true))); processor.setItemWriter(new ItemWriter() { - @Override + @Override public void write(List items) throws Exception { if (items.contains("fail")) { throw new IllegalArgumentException("Expected Exception!"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProviderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProviderTests.java index db4f78de9..372dd1e46 100755 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProviderTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProviderTests.java @@ -38,7 +38,7 @@ public class FaultTolerantChunkProviderTests { @Test public void testProvideWithOverflow() throws Exception { provider = new FaultTolerantChunkProvider(new ItemReader() { - @Override + @Override public String read() throws Exception, UnexpectedInputException, ParseException { throw new RuntimeException("Planned"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantExceptionClassesTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantExceptionClassesTests.java index 9b83c871f..12760b2be 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantExceptionClassesTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantExceptionClassesTests.java @@ -51,7 +51,7 @@ public class FaultTolerantExceptionClassesTests implements ApplicationContextAwa private ApplicationContext applicationContext; - @Override + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } @@ -292,9 +292,9 @@ public class FaultTolerantExceptionClassesTests implements ApplicationContextAwa writer.setExceptionType(FatalRuntimeException.class); StepExecution stepExecution = launchStep("noRollbackFatal"); assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus()); - // BATCH-1331: + // BATCH-1331: assertEquals("[1, 2, 3, 1, 2, 3, 4]", writer.getWritten().toString()); - // BATCH-1331: + // BATCH-1331: assertEquals("[1, 2, 3, 4]", writer.getCommitted().toString()); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java index d75dd7e13..d6d97e0ea 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java @@ -133,7 +133,7 @@ public class FaultTolerantStepFactoryBeanNonBufferingTests { this.failures = failures; } - @Override + @Override public void write(List items) throws Exception { logger.debug("Writing: " + items); for (String item : items) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java index 3a4d7a93c..d8c163123 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -62,7 +62,7 @@ import org.springframework.util.StringUtils; /** * @author Dave Syer - * + * */ public class FaultTolerantStepFactoryBeanRetryTests { @@ -90,7 +90,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { JobExecution jobExecution; private ItemWriter writer = new ItemWriter() { - @Override + @Override public void write(List data) throws Exception { processed.addAll(data); } @@ -141,7 +141,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setJobRepository(repository); factory.setTransactionManager(new ResourcelessTransactionManager()); ItemWriter failingWriter = new ItemWriter() { - @Override + @Override public void write(List data) throws Exception { int count = 0; for (Integer item : data) { @@ -154,7 +154,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { }; ItemProcessor processor = new ItemProcessor() { - @Override + @Override public Integer process(String item) throws Exception { processed.add(item); return Integer.parseInt(item); @@ -178,11 +178,11 @@ public class FaultTolerantStepFactoryBeanRetryTests { jobExecution); repository.add(stepExecution); step.execute(stepExecution); -// System.out.println(stepExecution.getWriteCount()); -// System.out.println(stepExecution.getSkipCount()); -// System.out.println(processed.size()); -// System.out.println(processed); -// System.out.println(written); + // System.out.println(stepExecution.getWriteCount()); + // System.out.println(stepExecution.getSkipCount()); + // System.out.println(processed.size()); + // System.out.println(processed); + // System.out.println(written); /* * Each chunk tried up to RETRY_LIMIT, then the scan processes each item * once, identfiying the skip as it goes @@ -195,7 +195,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { final int RETRY_LIMIT = 3; final List ITEM_LIST = Arrays.asList("a", "b", "c"); ItemWriter failingWriter = new ItemWriter() { - @Override + @Override public void write(List data) throws Exception { int count = 0; for (String item : data) { @@ -208,7 +208,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { }; ItemProcessor processor = new ItemProcessor() { - @Override + @Override public String process(String item) throws Exception { processed.add(item); return item; @@ -244,7 +244,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { public void testNoItemsReprocessedWhenErrorInWriterAndProcessorNotTransactional() throws Exception { ItemWriter failingWriter = new ItemWriter() { - @Override + @Override public void write(List data) throws Exception { int count = 0; for (String item : data) { @@ -257,7 +257,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { }; ItemProcessor processor = new ItemProcessor() { - @Override + @Override public String process(String item) throws Exception { processed.add(item); return item; @@ -290,7 +290,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { * failures, but it does test that read errors are re-presented for another * try when the retryLimit is high enough (it is used to build an exception * handler). - * + * * @throws Exception */ @SuppressWarnings("unchecked") @@ -298,7 +298,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { public void testSuccessfulRetryWithReadFailure() throws Exception { ItemReader provider = new ListItemReader(Arrays.asList( "a", "b", "c")) { - @Override + @Override public String read() { String item = super.read(); provided.add(item); @@ -363,7 +363,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setItemReader(reader); factory.setStreams(new ItemStream[] { reader }); factory.setItemWriter(new ItemWriter() { - @Override + @Override public void write(List items) throws Exception { if (fail && items.contains("e")) { throw new RuntimeException("Planned failure"); @@ -402,7 +402,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setSkipLimit(2); ItemReader provider = new ListItemReader(Arrays.asList( "a", "b", "c", "d", "e", "f")) { - @Override + @Override public String read() { String item = super.read(); count++; @@ -433,7 +433,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { public void testSkipAndRetryWithWriteFailure() throws Exception { factory.setListeners(new StepListener[] { new SkipListenerSupport() { - @Override + @Override public void onSkipInWrite(String item, Throwable t) { recovered.add(item); assertTrue(TransactionSynchronizationManager @@ -443,7 +443,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setSkipLimit(2); ItemReader provider = new ListItemReader(Arrays.asList( "a", "b", "c", "d", "e", "f")) { - @Override + @Override public String read() { String item = super.read(); logger.debug("Read Called! Item: [" + item + "]"); @@ -454,7 +454,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { }; ItemWriter itemWriter = new ItemWriter() { - @Override + @Override public void write(List item) throws Exception { logger.debug("Write Called! Item: [" + item + "]"); processed.addAll(item); @@ -497,7 +497,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setCommitInterval(3); factory.setListeners(new StepListener[] { new SkipListenerSupport() { - @Override + @Override public void onSkipInWrite(String item, Throwable t) { recovered.add(item); assertTrue(TransactionSynchronizationManager @@ -507,7 +507,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setSkipLimit(2); ItemReader provider = new ListItemReader(Arrays.asList( "a", "b", "c", "d", "e", "f")) { - @Override + @Override public String read() { String item = super.read(); logger.debug("Read Called! Item: [" + item + "]"); @@ -518,7 +518,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { }; ItemWriter itemWriter = new ItemWriter() { - @Override + @Override public void write(List item) throws Exception { logger.debug("Write Called! Item: [" + item + "]"); processed.addAll(item); @@ -565,7 +565,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setSkipLimit(0); ItemReader provider = new ListItemReader( Arrays.asList("b")) { - @Override + @Override public String read() { String item = super.read(); provided.add(item); @@ -574,7 +574,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { } }; ItemWriter itemWriter = new ItemWriter() { - @Override + @Override public void write(List item) throws Exception { processed.addAll(item); written.addAll(item); @@ -620,7 +620,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setSkipLimit(1); ItemReader provider = new ListItemReader( Arrays.asList("b")) { - @Override + @Override public String read() { String item = super.read(); provided.add(item); @@ -629,7 +629,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { } }; ItemWriter itemWriter = new ItemWriter() { - @Override + @Override public void write(List item) throws Exception { processed.addAll(item); written.addAll(item); @@ -673,7 +673,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setSkipLimit(0); ItemReader provider = new ListItemReader( Arrays.asList("b")) { - @Override + @Override public String read() { String item = super.read(); provided.add(item); @@ -682,7 +682,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { } }; ItemWriter itemWriter = new ItemWriter() { - @Override + @Override public void write(List item) throws Exception { processed.addAll(item); written.addAll(item); @@ -723,7 +723,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { // set the cache limit stupidly low factory.setRetryContextCache(new MapRetryContextCache(0)); ItemReader provider = new ItemReader() { - @Override + @Override public String read() { String item = "" + count; provided.add(item); @@ -736,7 +736,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { } }; ItemWriter itemWriter = new ItemWriter() { - @Override + @Override public void write(List item) throws Exception { processed.addAll(item); logger.debug("Write Called! Item: [" + item + "]"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java index 8c9351850..bf646e3fb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRollbackTests.java @@ -107,32 +107,32 @@ public class FaultTolerantStepFactoryBeanRollbackTests { writer = null; factory = null; } - + @Test public void testBeforeChunkListenerException() throws Exception{ factory.setListeners(new StepListener []{new ExceptionThrowingChunkListener(true)}); Step step = (Step) factory.getObject(); step.execute(stepExecution); assertEquals(FAILED, stepExecution.getStatus()); - assertEquals(FAILED.toString(), stepExecution.getExitStatus().getExitCode()); + assertEquals(FAILED.toString(), stepExecution.getExitStatus().getExitCode()); assertTrue(stepExecution.getCommitCount() == 0);//Make sure exception was thrown in after, not before Throwable e = stepExecution.getFailureExceptions().get(0); assertThat(e, instanceOf(FatalStepExecutionException.class)); assertThat(e.getCause(), instanceOf(IllegalArgumentException.class)); } - + @Test public void testAfterChunkListenerException() throws Exception{ factory.setListeners(new StepListener []{new ExceptionThrowingChunkListener(false)}); Step step = (Step) factory.getObject(); step.execute(stepExecution); assertEquals(FAILED, stepExecution.getStatus()); - assertEquals(FAILED.toString(), stepExecution.getExitStatus().getExitCode()); + assertEquals(FAILED.toString(), stepExecution.getExitStatus().getExitCode()); assertTrue(stepExecution.getCommitCount() > 0);//Make sure exception was thrown in after, not before Throwable e = stepExecution.getFailureExceptions().get(0); assertThat(e, instanceOf(FatalStepExecutionException.class)); assertThat(e.getCause(), instanceOf(IllegalArgumentException.class)); - } + } @Test public void testOverrideWithoutChangingRollbackRules() throws Exception { @@ -587,7 +587,7 @@ public class FaultTolerantStepFactoryBeanRollbackTests { } return map; } - + class ExceptionThrowingChunkListener implements ChunkListener{ private boolean throwBefore = true; @@ -595,18 +595,18 @@ public class FaultTolerantStepFactoryBeanRollbackTests { public ExceptionThrowingChunkListener(boolean throwBefore) { this.throwBefore = throwBefore; } - - @Override + + @Override public void beforeChunk() { if(throwBefore){ throw new IllegalArgumentException("Planned exception"); } } - @Override + @Override public void afterChunk() { throw new IllegalArgumentException("Planned exception"); - + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java index dcfb795a5..84c4c0a02 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java @@ -105,7 +105,7 @@ public class FaultTolerantStepFactoryBeanTests { factory.setSkipLimit(2); factory - .setSkippableExceptionClasses(getExceptionMap(SkippableException.class, SkippableRuntimeException.class)); + .setSkippableExceptionClasses(getExceptionMap(SkippableException.class, SkippableRuntimeException.class)); MapJobRepositoryFactoryBean repositoryFactory = new MapJobRepositoryFactoryBean(); repositoryFactory.afterPropertiesSet(); @@ -119,7 +119,7 @@ public class FaultTolerantStepFactoryBeanTests { /** * Non-skippable (and non-fatal) exception causes failure immediately. - * + * * @throws Exception */ @SuppressWarnings("unchecked") @@ -214,7 +214,7 @@ public class FaultTolerantStepFactoryBeanTests { factory.setSkipLimit(0); factory.setSkipPolicy(new SkipPolicy() { - @Override + @Override public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException { throw new RuntimeException("Planned exception in SkipPolicy"); } @@ -225,7 +225,7 @@ public class FaultTolerantStepFactoryBeanTests { Step step = (Step) factory.getObject(); step.execute(stepExecution); - + assertEquals(BatchStatus.FAILED, stepExecution.getStatus()); assertEquals(0, stepExecution.getReadSkipCount()); assertEquals(1, stepExecution.getReadCount()); @@ -242,7 +242,7 @@ public class FaultTolerantStepFactoryBeanTests { factory.setSkipLimit(0); factory.setSkipPolicy(new SkipPolicy() { - @Override + @Override public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException { throw new RuntimeException("Planned exception in SkipPolicy"); } @@ -253,7 +253,7 @@ public class FaultTolerantStepFactoryBeanTests { Step step = (Step) factory.getObject(); step.execute(stepExecution); - + assertEquals(BatchStatus.FAILED, stepExecution.getStatus()); assertEquals(0, stepExecution.getWriteSkipCount()); assertEquals(2, stepExecution.getReadCount()); @@ -422,7 +422,7 @@ public class FaultTolerantStepFactoryBeanTests { map.put(FatalRuntimeException.class, false); factory.setSkippableExceptionClasses(map); factory.setItemWriter(new ItemWriter() { - @Override + @Override public void write(List items) { throw new FatalRuntimeException("Ouch!"); } @@ -735,73 +735,73 @@ public class FaultTolerantStepFactoryBeanTests { final List listenerCalls = new ArrayList(); class TestItemListenerWriter implements ItemWriter, ItemReadListener, - ItemWriteListener, ItemProcessListener, SkipListener, - ChunkListener { - @Override + ItemWriteListener, ItemProcessListener, SkipListener, + ChunkListener { + @Override public void write(List items) throws Exception { if (items.contains("4")) { throw new SkippableException("skippable"); } } - @Override + @Override public void afterRead(String item) { listenerCalls.add(1); } - @Override + @Override public void beforeRead() { } - @Override + @Override public void onReadError(Exception ex) { } - @Override + @Override public void afterWrite(List items) { listenerCalls.add(2); } - @Override + @Override public void beforeWrite(List items) { } - @Override + @Override public void onWriteError(Exception exception, List items) { } - @Override + @Override public void afterProcess(String item, String result) { listenerCalls.add(3); } - @Override + @Override public void beforeProcess(String item) { } - @Override + @Override public void onProcessError(String item, Exception e) { } - @Override + @Override public void afterChunk() { listenerCalls.add(4); } - @Override + @Override public void beforeChunk() { } - @Override + @Override public void onSkipInProcess(String item, Throwable t) { } - @Override + @Override public void onSkipInRead(Throwable t) { listenerCalls.add(6); } - @Override + @Override public void onSkipInWrite(String item, Throwable t) { listenerCalls.add(5); } @@ -827,21 +827,21 @@ public class FaultTolerantStepFactoryBeanTests { writer.setFailures("4"); ItemStreamReader reader = new ItemStreamReader() { - @Override + @Override public void close() throws ItemStreamException { closed = true; } - @Override + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { opened = true; } - @Override + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { } - @Override + @Override public String read() throws Exception, UnexpectedInputException, ParseException { return null; } @@ -867,40 +867,40 @@ public class FaultTolerantStepFactoryBeanTests { writer.setFailures("4"); ItemStreamReader reader = new ItemStreamReader() { - @Override + @Override public void close() throws ItemStreamException { } - @Override + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { } - @Override + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { } - @Override + @Override public String read() throws Exception, UnexpectedInputException, ParseException { return null; } }; ItemStreamReader stream = new ItemStreamReader() { - @Override + @Override public void close() throws ItemStreamException { closed = true; } - @Override + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { opened = true; } - @Override + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { } - @Override + @Override public String read() throws Exception, UnexpectedInputException, ParseException { return null; } @@ -927,21 +927,21 @@ public class FaultTolerantStepFactoryBeanTests { writer.setFailures("4"); ItemStreamReader reader = new ItemStreamReader() { - @Override + @Override public void close() throws ItemStreamException { closed = true; } - @Override + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { opened = true; } - @Override + @Override public void update(ExecutionContext executionContext) throws ItemStreamException { } - @Override + @Override public String read() throws Exception, UnexpectedInputException, ParseException { return null; } @@ -951,7 +951,7 @@ public class FaultTolerantStepFactoryBeanTests { proxy.setTarget(reader); proxy.setInterfaces(new Class[] { ItemReader.class, ItemStream.class }); proxy.addAdvice(new MethodInterceptor() { - @Override + @Override public Object invoke(MethodInvocation invocation) throws Throwable { return invocation.proceed(); } @@ -974,19 +974,19 @@ public class FaultTolerantStepFactoryBeanTests { private boolean filterEncountered = false; - @Override + @Override public void afterProcess(T item, S result) { if (result == null) { filterEncountered = true; } } - @Override + @Override public void beforeProcess(T item) { } - @Override + @Override public void onProcessError(T item, Exception e) { } @@ -1017,7 +1017,7 @@ public class FaultTolerantStepFactoryBeanTests { /** * condition: skippable < fatal; exception is unclassified - * + * * expected: false; default classification */ @Test @@ -1027,7 +1027,7 @@ public class FaultTolerantStepFactoryBeanTests { /** * condition: skippable < fatal; exception is skippable - * + * * expected: true */ @Test @@ -1037,7 +1037,7 @@ public class FaultTolerantStepFactoryBeanTests { /** * condition: skippable < fatal; exception is fatal - * + * * expected: false */ @Test @@ -1047,7 +1047,7 @@ public class FaultTolerantStepFactoryBeanTests { /** * condition: fatal < skippable; exception is unclassified - * + * * expected: false; default classification */ @Test @@ -1057,7 +1057,7 @@ public class FaultTolerantStepFactoryBeanTests { /** * condition: fatal < skippable; exception is skippable - * + * * expected: true */ @Test @@ -1067,7 +1067,7 @@ public class FaultTolerantStepFactoryBeanTests { /** * condition: fatal < skippable; exception is fatal - * + * * expected: false */ @Test @@ -1091,6 +1091,7 @@ public class FaultTolerantStepFactoryBeanTests { return getSkipPolicy(factory); } + @SuppressWarnings("rawtypes") private SkipPolicy getSkipPolicy(FactoryBean factory) throws Exception { Object step = factory.getObject(); Object tasklet = ReflectionTestUtils.getField(step, "tasklet"); @@ -1105,9 +1106,10 @@ public class FaultTolerantStepFactoryBeanTests { } return map; } - + + @SuppressWarnings("serial") public static class NonExistentException extends Exception { - + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java index 3b7ef3a34..7aed2fe90 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanUnexpectedRollbackTests.java @@ -36,7 +36,7 @@ import org.springframework.transaction.support.DefaultTransactionStatus; public class FaultTolerantStepFactoryBeanUnexpectedRollbackTests { protected final Log logger = LogFactory.getLog(getClass()); - + @Autowired private DataSource dataSource; @@ -47,9 +47,10 @@ public class FaultTolerantStepFactoryBeanUnexpectedRollbackTests { FaultTolerantStepFactoryBean factory = new FaultTolerantStepFactoryBean(); factory.setItemWriter(writer); + @SuppressWarnings("serial") DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource) { private boolean failed = false; - @Override + @Override protected void doCommit(DefaultTransactionStatus status) throws TransactionException { if (writer.getWritten().isEmpty() || failed || !isExistingTransaction(status.getTransaction())) { super.doCommit(status); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBeanTests.java index 3473c3ede..1bf9b97b7 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/RepeatOperationsStepFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -36,7 +36,7 @@ import org.springframework.batch.support.transaction.ResourcelessTransactionMana /** * @author Dave Syer - * + * */ public class RepeatOperationsStepFactoryBeanTests extends TestCase { @@ -46,7 +46,7 @@ public class RepeatOperationsStepFactoryBeanTests extends TestCase { private JobExecution jobExecution = new JobExecution(new JobInstance(0L, new JobParameters(), "job")); - @Override + @Override protected void setUp() throws Exception { factory.setBeanName("RepeatOperationsStep"); factory.setItemReader(new ListItemReader(new ArrayList())); @@ -72,7 +72,7 @@ public class RepeatOperationsStepFactoryBeanTests extends TestCase { factory.setStepOperations(new RepeatOperations() { - @Override + @Override public RepeatStatus iterate(RepeatCallback callback) { list = new ArrayList(); list.add("foo"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProcessorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProcessorTests.java index 0cb637fad..545936915 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProcessorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProcessorTests.java @@ -20,7 +20,7 @@ public class SimpleChunkProcessorTests { private SimpleChunkProcessor processor = new SimpleChunkProcessor( new ItemProcessor() { - @Override + @Override public String process(String item) throws Exception { if (item.equals("err")) { return null; @@ -28,7 +28,7 @@ public class SimpleChunkProcessorTests { return item; } }, new ItemWriter() { - @Override + @Override public void write(List items) throws Exception { if (items.contains("fail")) { throw new RuntimeException("Planned failure!"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandlerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandlerTests.java index 8a42b4b39..b4e3df0ec 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandlerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleRetryExceptionHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -31,7 +31,7 @@ import org.springframework.retry.policy.NeverRetryPolicy; /** * @author Dave Syer - * + * */ public class SimpleRetryExceptionHandlerTests extends TestCase { @@ -39,20 +39,20 @@ public class SimpleRetryExceptionHandlerTests extends TestCase { /* * (non-Javadoc) - * + * * @see junit.framework.TestCase#setUp() */ - @Override + @Override protected void setUp() throws Exception { RepeatSynchronizationManager.register(context); } /* * (non-Javadoc) - * + * * @see junit.framework.TestCase#tearDown() */ - @Override + @Override protected void tearDown() throws Exception { RepeatSynchronizationManager.clear(); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java index 745f69ceb..d362bff4f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -70,7 +70,7 @@ public class SimpleStepFactoryBeanTests { private List written = new ArrayList(); private ItemWriter writer = new ItemWriter() { - @Override + @Override public void write(List data) throws Exception { written.addAll(data); } @@ -135,7 +135,7 @@ public class SimpleStepFactoryBeanTests { SimpleStepFactoryBean factory = getStepFactory(new String[] { "foo", "bar", "spam" }); factory.setItemWriter(new ItemWriter() { - @Override + @Override public void write(List data) throws Exception { throw new RuntimeException("Error!"); } @@ -173,7 +173,7 @@ public class SimpleStepFactoryBeanTests { SimpleStepFactoryBean factory = getStepFactory(new String[] { "foo", "bar", "spam" }); factory.setBeanName("exceptionStep"); factory.setItemWriter(new ItemWriter() { - @Override + @Override public void write(List data) throws Exception { throw new RuntimeException("Foo"); } @@ -198,7 +198,7 @@ public class SimpleStepFactoryBeanTests { factory.setItemWriter(new ItemWriter() { int count = 0; - @Override + @Override public void write(List data) throws Exception { if (count++ == 0) { throw new RuntimeException("Foo"); @@ -248,13 +248,13 @@ public class SimpleStepFactoryBeanTests { this.writeListener = writeListener; } - @Override + @Override public void afterChunk() { writeListener.trail = writeListener.trail + "4"; afterCount++; } - @Override + @Override public void beforeChunk() { writeListener.trail = writeListener.trail + "1"; beforeCount++; @@ -334,61 +334,61 @@ public class SimpleStepFactoryBeanTests { final List listenerCalls = new ArrayList(); class TestItemListenerWriter implements ItemWriter, ItemProcessor, - ItemReadListener, ItemWriteListener, ItemProcessListener, ChunkListener { - @Override + ItemReadListener, ItemWriteListener, ItemProcessListener, ChunkListener { + @Override public void write(List items) throws Exception { } - @Override + @Override public String process(String item) throws Exception { return item; } - @Override + @Override public void afterRead(String item) { listenerCalls.add("read"); } - @Override + @Override public void beforeRead() { } - @Override + @Override public void onReadError(Exception ex) { } - @Override + @Override public void afterWrite(List items) { listenerCalls.add("write"); } - @Override + @Override public void beforeWrite(List items) { } - @Override + @Override public void onWriteError(Exception exception, List items) { } - @Override + @Override public void afterProcess(String item, String result) { listenerCalls.add("process"); } - @Override + @Override public void beforeProcess(String item) { } - @Override + @Override public void onProcessError(String item, Exception e) { } - @Override + @Override public void afterChunk() { listenerCalls.add("chunk"); } - @Override + @Override public void beforeChunk() { } @@ -420,20 +420,20 @@ public class SimpleStepFactoryBeanTests { final List listenerCalls = new ArrayList(); class TestItemListenerWriter implements ItemWriter, ItemWriteListener { - @Override + @Override public void write(List items) throws Exception { } - @Override + @Override public void afterWrite(List items) { listenerCalls.add("write"); } - @Override + @Override public void beforeWrite(List items) { } - @Override + @Override public void onWriteError(Exception exception, List items) { } @@ -462,7 +462,7 @@ public class SimpleStepFactoryBeanTests { SimpleStepFactoryBean factory = getStepFactory(new String[] { "foo", "bar", "spam" }); factory.setItemWriter(null); factory.setItemProcessor(new ItemProcessor() { - @Override + @Override public String process(String item) throws Exception { written.add(item); return null; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipProcessorStub.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipProcessorStub.java index 4cb401854..195d4de09 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipProcessorStub.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipProcessorStub.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -55,7 +55,7 @@ public class SkipProcessorStub extends AbstractExceptionThrowingItemHandlerSt filter = false; } - @Override + @Override public T process(T item) throws Exception { processed.add(item); committed.add(item); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipReaderStub.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipReaderStub.java index e7e7d0f54..3e510bb75 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipReaderStub.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipReaderStub.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -58,7 +58,7 @@ public class SkipReaderStub extends AbstractExceptionThrowingItemHandlerStub< read.clear(); } - @Override + @Override public T read() throws Exception, UnexpectedInputException, ParseException { counter++; if (counter >= items.length) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipWriterStub.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipWriterStub.java index d2e50f685..048f85fbb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipWriterStub.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipWriterStub.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -48,7 +48,7 @@ public class SkipWriterStub extends AbstractExceptionThrowingItemHandlerStub< committed.clear(); } - @Override + @Override public void write(List items) throws Exception { logger.debug("Writing: " + items); for (T item : items) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java index 4442602ef..35fee14ec 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java @@ -1,5 +1,5 @@ /** - * + * */ package org.springframework.batch.core.step.item; @@ -42,10 +42,10 @@ import org.springframework.transaction.support.TransactionSynchronizationManager /** * Tests for the behavior of TaskletStep in a failure scenario. - * + * * @author Lucas Ward * @author Dave Syer - * + * */ public class TaskletStepExceptionTests { @@ -90,7 +90,7 @@ public class TaskletStepExceptionTests { @Test public void testInterruptedWithCustomStatus() throws Exception { taskletStep.setTasklet(new Tasklet() { - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { contribution.setExitStatus(new ExitStatus("FUNNY")); throw new JobInterruptedException("Planned"); @@ -145,7 +145,7 @@ public class TaskletStepExceptionTests { } }); taskletStep.setTasklet(new Tasklet() { - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; } @@ -195,6 +195,7 @@ public class TaskletStepExceptionTests { assertEquals(2, jobRepository.getUpdateCount()); } + @SuppressWarnings("serial") @Test public void testCommitError() throws Exception { @@ -212,7 +213,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { attributes.getStepContext().getStepExecution().getExecutionContext().putString("foo", "bar"); return RepeatStatus.FINISHED; @@ -226,11 +227,12 @@ public class TaskletStepExceptionTests { assertEquals("foo", e.getMessage()); assertEquals(0, stepExecution.getCommitCount()); assertEquals(1, stepExecution.getRollbackCount()); // Failed transaction - // counts as - // rollback + // counts as + // rollback assertEquals(0, stepExecution.getExecutionContext().size()); } + @SuppressWarnings("serial") @Test public void testUnexpectedRollback() throws Exception { @@ -244,7 +246,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { attributes.getStepContext().getStepExecution().getExecutionContext().putString("foo", "bar"); return RepeatStatus.FINISHED; @@ -258,8 +260,8 @@ public class TaskletStepExceptionTests { assertEquals("bar", e.getMessage()); assertEquals(0, stepExecution.getCommitCount()); assertEquals(1, stepExecution.getRollbackCount()); // Failed transaction - // counts as - // rollback + // counts as + // rollback assertEquals(0, stepExecution.getExecutionContext().size()); } @@ -268,7 +270,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; } @@ -288,7 +290,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; } @@ -309,7 +311,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; } @@ -329,7 +331,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { throw new RuntimeException("Tasklet exception"); } @@ -369,7 +371,7 @@ public class TaskletStepExceptionTests { private static class ExceptionTasklet implements Tasklet { - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { throw taskletException; } @@ -405,36 +407,36 @@ public class TaskletStepExceptionTests { this.failInTransaction = failInTransaction; } - @Override + @Override public void add(StepExecution stepExecution) { } - @Override + @Override public JobExecution createJobExecution(String jobName, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException { return null; } - @Override + @Override public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) { return null; } - @Override + @Override public int getStepExecutionCount(JobInstance jobInstance, String stepName) { return 0; } - @Override + @Override public boolean isJobInstanceExists(String jobName, JobParameters jobParameters) { return false; } - @Override + @Override public void update(JobExecution jobExecution) { } - @Override + @Override public void update(StepExecution stepExecution) { if (updateCount == failOnUpdateExecution) { throw new RuntimeException("Expected exception in step execution persistence"); @@ -442,7 +444,7 @@ public class TaskletStepExceptionTests { updateCount++; } - @Override + @Override public void updateExecutionContext(StepExecution stepExecution) { if (failOnUpdateContext) { if (!failInTransaction @@ -456,12 +458,12 @@ public class TaskletStepExceptionTests { return updateCount; } - @Override + @Override public JobExecution getLastJobExecution(String jobName, JobParameters jobParameters) { return null; } - @Override + @Override public void updateExecutionContext(JobExecution jobExecution) { } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncChunkOrientedStepIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncChunkOrientedStepIntegrationTests.java index 47ce49b33..7600d86a7 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncChunkOrientedStepIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncChunkOrientedStepIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -50,7 +50,7 @@ import org.springframework.transaction.PlatformTransactionManager; /** * @author Dave Syer - * + * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "/org/springframework/batch/core/repository/dao/sql-dao-test.xml") @@ -80,17 +80,17 @@ public class AsyncChunkOrientedStepIntegrationTests { private ItemReader getReader(String[] args) { return new ListItemReader(Arrays.asList(args)); } - + @After public void reset() { // Reset concurrency settings to something reasonable dataSource.setMaxActive(maxActive); - dataSource.setMaxIdle(maxIdle); + dataSource.setMaxIdle(maxIdle); } @Before public void init() throws Exception { - + maxActive = dataSource.getMaxActive(); maxIdle = dataSource.getMaxIdle(); @@ -121,7 +121,7 @@ public class AsyncChunkOrientedStepIntegrationTests { step.setTasklet(new TestingChunkOrientedTasklet(getReader(new String[] { "a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c" }), new ItemWriter() { - @Override + @Override public void write(List data) throws Exception { written.addAll(data); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncTaskletStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncTaskletStepTests.java index fc2d8f1d9..ec89ec172 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncTaskletStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncTaskletStepTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -57,7 +57,7 @@ public class AsyncTaskletStepTests { private int throttleLimit = 20; ItemWriter itemWriter = new ItemWriter() { - @Override + @Override public void write(List data) throws Exception { // Thread.sleep(100L); logger.info("Items: " + data); @@ -172,7 +172,7 @@ public class AsyncTaskletStepTests { concurrencyLimit = 1; items = Arrays.asList("one", "barf", "three", "four"); itemProcessor = new ItemProcessor() { - @Override + @Override public String process(String item) throws Exception { logger.info("Item: "+item); processed.add(item); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapterTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapterTests.java index b51793457..5254de2fe 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapterTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -24,13 +24,13 @@ import org.junit.Test; import org.springframework.batch.repeat.RepeatStatus; public class CallableTaskletAdapterTests { - + private CallableTaskletAdapter adapter = new CallableTaskletAdapter(); @Test public void testHandle() throws Exception { adapter.setCallable(new Callable() { - @Override + @Override public RepeatStatus call() throws Exception { return RepeatStatus.FINISHED; } @@ -48,5 +48,5 @@ public class CallableTaskletAdapterTests { // expected } } - + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/ChunkOrientedStepIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/ChunkOrientedStepIntegrationTests.java index 188f380a9..864ebc288 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/ChunkOrientedStepIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/ChunkOrientedStepIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -48,7 +48,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager /** * @author Dave Syer - * + * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "/org/springframework/batch/core/repository/dao/sql-dao-test.xml") @@ -87,22 +87,23 @@ public class ChunkOrientedStepIntegrationTests { } + @SuppressWarnings("serial") @Test public void testStatusForCommitFailedException() throws Exception { step.setTasklet(new TestingChunkOrientedTasklet(getReader(new String[] { "a", "b", "c" }), new ItemWriter() { - @Override - public void write(List data) throws Exception { - TransactionSynchronizationManager - .registerSynchronization(new TransactionSynchronizationAdapter() { - @Override - public void beforeCommit(boolean readOnly) { - throw new RuntimeException("Simulate commit failure"); - } - }); + @Override + public void write(List data) throws Exception { + TransactionSynchronizationManager + .registerSynchronization(new TransactionSynchronizationAdapter() { + @Override + public void beforeCommit(boolean readOnly) { + throw new RuntimeException("Simulate commit failure"); } - }, chunkOperations)); + }); + } + }, chunkOperations)); JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters(Collections .singletonMap("run.id", new JobParameter(getClass().getName() + ".1")))); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java index 61628b0cf..0b20c1be0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -65,7 +65,7 @@ public class StepExecutorInterruptionTests { } private void configureStep(TaskletStep step) throws JobExecutionAlreadyRunningException, JobRestartException, - JobInstanceAlreadyCompleteException { + JobInstanceAlreadyCompleteException { this.step = step; JobSupport job = new JobSupport(); @@ -75,7 +75,7 @@ public class StepExecutorInterruptionTests { step.setJobRepository(jobRepository); step.setTransactionManager(new ResourcelessTransactionManager()); itemWriter = new ItemWriter() { - @Override + @Override public void write(List item) throws Exception { } }; @@ -93,7 +93,7 @@ public class StepExecutorInterruptionTests { // N.B, If we don't set the completion policy it might run forever template.setCompletionPolicy(new SimpleCompletionPolicy(2)); step.setTasklet(new TestingChunkOrientedTasklet(new ItemReader() { - @Override + @Override public Object read() throws Exception { // do something non-trivial (and not Thread.sleep()) double foo = 1; @@ -134,6 +134,7 @@ public class StepExecutorInterruptionTests { // is taken. configureStep(new TaskletStep("step") { + @SuppressWarnings("serial") @Override protected Semaphore createSemaphore() { return new Semaphore(1) { @@ -154,7 +155,7 @@ public class StepExecutorInterruptionTests { Thread processingThread = createThread(stepExecution); step.setTasklet(new TestingChunkOrientedTasklet(new ItemReader() { - @Override + @Override public Object read() throws Exception { return null; } @@ -179,6 +180,7 @@ public class StepExecutorInterruptionTests { public void testLockNotReleasedIfChunkFails() throws Exception { configureStep(new TaskletStep("step") { + @SuppressWarnings("serial") @Override protected Semaphore createSemaphore() { return new Semaphore(1) { @@ -198,7 +200,7 @@ public class StepExecutorInterruptionTests { }); step.setTasklet(new TestingChunkOrientedTasklet(new ItemReader() { - @Override + @Override public Object read() throws Exception { throw new RuntimeException("Planned!"); } @@ -216,7 +218,7 @@ public class StepExecutorInterruptionTests { */ private Thread createThread(final StepExecution stepExecution) { Thread processingThread = new Thread() { - @Override + @Override public void run() { try { jobRepository.add(stepExecution); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java index ec8e45436..89711b90f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/SystemCommandTaskletIntegrationTests.java @@ -223,7 +223,7 @@ public class SystemCommandTaskletIntegrationTests { */ private static class TestExitCodeMapper implements SystemProcessExitCodeMapper { - @Override + @Override public ExitStatus getExitStatus(int exitCode) { if (exitCode == 0) { return ExitStatus.COMPLETED; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java index 1474ce789..847fcf0bf 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -73,7 +73,7 @@ public class TaskletStepTests { private List list = new ArrayList(); ItemWriter itemWriter = new ItemWriter() { - @Override + @Override public void write(List data) throws Exception { processed.addAll(data); } @@ -87,6 +87,7 @@ public class TaskletStepTests { private ResourcelessTransactionManager transactionManager; + @SuppressWarnings("serial") private ExecutionContext foobarEc = new ExecutionContext() { { put("foo", "bar"); @@ -100,7 +101,7 @@ public class TaskletStepTests { private TaskletStep getStep(String[] strings) throws Exception { return getStep(strings, 1); } - + private TaskletStep getStep(String[] strings, int commitInterval) throws Exception { TaskletStep step = new TaskletStep("stepName"); // Only process one item: @@ -241,7 +242,7 @@ public class TaskletStepTests { ItemReader itemReader = new ItemReader() { - @Override + @Override public String read() throws Exception { throw new RuntimeException(); } @@ -266,7 +267,7 @@ public class TaskletStepTests { ItemReader itemReader = new ItemReader() { - @Override + @Override public String read() throws Exception { throw new RuntimeException(); @@ -292,7 +293,7 @@ public class TaskletStepTests { ItemReader itemReader = new ItemReader() { - @Override + @Override public String read() throws Exception { throw new RuntimeException(); @@ -344,7 +345,7 @@ public class TaskletStepTests { final JobExecution jobExecution = new JobExecution(jobInstance); final StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); step.setJobRepository(new JobRepositorySupport() { - @Override + @Override public void updateExecutionContext(StepExecution stepExecution) { list.add(stepExecution); } @@ -364,10 +365,11 @@ public class TaskletStepTests { private int counter = 0; // initial save before item processing succeeds, later calls fail - @Override + @Override public void updateExecutionContext(StepExecution stepExecution) { - if (counter > 0) + if (counter > 0) { throw new RuntimeException("foo"); + } counter++; } }); @@ -408,7 +410,7 @@ public class TaskletStepTests { @Test public void testRestartJobOnNonRestartableTasklet() throws Exception { step.setTasklet(new TestingChunkOrientedTasklet(new ItemReader() { - @Override + @Override public String read() throws Exception { return "foo"; } @@ -422,12 +424,12 @@ public class TaskletStepTests { @Test public void testStreamManager() throws Exception { MockRestartableItemReader reader = new MockRestartableItemReader() { - @Override + @Override public String read() throws Exception { return "foo"; } - @Override + @Override public void update(ExecutionContext executionContext) { executionContext.putString("foo", "bar"); } @@ -449,7 +451,7 @@ public class TaskletStepTests { @Test public void testDirectlyInjectedItemStream() throws Exception { step.setStreams(new ItemStream[] { new ItemStreamSupport() { - @Override + @Override public void update(ExecutionContext executionContext) { executionContext.putString("foo", "bar"); } @@ -467,12 +469,12 @@ public class TaskletStepTests { @Test public void testDirectlyInjectedListener() throws Exception { step.registerStepExecutionListener(new StepExecutionListenerSupport() { - @Override + @Override public void beforeStep(StepExecution stepExecution) { list.add("foo"); } - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("bar"); return null; @@ -487,12 +489,12 @@ public class TaskletStepTests { @Test public void testListenerCalledBeforeStreamOpened() throws Exception { MockRestartableItemReader reader = new MockRestartableItemReader() { - @Override + @Override public void beforeStep(StepExecution stepExecution) { list.add("foo"); } - @Override + @Override public void open(ExecutionContext executionContext) throws ItemStreamException { assertEquals(1, list.size()); } @@ -510,7 +512,7 @@ public class TaskletStepTests { final ExitStatus customStatus = new ExitStatus("COMPLETED_CUSTOM"); step.setStepExecutionListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() { - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("afterStepCalled"); return customStatus; @@ -533,14 +535,14 @@ public class TaskletStepTests { @Test public void testDirectlyInjectedListenerOnError() throws Exception { step.registerStepExecutionListener(new StepExecutionListenerSupport() { - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("exception"); return null; } }); step.setTasklet(new TestingChunkOrientedTasklet(new MockRestartableItemReader() { - @Override + @Override public String read() throws Exception { throw new RuntimeException("FOO"); } @@ -555,12 +557,12 @@ public class TaskletStepTests { @Test public void testDirectlyInjectedStreamWhichIsAlsoReader() throws Exception { MockRestartableItemReader reader = new MockRestartableItemReader() { - @Override + @Override public String read() throws Exception { return "foo"; } - @Override + @Override public void update(ExecutionContext executionContext) { executionContext.putString("foo", "bar"); } @@ -584,7 +586,7 @@ public class TaskletStepTests { StepInterruptionPolicy interruptionPolicy = new StepInterruptionPolicy() { - @Override + @Override public void checkInterrupted(StepExecution stepExecution) throws JobInterruptedException { throw new JobInterruptedException("interrupted"); } @@ -594,7 +596,7 @@ public class TaskletStepTests { ItemReader itemReader = new ItemReader() { - @Override + @Override public String read() throws Exception { throw new RuntimeException(); @@ -620,7 +622,7 @@ public class TaskletStepTests { public void testStatusForNormalFailure() throws Exception { ItemReader itemReader = new ItemReader() { - @Override + @Override public String read() throws Exception { // Trigger a rollback throw new RuntimeException("Foo"); @@ -644,7 +646,7 @@ public class TaskletStepTests { public void testStatusForErrorFailure() throws Exception { ItemReader itemReader = new ItemReader() { - @Override + @Override public String read() throws Exception { // Trigger a rollback throw new Error("Foo"); @@ -664,11 +666,12 @@ public class TaskletStepTests { assertEquals("Foo", stepExecution.getFailureExceptions().get(0).getMessage()); } + @SuppressWarnings("serial") @Test public void testStatusForResetFailedException() throws Exception { ItemReader itemReader = new ItemReader() { - @Override + @Override public String read() throws Exception { // Trigger a rollback throw new RuntimeException("Foo"); @@ -676,7 +679,7 @@ public class TaskletStepTests { }; step.setTasklet(new TestingChunkOrientedTasklet(itemReader, itemWriter)); step.setTransactionManager(new ResourcelessTransactionManager() { - @Override + @Override protected void doRollback(DefaultTransactionStatus status) throws TransactionException { // Simulate failure on rollback when stream resets throw new RuntimeException("Bar"); @@ -697,11 +700,12 @@ public class TaskletStepTests { assertEquals("Bar", stepExecution.getFailureExceptions().get(0).getMessage()); } + @SuppressWarnings("serial") @Test public void testStatusForCommitFailedException() throws Exception { step.setTransactionManager(new ResourcelessTransactionManager() { - @Override + @Override protected void doCommit(DefaultTransactionStatus status) throws TransactionException { // Simulate failure on commit throw new RuntimeException("Foo"); @@ -730,7 +734,7 @@ public class TaskletStepTests { step.setJobRepository(new JobRepositorySupport()); step.setStreams(new ItemStream[] { new ItemStreamSupport() { - @Override + @Override public void close() throws ItemStreamException { throw new RuntimeException("Bar"); } @@ -754,7 +758,7 @@ public class TaskletStepTests { public void testStatusForCloseFailedException() throws Exception { MockRestartableItemReader itemReader = new MockRestartableItemReader() { - @Override + @Override public void close() throws ItemStreamException { super.close(); // Simulate failure on rollback when stream resets @@ -788,7 +792,7 @@ public class TaskletStepTests { @Test public void testRestartAfterFailureInFirstChunk() throws Exception { MockRestartableItemReader reader = new MockRestartableItemReader() { - @Override + @Override public String read() throws Exception { // fail on the very first item throw new RuntimeException("CRASH!"); @@ -825,14 +829,14 @@ public class TaskletStepTests { } /** - * Exception in {@link StepExecutionListener#afterStep(StepExecution)} + * Exception in {@link StepExecutionListener#afterStep(StepExecution)} * doesn't cause step failure. * @throws JobInterruptedException */ @Test public void testStepFailureInAfterStepCallback() throws JobInterruptedException { StepExecutionListener listener = new StepExecutionListenerSupport() { - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { throw new RuntimeException("exception thrown in afterStep to signal failure"); } @@ -849,7 +853,7 @@ public class TaskletStepTests { public void testNoRollbackFor() throws Exception { step.setTasklet(new Tasklet() { - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { throw new RuntimeException("Bar"); } @@ -858,8 +862,9 @@ public class TaskletStepTests { JobExecution jobExecutionContext = new JobExecution(jobInstance); StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); + @SuppressWarnings("serial") DefaultTransactionAttribute transactionAttribute = new DefaultTransactionAttribute() { - @Override + @Override public boolean rollbackOn(Throwable ex) { return false; } @@ -873,7 +878,7 @@ public class TaskletStepTests { @Test public void testTaskletExecuteReturnNull() throws Exception { step.setTasklet(new Tasklet() { - @Override + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return null; } @@ -883,7 +888,7 @@ public class TaskletStepTests { step.execute(stepExecution); assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus()); } - + private static class JobRepositoryStub extends JobRepositorySupport { private int updateCount = 0; @@ -902,7 +907,7 @@ public class TaskletStepTests { private int called = 0; - @Override + @Override public void update(StepExecution stepExecution) { called++; if (called == 3) { @@ -912,18 +917,18 @@ public class TaskletStepTests { } private class MockRestartableItemReader extends ItemStreamSupport implements ItemReader, - StepExecutionListener { + StepExecutionListener { private boolean getExecutionAttributesCalled = false; private boolean restoreFromCalled = false; - @Override + @Override public String read() throws Exception { return "item"; } - @Override + @Override public void update(ExecutionContext executionContext) { getExecutionAttributesCalled = true; executionContext.putString("spam", "bucket"); @@ -937,12 +942,12 @@ public class TaskletStepTests { return restoreFromCalled; } - @Override + @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; } - @Override + @Override public void beforeStep(StepExecution stepExecution) { } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/test/namespace/config/DummyNamespaceHandler.java b/spring-batch-core/src/test/java/org/springframework/batch/test/namespace/config/DummyNamespaceHandler.java index 062fb3ed9..b82c45f4b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/test/namespace/config/DummyNamespaceHandler.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/test/namespace/config/DummyNamespaceHandler.java @@ -1,12 +1,12 @@ /* - * Copyright 2006-2012 the original author or authors. - * + * Copyright 2006-2013 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. @@ -29,23 +29,23 @@ import org.w3c.dom.Node; /** * Empty implementation used for testing only. - * + * * @author Costin Leau */ public class DummyNamespaceHandler implements NamespaceHandler { public static String LABEL = new Random().toString(); - @Override + @Override public BeanDefinitionHolder decorate(Node source, BeanDefinitionHolder definition, ParserContext parserContext) { return null; } - @Override + @Override public void init() { } - @Override + @Override public BeanDefinition parse(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(TestTasklet.class); builder.addPropertyValue("name", LABEL); diff --git a/spring-batch-core/src/test/java/test/jdbc/datasource/DataSourceInitializer.java b/spring-batch-core/src/test/java/test/jdbc/datasource/DataSourceInitializer.java index 49e2f8dfc..c7d04860b 100644 --- a/spring-batch-core/src/test/java/test/jdbc/datasource/DataSourceInitializer.java +++ b/spring-batch-core/src/test/java/test/jdbc/datasource/DataSourceInitializer.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -41,15 +41,15 @@ import org.springframework.util.StringUtils; /** * Wrapper for a {@link DataSource} that can run scripts on start up and shut * down. Us as a bean definition

    - * + * * Run this class to initialize a database in a running server process. * Make sure the server is running first by launching the "hsql-server" from the * hsql.server project. Then you can right click in Eclipse and * Run As -> Java Application. Do the same any time you want to wipe the * database and start again. - * + * * @author Dave Syer - * + * */ public class DataSourceInitializer implements InitializingBean { @@ -65,15 +65,16 @@ public class DataSourceInitializer implements InitializingBean { /** * Main method as convenient entry point. - * + * * @param args */ + @SuppressWarnings("resource") public static void main(String... args) { new ClassPathXmlApplicationContext(ClassUtils.addResourcePathToPackagePath(DataSourceInitializer.class, DataSourceInitializer.class.getSimpleName() + "-context.xml")); } - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(dataSource); initialize(); @@ -91,16 +92,16 @@ public class DataSourceInitializer implements InitializingBean { } } + @SuppressWarnings({ "unchecked", "rawtypes" }) private void doExecuteScript(final Resource scriptResource) { - if (scriptResource == null || !scriptResource.exists()) { - throw new IllegalArgumentException("Script resource is null or does not exist"); - } + if (scriptResource == null || !scriptResource.exists()) { + throw new IllegalArgumentException("Script resource is null or does not exist"); + } TransactionTemplate transactionTemplate = new TransactionTemplate(new DataSourceTransactionManager(dataSource)); transactionTemplate.execute(new TransactionCallback() { - @Override - @SuppressWarnings("unchecked") + @Override public Object doInTransaction(TransactionStatus status) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); String[] scripts; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java index 877a2ccf4..3b40126f8 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -18,8 +18,8 @@ package org.springframework.batch.item; import java.io.Serializable; import java.util.Map; -import java.util.Set; import java.util.Map.Entry; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.springframework.util.Assert; @@ -28,13 +28,14 @@ import org.springframework.util.Assert; * Object representing a context for an {@link ItemStream}. It is a thin wrapper * for a map that allows optionally for type safety on reads. It also allows for * dirty checking by setting a 'dirty' flag whenever any put is called. - * + * * Note that putting null value is equivalent to removing the entry * for the given key. - * + * * @author Lucas Ward * @author Douglas Kaminsky */ +@SuppressWarnings("serial") public class ExecutionContext implements Serializable { private volatile boolean dirty = false; @@ -51,7 +52,7 @@ public class ExecutionContext implements Serializable { /** * Initializes a new execution context with the contents of another map. - * + * * @param map Initial contents of context. */ public ExecutionContext(Map map) { @@ -73,7 +74,7 @@ public class ExecutionContext implements Serializable { /** * Adds a String value to the context. - * + * * @param key Key to add to context * @param value Value to associate with key */ @@ -85,7 +86,7 @@ public class ExecutionContext implements Serializable { /** * Adds a Long value to the context. - * + * * @param key Key to add to context * @param value Value to associate with key */ @@ -96,7 +97,7 @@ public class ExecutionContext implements Serializable { /** * Adds an Integer value to the context. - * + * * @param key Key to add to context * @param value Value to associate with key */ @@ -106,7 +107,7 @@ public class ExecutionContext implements Serializable { /** * Add a Double value to the context. - * + * * @param key Key to add to context * @param value Value to associate with key */ @@ -118,7 +119,7 @@ public class ExecutionContext implements Serializable { /** * Add an Object value to the context (must be Serializable). Putting * null value for a given key removes the key. - * + * * @param key Key to add to context * @param value Value to associate with key */ @@ -138,7 +139,7 @@ public class ExecutionContext implements Serializable { * Indicates if context has been changed with a "put" operation since the * dirty flag was last cleared. Note that the last time the flag was cleared * might correspond to creation of the context. - * + * * @return True if "put" operation has occurred since flag was last cleared */ public boolean isDirty() { @@ -147,7 +148,7 @@ public class ExecutionContext implements Serializable { /** * Typesafe Getter for the String represented by the provided key. - * + * * @param key The key to get a value for * @return The String value */ @@ -159,7 +160,7 @@ public class ExecutionContext implements Serializable { /** * Typesafe Getter for the String represented by the provided key with * default value to return if key is not represented. - * + * * @param key The key to get a value for * @param defaultString Default to return if key is not represented * @return The String value if key is repreesnted, specified @@ -175,7 +176,7 @@ public class ExecutionContext implements Serializable { /** * Typesafe Getter for the Long represented by the provided key. - * + * * @param key The key to get a value for * @return The Long value */ @@ -187,7 +188,7 @@ public class ExecutionContext implements Serializable { /** * Typesafe Getter for the Long represented by the provided key with default * value to return if key is not represented. - * + * * @param key The key to get a value for * @param defaultLong Default to return if key is not represented * @return The long value if key is represented, specified @@ -203,7 +204,7 @@ public class ExecutionContext implements Serializable { /** * Typesafe Getter for the Integer represented by the provided key. - * + * * @param key The key to get a value for * @return The Integer value */ @@ -215,7 +216,7 @@ public class ExecutionContext implements Serializable { /** * Typesafe Getter for the Integer represented by the provided key with * default value to return if key is not represented. - * + * * @param key The key to get a value for * @param defaultInt Default to return if key is not represented * @return The int value if key is represented, specified @@ -231,7 +232,7 @@ public class ExecutionContext implements Serializable { /** * Typesafe Getter for the Double represented by the provided key. - * + * * @param key The key to get a value for * @return The Double value */ @@ -242,7 +243,7 @@ public class ExecutionContext implements Serializable { /** * Typesafe Getter for the Double represented by the provided key with * default value to return if key is not represented. - * + * * @param key The key to get a value for * @param defaultDouble Default to return if key is not represented * @return The double value if key is represented, specified @@ -258,7 +259,7 @@ public class ExecutionContext implements Serializable { /** * Getter for the value represented by the provided key. - * + * * @param key The key to get a value for * @return The value represented by the given key */ @@ -269,7 +270,7 @@ public class ExecutionContext implements Serializable { /** * Utility method that attempts to take a value represented by a given key * and validate it as a member of the specified type. - * + * * @param key The key to validate a value for * @param type Class against which value should be validated * @return Value typed to the specified Class @@ -288,7 +289,7 @@ public class ExecutionContext implements Serializable { /** * Indicates whether or not the context is empty. - * + * * @return True if the context has no entries, false otherwise. * @see java.util.Map#isEmpty() */ @@ -305,7 +306,7 @@ public class ExecutionContext implements Serializable { /** * Returns the entry set containing the contents of this context. - * + * * @return A set representing the contents of the context * @see java.util.Map#entrySet() */ @@ -315,7 +316,7 @@ public class ExecutionContext implements Serializable { /** * Indicates whether or not a key is represented in this context. - * + * * @param key Key to check existence for * @return True if key is represented in context, false otherwise * @see java.util.Map#containsKey(Object) @@ -326,7 +327,7 @@ public class ExecutionContext implements Serializable { /** * Removes the mapping for a key from this context if it is present. - * + * * @see java.util.Map#remove(Object) */ public Object remove(String key) { @@ -335,7 +336,7 @@ public class ExecutionContext implements Serializable { /** * Indicates whether or not a value is represented in this context. - * + * * @param value Value to check existence for * @return True if value is represented in context, false otherwise * @see java.util.Map#containsValue(Object) @@ -346,10 +347,10 @@ public class ExecutionContext implements Serializable { /* * (non-Javadoc) - * + * * @see java.lang.Object#equals(java.lang.Object) */ - @Override + @Override public boolean equals(Object obj) { if (obj instanceof ExecutionContext == false) { return false; @@ -363,27 +364,27 @@ public class ExecutionContext implements Serializable { /* * (non-Javadoc) - * + * * @see java.lang.Object#hashCode() */ - @Override + @Override public int hashCode() { return map.hashCode(); } /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ - @Override + @Override public String toString() { return map.toString(); } /** * Returns number of entries in the context - * + * * @return Number of entries in the context * @see java.util.Map#size() */ diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ItemStreamSupport.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ItemStreamSupport.java index 5130eda66..cebf23566 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ItemStreamSupport.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ItemStreamSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -18,7 +18,7 @@ package org.springframework.batch.item; /** * Empty method implementation of {@link ItemStream}. - * + * * @author Dave Syer * */ diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/AbstractMethodInvokingDelegator.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/AbstractMethodInvokingDelegator.java index ac5b415e8..516d70e65 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/AbstractMethodInvokingDelegator.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/AbstractMethodInvokingDelegator.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -30,12 +30,12 @@ import org.springframework.util.MethodInvoker; * Superclass for delegating classes which dynamically call a custom method of * injected object. Provides convenient API for dynamic method invocation * shielding subclasses from low-level details and exception handling. - * + * * {@link Exception}s thrown by a successfully invoked delegate method are * re-thrown without wrapping. In case the delegate method throws a * {@link Throwable} that doesn't subclass {@link Exception} it will be wrapped * by {@link InvocationTargetThrowableWrapper}. - * + * * @author Robert Kasanicky */ public abstract class AbstractMethodInvokingDelegator implements InitializingBean { @@ -129,7 +129,7 @@ public abstract class AbstractMethodInvokingDelegator implements Initializing } } - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(targetObject); Assert.hasLength(targetMethod); @@ -171,8 +171,9 @@ public abstract class AbstractMethodInvokingDelegator implements Initializing argumentsMatchParameters = false; } } - if (argumentsMatchParameters) + if (argumentsMatchParameters) { return true; + } } } } @@ -201,7 +202,7 @@ public abstract class AbstractMethodInvokingDelegator implements Initializing * {@link #setTargetMethod(String)}. These will be used only when the * subclass tries to invoke the target method without providing explicit * argument values. - * + * * If arguments are set to not-null value {@link #afterPropertiesSet()} will * check the values are compatible with target method's signature. In case * arguments are null (not set) method signature will not be checked and it @@ -214,7 +215,7 @@ public abstract class AbstractMethodInvokingDelegator implements Initializing /** * Used to wrap a {@link Throwable} (not an {@link Exception}) thrown by a * reflectively-invoked delegate. - * + * * @author Robert Kasanicky */ public static class InvocationTargetThrowableWrapper extends RuntimeException { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemProcessorAdapter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemProcessorAdapter.java index a6b2b45d9..c95dfaf1a 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemProcessorAdapter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemProcessorAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -21,17 +21,17 @@ import org.springframework.batch.item.ItemProcessor; /** * Invokes a custom method on a delegate plain old Java object which itself * processes an item. - * + * * @author Dave Syer */ public class ItemProcessorAdapter extends AbstractMethodInvokingDelegator implements ItemProcessor { /** * Invoke the delegate method and return the result. - * + * * @see ItemProcessor#process(Object) */ - @Override + @Override public O process(I item) throws Exception { return invokeDelegateMethodWithArgument(item); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemReaderAdapter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemReaderAdapter.java index c6f628d3c..f7b3730d6 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemReaderAdapter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemReaderAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -21,7 +21,7 @@ import org.springframework.batch.item.ItemReader; /** * Invokes a custom method on a delegate plain old Java object which itself * provides an item. - * + * * @author Robert Kasanicky */ public class ItemReaderAdapter extends AbstractMethodInvokingDelegator implements ItemReader { @@ -29,7 +29,7 @@ public class ItemReaderAdapter extends AbstractMethodInvokingDelegator imp /** * @return return value of the target method. */ - @Override + @Override public T read() throws Exception { return invokeDelegateMethod(); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemWriterAdapter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemWriterAdapter.java index 76ba397a1..0088e03ba 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemWriterAdapter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemWriterAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -22,21 +22,21 @@ import org.springframework.batch.item.ItemWriter; /** - * Delegates item processing to a custom method - + * Delegates item processing to a custom method - * passes the item as an argument for the delegate method. - * + * * @see PropertyExtractingDelegatingItemWriter - * + * * @author Robert Kasanicky */ public class ItemWriterAdapter extends AbstractMethodInvokingDelegator implements ItemWriter { - - @Override - public void write(List items) throws Exception { - for (T item : items) { - invokeDelegateMethodWithArgument(item); + + @Override + public void write(List items) throws Exception { + for (T item : items) { + invokeDelegateMethodWithArgument(item); } - } - + } + } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemWriter.java index 881c78c1c..f7d997983 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/PropertyExtractingDelegatingItemWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -27,13 +27,13 @@ import org.springframework.util.Assert; /** * Delegates processing to a custom method - extracts property values from item * object and uses them as arguments for the delegate method. - * + * * @see ItemWriterAdapter - * + * * @author Robert Kasanicky */ public class PropertyExtractingDelegatingItemWriter extends AbstractMethodInvokingDelegator implements - ItemWriter { +ItemWriter { private String[] fieldsUsedAsTargetMethodArguments; @@ -42,7 +42,7 @@ public class PropertyExtractingDelegatingItemWriter extends AbstractMethodInv * fieldsUsedAsTargetMethodArguments and passes them as arguments to the * delegate method. */ - @Override + @Override public void write(List items) throws Exception { for (T item : items) { @@ -59,7 +59,7 @@ public class PropertyExtractingDelegatingItemWriter extends AbstractMethodInv } } - @Override + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notEmpty(fieldsUsedAsTargetMethodArguments); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/amqp/AmqpItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/amqp/AmqpItemReader.java index 70fd1f343..ee4d10cd3 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/amqp/AmqpItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/amqp/AmqpItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2013 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. @@ -30,34 +30,34 @@ import org.springframework.util.Assert; * @author Chris Schaefer */ public class AmqpItemReader implements ItemReader { - private final AmqpTemplate amqpTemplate; - private Class itemType; + private final AmqpTemplate amqpTemplate; + private Class itemType; - public AmqpItemReader(final AmqpTemplate amqpTemplate) { - Assert.notNull(amqpTemplate, "AmpqTemplate must not be null"); + public AmqpItemReader(final AmqpTemplate amqpTemplate) { + Assert.notNull(amqpTemplate, "AmpqTemplate must not be null"); - this.amqpTemplate = amqpTemplate; - } + this.amqpTemplate = amqpTemplate; + } - @Override - @SuppressWarnings("unchecked") - public T read() { - if (itemType != null && itemType.isAssignableFrom(Message.class)) { - return (T) amqpTemplate.receive(); - } + @Override + @SuppressWarnings("unchecked") + public T read() { + if (itemType != null && itemType.isAssignableFrom(Message.class)) { + return (T) amqpTemplate.receive(); + } - Object result = amqpTemplate.receiveAndConvert(); + Object result = amqpTemplate.receiveAndConvert(); - if (itemType != null && result != null) { - Assert.state(itemType.isAssignableFrom(result.getClass()), - "Received message payload of wrong type: expected [" + itemType + "]"); - } + if (itemType != null && result != null) { + Assert.state(itemType.isAssignableFrom(result.getClass()), + "Received message payload of wrong type: expected [" + itemType + "]"); + } - return (T) result; - } + return (T) result; + } - public void setItemType(Class itemType) { - Assert.notNull(itemType, "Item type cannot be null"); - this.itemType = itemType; - } + public void setItemType(Class itemType) { + Assert.notNull(itemType, "Item type cannot be null"); + this.itemType = itemType; + } } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractCursorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractCursorItemReader.java index d3e75e35e..24eaa9e49 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractCursorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractCursorItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -45,27 +45,27 @@ import org.springframework.util.Assert; /** *

    - * Abstract base class for any simple item reader that opens a database cursor and continually retrieves - * the next row in the ResultSet. + * Abstract base class for any simple item reader that opens a database cursor and continually retrieves + * the next row in the ResultSet. *

    - * + * *

    * By default the cursor will be opened using a separate connection. The ResultSet for the cursor - * is held open regardless of commits or roll backs in a surrounding transaction. Clients of this + * is held open regardless of commits or roll backs in a surrounding transaction. Clients of this * reader are responsible for buffering the items in the case that they need to be re-presented on a * rollback. This buffering is handled by the step implementations provided and is only a concern for * anyone writing their own step implementations. *

    - * + * *

    - * There is an option ({@link #setUseSharedExtendedConnection(boolean)} that will share the connection - * used for the cursor with the rest of the step processing. If you set this flag to true - * then you must wrap the DataSource in a {@link ExtendedConnectionDataSourceProxy} to prevent the - * connection from being closed and released after each commit performed as part of the step processing. - * You must also use a JDBC driver supporting JDBC 3.0 or later since the cursor will be opened with the - * additional option of 'HOLD_CUSORS_OVER_COMMIT' enabled. + * There is an option ({@link #setUseSharedExtendedConnection(boolean)} that will share the connection + * used for the cursor with the rest of the step processing. If you set this flag to true + * then you must wrap the DataSource in a {@link ExtendedConnectionDataSourceProxy} to prevent the + * connection from being closed and released after each commit performed as part of the step processing. + * You must also use a JDBC driver supporting JDBC 3.0 or later since the cursor will be opened with the + * additional option of 'HOLD_CUSORS_OVER_COMMIT' enabled. *

    - * + * *

    * Each call to {@link #read()} will attempt to map the row at the current position in the * ResultSet. There is currently no wrapping of the ResultSet to suppress calls @@ -76,7 +76,7 @@ import org.springframework.util.Assert; * restartability. This ensures that each call to {@link #read()} returns the * ResultSet at the correct row, regardless of rollbacks or restarts. *

    - * + * *

    * {@link ExecutionContext}: The current row is returned as restart data, and * when restored from that same data, the cursor is opened and the current row @@ -84,56 +84,56 @@ import org.springframework.util.Assert; * {@link #setDriverSupportsAbsolute(boolean)} for improving restart * performance. *

    - * + * *

    * Calling close on this {@link ItemStream} will cause all resources it is * currently using to be freed. (Connection, ResultSet, etc). It is then illegal * to call {@link #read()} again until it has been re-opened. *

    - * + * *

    * Known limitation: when used with Derby * {@link #setVerifyCursorPosition(boolean)} needs to be false * because {@link ResultSet#getRow()} call used for cursor position verification * is not available for 'TYPE_FORWARD_ONLY' result sets. *

    - * + * * @author Lucas Ward * @author Peter Zozom * @author Robert Kasanicky * @author Thomas Risberg */ public abstract class AbstractCursorItemReader extends AbstractItemCountingItemStreamItemReader - implements InitializingBean { +implements InitializingBean { /** Logger available to subclasses */ protected final Log log = LogFactory.getLog(getClass()); public static final int VALUE_NOT_SET = -1; private Connection con; - + protected ResultSet rs; - + private DataSource dataSource; - + private int fetchSize = VALUE_NOT_SET; - + private int maxRows = VALUE_NOT_SET; - + private int queryTimeout = VALUE_NOT_SET; - + private boolean ignoreWarnings = true; - + private boolean verifyCursorPosition = true; - + private SQLExceptionTranslator exceptionTranslator; - + private boolean initialized = false; - + private boolean driverSupportsAbsolute = false; - + private boolean useSharedExtendedConnection = false; - + public AbstractCursorItemReader() { super(); @@ -141,18 +141,18 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt /** * Assert that mandatory properties are set. - * + * * @throws IllegalArgumentException if either data source or sql properties * not set. */ - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(dataSource, "DataSource must be provided"); } /** * Public setter for the data source for injection purposes. - * + * * @param dataSource */ public void setDataSource(DataSource dataSource) { @@ -161,7 +161,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt /** * Public getter for the data source. - * + * * @return the dataSource */ public DataSource getDataSource() { @@ -173,7 +173,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt * CallableStatement), applying statement settings such as fetch size, max * rows, and query timeout. @param stmt the JDBC Statement to prepare * @throws SQLException - * + * * @see #setFetchSize * @see #setMaxRows * @see #setQueryTimeout @@ -193,7 +193,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt /** * Return the exception translator for this instance. - * + * * Creates a default SQLErrorCodeSQLExceptionTranslator for the specified * DataSource if none is set. */ @@ -214,31 +214,31 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt /** * Throw a SQLWarningException if we're not ignoring warnings, else log the * warnings (at debug level). - * + * * @param statement the current statement to obtain the warnings from, if there are any. * @throws SQLException - * + * * @see org.springframework.jdbc.SQLWarningException */ protected void handleWarnings(Statement statement) throws SQLWarningException, - SQLException { - if (ignoreWarnings) { - if (log.isDebugEnabled()) { - SQLWarning warningToLog = statement.getWarnings(); - while (warningToLog != null) { - log.debug("SQLWarning ignored: SQL state '" + warningToLog.getSQLState() + "', error code '" - + warningToLog.getErrorCode() + "', message [" + warningToLog.getMessage() + "]"); - warningToLog = warningToLog.getNextWarning(); - } - } - } - else { - SQLWarning warnings = statement.getWarnings(); - if (warnings != null) { - throw new SQLWarningException("Warning not ignored", warnings); - } + SQLException { + if (ignoreWarnings) { + if (log.isDebugEnabled()) { + SQLWarning warningToLog = statement.getWarnings(); + while (warningToLog != null) { + log.debug("SQLWarning ignored: SQL state '" + warningToLog.getSQLState() + "', error code '" + + warningToLog.getErrorCode() + "', message [" + warningToLog.getMessage() + "]"); + warningToLog = warningToLog.getNextWarning(); } } + } + else { + SQLWarning warnings = statement.getWarnings(); + if (warnings != null) { + throw new SQLWarningException("Warning not ignored", warnings); + } + } + } /** * Moves the cursor in the ResultSet to the position specified by the row @@ -262,7 +262,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt * fetched from the database when more rows are needed for this * ResultSet object. If the fetch size specified is zero, the * JDBC driver ignores the value. - * + * * @param fetchSize the number of rows to fetch * @see ResultSet#setFetchSize(int) */ @@ -273,7 +273,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt /** * Sets the limit for the maximum number of rows that any * ResultSet object can contain to the given number. - * + * * @param maxRows the new max rows limit; zero means there is no limit * @see Statement#setMaxRows(int) */ @@ -285,7 +285,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt * Sets the number of seconds the driver will wait for a * Statement object to execute to the given number of seconds. * If the limit is exceeded, an SQLException is thrown. - * + * * @param queryTimeout seconds the new query timeout limit in seconds; zero * means there is no limit * @see Statement#setQueryTimeout(int) @@ -297,7 +297,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt /** * Set whether SQLWarnings should be ignored (only logged) or exception * should be thrown. - * + * * @param ignoreWarnings if TRUE, warnings are ignored */ public void setIgnoreWarnings(boolean ignoreWarnings) { @@ -307,7 +307,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt /** * Allow verification of cursor position after current row is processed by * RowMapper or RowCallbackHandler. Default value is TRUE. - * + * * @param verifyCursorPosition if true, cursor position is verified */ public void setVerifyCursorPosition(boolean verifyCursorPosition) { @@ -320,9 +320,9 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt * true for JDBC drivers that supports ResultSet.absolute() as * it may improve performance, especially if a step fails while working with * a large data set. - * + * * @see ResultSet#absolute(int) - * + * * @param driverSupportsAbsolute false by default */ public void setDriverSupportsAbsolute(boolean driverSupportsAbsolute) { @@ -331,16 +331,16 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt /** * Indicate whether the connection used for the cursor should be used by all other processing - * thus sharing the same transaction. If this is set to false, which is the default, then the + * thus sharing the same transaction. If this is set to false, which is the default, then the * cursor will be opened using in its connection and will not participate in any transactions - * started for the rest of the step processing. If you set this flag to true then you must + * started for the rest of the step processing. If you set this flag to true then you must * wrap the DataSource in a {@link ExtendedConnectionDataSourceProxy} to prevent the * connection from being closed and released after each commit. - * - * When you set this option to true then the statement used to open the cursor - * will be created with both 'READ_ONLY' and 'HOLD_CUSORS_OVER_COMMIT' options. This allows - * holding the cursor open over transaction start and commits performed in the step processing. - * To use this feature you need a database that supports this and a JDBC driver supporting + * + * When you set this option to true then the statement used to open the cursor + * will be created with both 'READ_ONLY' and 'HOLD_CUSORS_OVER_COMMIT' options. This allows + * holding the cursor open over transaction start and commits performed in the step processing. + * To use this feature you need a database that supports this and a JDBC driver supporting * JDBC 3.0 or later. * * @param useSharedExtendedConnection false by default @@ -354,7 +354,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt } public abstract String getSql(); - + /** * Check the result set is in synch with the currentRow attribute. This is * important to ensure that the user hasn't modified the current row. @@ -368,10 +368,10 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt } /** - * Close the cursor and database connection. Make call to cleanupOnClose so sub classes can cleanup + * Close the cursor and database connection. Make call to cleanupOnClose so sub classes can cleanup * any resources they have allocated. */ - @Override + @Override protected void doClose() throws Exception { initialized = false; JdbcUtils.closeResultSet(this.rs); @@ -387,7 +387,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt JdbcUtils.closeConnection(this.con); } } - + protected abstract void cleanupOnClose() throws Exception; /** @@ -402,12 +402,12 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt initializeConnection(); openCursor(con); initialized = true; - + } protected void initializeConnection() { Assert.state(getDataSource() != null, "DataSource must not be null."); - + try { if (useSharedExtendedConnection) { if (!(getDataSource() instanceof ExtendedConnectionDataSourceProxy)) { @@ -427,19 +427,19 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt throw getExceptionTranslator().translate("Executing query", getSql(), se); } } - + protected abstract void openCursor(Connection con); - + /** * Read next row and map it to item, verify cursor position if * {@link #setVerifyCursorPosition(boolean)} is true. */ - @Override + @Override protected T doRead() throws Exception { if (rs == null) { throw new ReaderNotOpenException("Reader must be open before it can be read."); } - + try { if (!rs.next()) { return null; @@ -453,11 +453,11 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt throw getExceptionTranslator().translate("Attempt to process next row failed", getSql(), se); } } - + /** - * Read the cursor and map to the type of object this reader should return. This method must be + * Read the cursor and map to the type of object this reader should return. This method must be * overriden by subclasses. - * + * * @param rs The current result set * @param currentRow Current position of the result set * @return the mapped object at the cursor position @@ -469,7 +469,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt * Use {@link ResultSet#absolute(int)} if possible, otherwise scroll by * calling {@link ResultSet#next()}. */ - @Override + @Override protected void jumpToItem(int itemIndex) throws Exception { if (driverSupportsAbsolute) { try { @@ -480,7 +480,7 @@ public abstract class AbstractCursorItemReader extends AbstractItemCountingIt // traversing ResultSet log.warn("The JDBC driver does not appear to support ResultSet.absolute(). Consider" + " reverting to the default behavior setting the driverSupportsAbsolute to false", e); - + moveCursorToRow(itemIndex); } } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractPagingItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractPagingItemReader.java index e878db202..81dd39a35 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractPagingItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractPagingItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -27,20 +27,20 @@ import org.springframework.util.ClassUtils; /** * Abstract {@link org.springframework.batch.item.ItemReader} for to extend when * reading database records in a paging fashion. - * + * *

    * Implementations should execute queries using paged requests of a size * specified in {@link #setPageSize(int)}. Additional pages are requested when * needed as {@link #read()} method is called, returning an object corresponding * to current position. *

    - * + * * @author Thomas Risberg * @author Dave Syer * @since 2.0 */ public abstract class AbstractPagingItemReader extends AbstractItemCountingItemStreamItemReader implements - InitializingBean { +InitializingBean { protected Log logger = LogFactory.getLog(getClass()); @@ -78,7 +78,7 @@ public abstract class AbstractPagingItemReader extends AbstractItemCountingIt /** * The number of rows to retrieve at a time. - * + * * @param pageSize the number of rows to fetch per page */ public void setPageSize(int pageSize) { @@ -89,7 +89,7 @@ public abstract class AbstractPagingItemReader extends AbstractItemCountingIt * Check mandatory properties. * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.isTrue(pageSize > 0, "pageSize must be greater than zero"); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/BeanPropertyItemSqlParameterSourceProvider.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/BeanPropertyItemSqlParameterSourceProvider.java index d777849bc..68c23f3e5 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/BeanPropertyItemSqlParameterSourceProvider.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/BeanPropertyItemSqlParameterSourceProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -21,18 +21,18 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource; /** * A convenient implementation for providing BeanPropertySqlParameterSource when the item has JavaBean properties * that correspond to names used for parameters in the SQL statement. - * + * * @author Thomas Risberg * @since 2.0 */ public class BeanPropertyItemSqlParameterSourceProvider implements ItemSqlParameterSourceProvider { /** - * Provide parameter values in an {@link BeanPropertySqlParameterSource} based on values from + * Provide parameter values in an {@link BeanPropertySqlParameterSource} based on values from * the provided item. * @param item the item to use for parameter values */ - @Override + @Override public SqlParameterSource createSqlParameterSource(T item) { return new BeanPropertySqlParameterSource(item); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxy.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxy.java index 9af43810b..0b6f1d155 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxy.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2013 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. @@ -38,19 +38,19 @@ import org.springframework.util.Assert; * Implementation of {@link SmartDataSource} that is capable of keeping a single * JDBC Connection which is NOT closed after each use even if * {@link Connection#close()} is called. - * + * * The connection can be kept open over multiple transactions when used together * with any of Spring's * {@link org.springframework.transaction.PlatformTransactionManager} * implementations. - * + * *

    * Loosely based on the SingleConnectionDataSource implementation in Spring * Core. Intended to be used with the {@link JdbcCursorItemReader} to provide a * connection that remains open across transaction boundaries, It remains open * for the life of the cursor, and can be shared with the main transaction of * the rest of the step processing. - * + * *

    * Once close suppression has been turned on for a connection, it will be * returned for the first {@link #getConnection()} call. Any subsequent calls to @@ -64,16 +64,16 @@ import org.springframework.util.Assert; * {@link Connection} to be the main {@link Connection} for an extended data * access process. The close suppression is turned off by calling * {@link #stopCloseSuppression(Connection)}. - * + * *

    * This class is not multi-threading capable. - * + * *

    * The connection returned will be a close-suppressing proxy instead of the * physical {@link Connection}. Be aware that you will not be able to cast this * to a native OracleConnection or the like anymore; you need to * use a {@link org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor}. - * + * * @author Thomas Risberg * @see #getConnection() * @see java.sql.Connection#close() @@ -111,7 +111,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi /** * Setter for the {&link DataSource} that is to be wrapped. - * + * * @param dataSource the DataSource */ public void setDataSource(DataSource dataSource) { @@ -121,7 +121,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi /** * @see SmartDataSource */ - @Override + @Override public boolean shouldClose(Connection connection) { boolean shouldClose = !isCloseSuppressionActive(connection); if (borrowedConnection && closeSuppressedConnection.equals(connection)) { @@ -133,7 +133,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi /** * Return the status of close suppression being activated for a given * {@link Connection} - * + * * @param connection the {@link Connection} that the close suppression * status is requested for * @return true or false @@ -146,7 +146,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi } /** - * + * * @param connection the {@link Connection} that close suppression is * requested for */ @@ -160,7 +160,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi } /** - * + * * @param connection the {@link Connection} that close suppression should be * turned off for */ @@ -171,14 +171,14 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi } } - @Override + @Override public Connection getConnection() throws SQLException { synchronized (this.connectionMonitor) { return initConnection(null, null); } } - @Override + @Override public Connection getConnection(String username, String password) throws SQLException { synchronized (this.connectionMonitor) { return initConnection(username, password); @@ -210,22 +210,22 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi return connection; } - @Override + @Override public PrintWriter getLogWriter() throws SQLException { return dataSource.getLogWriter(); } - @Override + @Override public int getLoginTimeout() throws SQLException { return dataSource.getLoginTimeout(); } - @Override + @Override public void setLogWriter(PrintWriter out) throws SQLException { dataSource.setLogWriter(out); } - @Override + @Override public void setLoginTimeout(int seconds) throws SQLException { dataSource.setLoginTimeout(seconds); } @@ -257,7 +257,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi this.target = target; } - @Override + @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // Invocation on ConnectionProxy interface coming in... @@ -300,7 +300,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi * Performs only a 'shallow' non-recursive check of self's and delegate's * class to retain Java 5 compatibility. */ - @Override + @Override public boolean isWrapperFor(Class iface) throws SQLException { if (iface.isAssignableFrom(SmartDataSource.class) || iface.isAssignableFrom(dataSource.getClass())) { return true; @@ -313,7 +313,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi * cast to supplied parameter class. Does *not* support recursive unwrapping * of the delegate to retain Java 5 compatibility. */ - @Override + @Override public T unwrap(Class iface) throws SQLException { if (iface.isAssignableFrom(SmartDataSource.class)) { @SuppressWarnings("unchecked") @@ -328,7 +328,7 @@ public class ExtendedConnectionDataSourceProxy implements SmartDataSource, Initi throw new SQLException("Unsupported class " + iface.getSimpleName()); } - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(dataSource); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateCursorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateCursorItemReader.java index 7cf67ad59..9d0b8bfca 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateCursorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateCursorItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -39,8 +39,8 @@ import org.springframework.util.ClassUtils; * {@link #setQueryString(String)}, a named query can be used by * {@link #setQueryName(String)}, or a query provider strategy can be supplied * via {@link #setQueryProvider(HibernateQueryProvider)}. - * - * + * + * *

    * The reader can be configured to use either {@link StatelessSession} * sufficient for simple mappings without the need to cascade to associated @@ -49,14 +49,14 @@ import org.springframework.util.ClassUtils; * the {@link #update(ExecutionContext)} method without being flushed (no data * modifications are expected). *

    - * + * * The implementation is not thread-safe. - * + * * @author Robert Kasanicky * @author Dave Syer */ public class HibernateCursorItemReader extends AbstractItemCountingItemStreamItemReader implements ItemStream, - InitializingBean { +InitializingBean { private HibernateItemReaderHelper helper = new HibernateItemReaderHelper(); @@ -72,7 +72,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream private Map parameterValues; - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.state(fetchSize >= 0, "fetchSize must not be negative"); helper.afterPropertiesSet(); @@ -80,7 +80,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream /** * The parameter values to apply to a query (map of name:value). - * + * * @param parameterValues the parameter values to set */ public void setParameterValues(Map parameterValues) { @@ -92,7 +92,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream * {@link #setQueryString(String) query string} or the { * {@link #setQueryProvider(HibernateQueryProvider) query provider} should * be set. - * + * * @param queryName name of a hibernate named query */ public void setQueryName(String queryName) { @@ -102,7 +102,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream /** * Fetch size used internally by Hibernate to limit amount of data fetched * from database per round trip. - * + * * @param fetchSize the fetch size to pass down to Hibernate */ public void setFetchSize(int fetchSize) { @@ -113,7 +113,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream * A query provider. Either this or the {{@link #setQueryString(String) * query string} or the {{@link #setQueryName(String) query name} should be * set. - * + * * @param queryProvider Hibernate query provider */ public void setQueryProvider(HibernateQueryProvider queryProvider) { @@ -124,7 +124,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream * A query string in HQL. Either this or the { * {@link #setQueryProvider(HibernateQueryProvider) query provider} or the { * {@link #setQueryName(String) query name} should be set. - * + * * @param queryString HQL query string */ public void setQueryString(String queryString) { @@ -133,7 +133,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream /** * The Hibernate SessionFactory to use the create a session. - * + * * @param sessionFactory the {@link SessionFactory} to set */ public void setSessionFactory(SessionFactory sessionFactory) { @@ -142,7 +142,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream /** * Can be set only in uninitialized state. - * + * * @param useStatelessSession true to use * {@link StatelessSession} false to use standard hibernate * {@link Session} @@ -151,7 +151,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream helper.setUseStatelessSession(useStatelessSession); } - @Override + @Override protected T doRead() throws Exception { if (cursor.next()) { Object[] data = cursor.get(); @@ -180,7 +180,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream /** * Open hibernate session and create a forward-only cursor for the query. */ - @Override + @Override protected void doOpen() throws Exception { Assert.state(!initialized, "Cannot open an already opened ItemReader, call close first"); cursor = helper.getForwardOnlyCursor(fetchSize, parameterValues); @@ -189,7 +189,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream /** * Update the context and clear the session if stateful. - * + * * @param executionContext the current {@link ExecutionContext} * @throws ItemStreamException if there is a problem */ @@ -204,7 +204,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream * the session every now and then (if stateful) to avoid memory problems. * The frequency of session clearing is the larger of the fetch size (if * set) and 100. - * + * * @param itemIndex the first item to read * @throws Exception if there is a problem * @see AbstractItemCountingItemStreamItemReader#jumpToItem(int) @@ -218,7 +218,7 @@ public class HibernateCursorItemReader extends AbstractItemCountingItemStream /** * Close the cursor and hibernate session. */ - @Override + @Override protected void doClose() throws Exception { initialized = false; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemReaderHelper.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemReaderHelper.java index a1cb3ce50..a769f1ea6 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemReaderHelper.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemReaderHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 the original author or authors. + * Copyright 2006-2013 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. @@ -33,9 +33,9 @@ import org.springframework.util.StringUtils; /** * Internal shared state helper for hibernate readers managing sessions and * queries. - * + * * @author Dave Syer - * + * */ public class HibernateItemReaderHelper implements InitializingBean { @@ -76,7 +76,7 @@ public class HibernateItemReaderHelper implements InitializingBean { /** * Can be set only in uninitialized state. - * + * * @param useStatelessSession true to use * {@link StatelessSession} false to use standard hibernate * {@link Session} @@ -94,7 +94,7 @@ public class HibernateItemReaderHelper implements InitializingBean { this.sessionFactory = sessionFactory; } - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.state(sessionFactory != null, "A SessionFactory must be provided"); @@ -113,10 +113,10 @@ public class HibernateItemReaderHelper implements InitializingBean { /** * Get a cursor over all of the results, with the forward-only flag set. - * + * * @param fetchSize the fetch size to use retrieving the results * @param parameterValues the parameter values to use (or null if none). - * + * * @return a forward-only {@link ScrollableResults} */ public ScrollableResults getForwardOnlyCursor(int fetchSize, Map parameterValues) { @@ -172,7 +172,7 @@ public class HibernateItemReaderHelper implements InitializingBean { /** * Scroll through the results up to the item specified. - * + * * @param cursor the results to scroll over */ public void jumpToItem(ScrollableResults cursor, int itemIndex, int flushInterval) { @@ -201,7 +201,7 @@ public class HibernateItemReaderHelper implements InitializingBean { /** * Read a page of data, clearing the existing session (if necessary) first, * and creating a new session before executing the query. - * + * * @param page the page to read (starting at 0) * @param pageSize the size of the page or maximum number of items to read * @param fetchSize the fetch size to use diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemWriter.java index d1c764d0b..228567b1c 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateItemWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -33,13 +33,13 @@ import org.springframework.util.Assert; * TaskletStep). It will also clear the session on write * default (see {@link #setClearSession(boolean) clearSession} property).
    *
    - * + * * The writer is thread safe after its properties are set (normal singleton * behavior), so it can be used to write in multiple concurrent transactions. - * + * * @author Dave Syer * @author Thomas Risberg - * + * */ public class HibernateItemWriter implements ItemWriter, InitializingBean { @@ -53,7 +53,7 @@ public class HibernateItemWriter implements ItemWriter, InitializingBean { /** * Flag to indicate that the session should be cleared and flushed at the * end of the write (default true). - * + * * @param clearSession * the flag value to set */ @@ -63,7 +63,7 @@ public class HibernateItemWriter implements ItemWriter, InitializingBean { /** * Public setter for the {@link HibernateOperations} property. - * + * * @param hibernateTemplate * the hibernateTemplate to set */ @@ -74,7 +74,7 @@ public class HibernateItemWriter implements ItemWriter, InitializingBean { /** * Set the Hibernate SessionFactory to be used internally. Will * automatically create a HibernateTemplate for the given SessionFactory. - * + * * @see #setHibernateTemplate */ public final void setSessionFactory(SessionFactory sessionFactory) { @@ -84,7 +84,7 @@ public class HibernateItemWriter implements ItemWriter, InitializingBean { /** * Check mandatory properties - there must be a hibernateTemplate. */ - @Override + @Override public void afterPropertiesSet() { Assert.notNull(hibernateTemplate, "HibernateItemWriter requires a HibernateOperations"); @@ -93,10 +93,10 @@ public class HibernateItemWriter implements ItemWriter, InitializingBean { /** * Save or update any entities not in the current hibernate session and then * flush the hibernate session. - * + * * @see org.springframework.batch.item.ItemWriter#write(java.util.List) */ - @Override + @Override public final void write(List items) { doWrite(hibernateTemplate, items); hibernateTemplate.flush(); @@ -108,7 +108,7 @@ public class HibernateItemWriter implements ItemWriter, InitializingBean { /** * Do perform the actual write operation. This can be overridden in a * subclass if necessary. - * + * * @param hibernateTemplate * the HibernateTemplate to use for the operation * @param items diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernatePagingItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernatePagingItemReader.java index 34d13d040..b4c650008 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernatePagingItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernatePagingItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2013 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. @@ -37,7 +37,7 @@ import org.springframework.util.ClassUtils; * query can be used by {@link #setQueryName(String)}, or a query provider * strategy can be supplied via * {@link #setQueryProvider(HibernateQueryProvider)}. - * + * *

    * The reader can be configured to use either {@link StatelessSession} * sufficient for simple mappings without the need to cascade to associated @@ -46,16 +46,16 @@ import org.springframework.util.ClassUtils; * the {@link #update(ExecutionContext)} method without being flushed (no data * modifications are expected). *

    - * + * *

    * The implementation is thread-safe in between calls to * {@link #open(ExecutionContext)}, but remember to use * saveState=false if used in a multi-threaded client (no restart * available). *

    - * + * * @author Dave Syer - * + * * @since 2.1 */ public class HibernatePagingItemReader extends AbstractPagingItemReader implements ItemStream, InitializingBean { @@ -72,7 +72,7 @@ public class HibernatePagingItemReader extends AbstractPagingItemReader im /** * The parameter values to apply to a query (map of name:value). - * + * * @param parameterValues the parameter values to set */ public void setParameterValues(Map parameterValues) { @@ -84,7 +84,7 @@ public class HibernatePagingItemReader extends AbstractPagingItemReader im * {@link #setQueryString(String) query string} or the { * {@link #setQueryProvider(HibernateQueryProvider) query provider} should * be set. - * + * * @param queryName name of a hibernate named query */ public void setQueryName(String queryName) { @@ -94,7 +94,7 @@ public class HibernatePagingItemReader extends AbstractPagingItemReader im /** * Fetch size used internally by Hibernate to limit amount of data fetched * from database per round trip. - * + * * @param fetchSize the fetch size to pass down to Hibernate */ public void setFetchSize(int fetchSize) { @@ -105,7 +105,7 @@ public class HibernatePagingItemReader extends AbstractPagingItemReader im * A query provider. Either this or the {{@link #setQueryString(String) * query string} or the {{@link #setQueryName(String) query name} should be * set. - * + * * @param queryProvider Hibernate query provider */ public void setQueryProvider(HibernateQueryProvider queryProvider) { @@ -116,7 +116,7 @@ public class HibernatePagingItemReader extends AbstractPagingItemReader im * A query string in HQL. Either this or the { * {@link #setQueryProvider(HibernateQueryProvider) query provider} or the { * {@link #setQueryName(String) query name} should be set. - * + * * @param queryString HQL query string */ public void setQueryString(String queryString) { @@ -125,7 +125,7 @@ public class HibernatePagingItemReader extends AbstractPagingItemReader im /** * The Hibernate SessionFactory to use the create a session. - * + * * @param sessionFactory the {@link SessionFactory} to set */ public void setSessionFactory(SessionFactory sessionFactory) { @@ -134,7 +134,7 @@ public class HibernatePagingItemReader extends AbstractPagingItemReader im /** * Can be set only in uninitialized state. - * + * * @param useStatelessSession true to use * {@link StatelessSession} false to use standard hibernate * {@link Session} @@ -143,7 +143,7 @@ public class HibernatePagingItemReader extends AbstractPagingItemReader im helper.setUseStatelessSession(useStatelessSession); } - @Override + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.state(fetchSize >= 0, "fetchSize must not be negative"); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisBatchItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisBatchItemWriter.java index 8c46ec5c1..cf168b991 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisBatchItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisBatchItemWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -34,18 +34,18 @@ import com.ibatis.sqlmap.engine.execution.BatchException; import com.ibatis.sqlmap.engine.execution.BatchResult; /** - * {@link ItemWriter} that uses the batching features from - * {@link SqlMapClientTemplate} to execute a batch of statements for all items + * {@link ItemWriter} that uses the batching features from + * {@link SqlMapClientTemplate} to execute a batch of statements for all items * provided.
    - * + * * The user must provide an iBATIS statement id that points to the SQL statement defined * in the iBATIS SqlMap configuration.
    - * + * * It is expected that {@link #write(List)} is called inside a transaction.
    - * + * * The writer is thread safe after its properties are set (normal singleton * behavior), so it can be used to write in multiple concurrent transactions. - * + * * @author Thomas Risberg * @since 2.0 */ @@ -62,7 +62,7 @@ public class IbatisBatchItemWriter implements ItemWriter, InitializingBean /** * Public setter for the flag that determines whether an assertion is made * that all items cause at least one row to be updated. - * + * * @param assertUpdates the flag to set. Defaults to true; */ public void setAssertUpdates(boolean assertUpdates) { @@ -71,7 +71,7 @@ public class IbatisBatchItemWriter implements ItemWriter, InitializingBean /** * Public setter for {@link SqlMapClient} for injection purposes. - * + * * @param sqlMapClient the SqlMapClient */ public void setSqlMapClient(SqlMapClient sqlMapClient) { @@ -82,7 +82,7 @@ public class IbatisBatchItemWriter implements ItemWriter, InitializingBean /** * Public setter for the {@link SqlMapClientTemplate}. - * + * * @param sqlMapClientTemplate the SqlMapClientTemplate */ public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) { @@ -90,9 +90,9 @@ public class IbatisBatchItemWriter implements ItemWriter, InitializingBean } /** - * Public setter for the statement id identifying the statement in the SqlMap + * Public setter for the statement id identifying the statement in the SqlMap * configuration file. - * + * * @param statementId the id for the statement */ public void setStatementId(String statementId) { @@ -102,16 +102,16 @@ public class IbatisBatchItemWriter implements ItemWriter, InitializingBean /** * Check mandatory properties - there must be an SqlMapClient and a statementId. */ - @Override + @Override public void afterPropertiesSet() { Assert.notNull(sqlMapClientTemplate, "A SqlMapClient or a SqlMapClientTemplate is required."); Assert.notNull(statementId, "A statementId is required."); } - + /* (non-Javadoc) * @see org.springframework.batch.item.ItemWriter#write(java.util.List) */ - @Override + @Override public void write(final List items) { if (!items.isEmpty()) { @@ -119,11 +119,11 @@ public class IbatisBatchItemWriter implements ItemWriter, InitializingBean if (logger.isDebugEnabled()) { logger.debug("Executing batch with " + items.size() + " items."); } - + @SuppressWarnings("unchecked") List results = (List) sqlMapClientTemplate.execute( new SqlMapClientCallback() { - @Override + @Override public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException { executor.startBatch(); @@ -137,14 +137,14 @@ public class IbatisBatchItemWriter implements ItemWriter, InitializingBean } } }); - + if (assertUpdates) { if (results.size() != 1) { throw new InvalidDataAccessResourceUsageException("Batch execution returned invalid results. " + "Expected 1 but number of BatchResult objects returned was " + results.size()); } - - int[] updateCounts = results.get(0).getUpdateCounts(); + + int[] updateCounts = results.get(0).getUpdateCounts(); for (int i = 0; i < updateCounts.length; i++) { int value = updateCounts[i]; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisPagingItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisPagingItemReader.java index 5d8ff8046..afbf25dfe 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisPagingItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisPagingItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -16,14 +16,14 @@ package org.springframework.batch.item.database; -import org.springframework.util.ClassUtils; -import org.springframework.util.Assert; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CopyOnWriteArrayList; + import org.springframework.batch.item.ExecutionContext; import org.springframework.orm.ibatis.SqlMapClientTemplate; - -import java.util.Map; -import java.util.HashMap; -import java.util.concurrent.CopyOnWriteArrayList; +import org.springframework.util.Assert; +import org.springframework.util.ClassUtils; import com.ibatis.sqlmap.client.SqlMapClient; @@ -32,7 +32,7 @@ import com.ibatis.sqlmap.client.SqlMapClient; * {@link org.springframework.batch.item.ItemReader} for reading database * records using iBATIS in a paging fashion. *

    - * + * *

    * It executes the query specified as the {@link #setQueryId(String)} to * retrieve requested data. The query is executed using paged requests of a size @@ -53,20 +53,20 @@ import com.ibatis.sqlmap.client.SqlMapClient; * infinite loop in the reader because it keeps asking for the next page and * gets the same result set over and over. *

    - * + * *

    * The performance of the paging depends on the iBATIS implementation. * Setting a fairly large page size and using a commit interval that matches the * page size should provide better performance. *

    - * + * *

    * The implementation is thread-safe in between calls to * {@link #open(ExecutionContext)}, but remember to use * saveState=false if used in a multi-threaded client (no restart * available). *

    - * + * * @author Thomas Risberg * @author Dave Syer * @since 2.0 @@ -95,7 +95,7 @@ public class IbatisPagingItemReader extends AbstractPagingItemReader { /** * The parameter values to be used for the query execution. - * + * * @param parameterValues the values keyed by the parameter named used in * the query string. */ @@ -107,7 +107,7 @@ public class IbatisPagingItemReader extends AbstractPagingItemReader { * Check mandatory properties. * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ - @Override + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(sqlMapClient); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcBatchItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcBatchItemWriter.java index da843354f..b9dcfc2ec 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcBatchItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcBatchItemWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -30,29 +30,29 @@ import org.springframework.dao.DataAccessException; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.jdbc.core.PreparedStatementCallback; -import org.springframework.jdbc.core.namedparam.SqlParameterSource; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; +import org.springframework.jdbc.core.namedparam.SqlParameterSource; import org.springframework.util.Assert; /** - *

    {@link ItemWriter} that uses the batching features from + *

    {@link ItemWriter} that uses the batching features from * {@link NamedParameterJdbcTemplate} to execute a batch of statements for all items * provided.

    - * - * The user must provide an SQL query and a special callback in the for of either + * + * The user must provide an SQL query and a special callback in the for of either * {@link ItemPreparedStatementSetter}, or a {@link ItemSqlParameterSourceProvider}. - * You can use either named parameters or the traditional '?' placeholders. If you use the - * named parameter support then you should provide a {@link ItemSqlParameterSourceProvider}, + * You can use either named parameters or the traditional '?' placeholders. If you use the + * named parameter support then you should provide a {@link ItemSqlParameterSourceProvider}, * otherwise you should provide a {@link ItemPreparedStatementSetter}. - * This callback would be responsible for mapping the item to the parameters needed to + * This callback would be responsible for mapping the item to the parameters needed to * execute the SQL statement.
    - * + * * It is expected that {@link #write(List)} is called inside a transaction.
    - * + * * The writer is thread safe after its properties are set (normal singleton * behavior), so it can be used to write in multiple concurrent transactions. - * + * * @author Dave Syer * @author Thomas Risberg * @since 2.0 @@ -114,7 +114,7 @@ public class JdbcBatchItemWriter implements ItemWriter, InitializingBean { /** * Public setter for the data source for injection purposes. - * + * * @param dataSource */ public void setDataSource(DataSource dataSource) { @@ -132,10 +132,10 @@ public class JdbcBatchItemWriter implements ItemWriter, InitializingBean { } /** - * Check mandatory properties - there must be a SimpleJdbcTemplate and an SQL statement plus a + * Check mandatory properties - there must be a SimpleJdbcTemplate and an SQL statement plus a * parameter source. */ - @Override + @Override public void afterPropertiesSet() { Assert.notNull(namedParameterJdbcTemplate, "A DataSource or a NamedParameterJdbcTemplate is required."); Assert.notNull(sql, "An SQL statement is required."); @@ -154,11 +154,11 @@ public class JdbcBatchItemWriter implements ItemWriter, InitializingBean { Assert.notNull(itemPreparedStatementSetter, "Using SQL statement with '?' placeholders requires an ItemPreparedStatementSetter"); } } - + /* (non-Javadoc) * @see org.springframework.batch.item.ItemWriter#write(java.util.List) */ - @Override + @Override public void write(final List items) throws Exception { if (!items.isEmpty()) { @@ -168,7 +168,7 @@ public class JdbcBatchItemWriter implements ItemWriter, InitializingBean { } int[] updateCounts = null; - + if (usingNamedParameters) { SqlParameterSource[] batchArgs = new SqlParameterSource[items.size()]; int i = 0; @@ -179,7 +179,7 @@ public class JdbcBatchItemWriter implements ItemWriter, InitializingBean { } else { updateCounts = (int[]) namedParameterJdbcTemplate.getJdbcOperations().execute(sql, new PreparedStatementCallback() { - @Override + @Override public Object doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException { for (T item : items) { itemPreparedStatementSetter.setValues(item, ps); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcCursorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcCursorItemReader.java index 977977ab5..1404bdd78 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcCursorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcCursorItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -21,7 +21,6 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; - import org.springframework.jdbc.core.PreparedStatementSetter; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.support.JdbcUtils; @@ -31,26 +30,27 @@ import org.springframework.util.ClassUtils; /** *

    * Simple item reader implementation that opens a JDBC cursor and continually retrieves the - * next row in the ResultSet. + * next row in the ResultSet. *

    - * + * *

    - * The statement used to open the cursor is created with the 'READ_ONLY' option since a non read-only - * cursor may unnecessarily lock tables or rows. It is also opened with 'TYPE_FORWARD_ONLY' option. - * By default the cursor will be opened using a separate connection which means that it will not participate + * The statement used to open the cursor is created with the 'READ_ONLY' option since a non read-only + * cursor may unnecessarily lock tables or rows. It is also opened with 'TYPE_FORWARD_ONLY' option. + * By default the cursor will be opened using a separate connection which means that it will not participate * in any transactions created as part of the step processing. *

    - * + * *

    * Each call to {@link #read()} will call the provided RowMapper, passing in the - * ResultSet. + * ResultSet. *

    - * + * * @author Lucas Ward * @author Peter Zozom * @author Robert Kasanicky * @author Thomas Risberg */ +@SuppressWarnings("rawtypes") public class JdbcCursorItemReader extends AbstractCursorItemReader { PreparedStatement preparedStatement; @@ -68,7 +68,7 @@ public class JdbcCursorItemReader extends AbstractCursorItemReader { /** * Set the RowMapper to be used for all calls to read(). - * + * * @param rowMapper */ public void setRowMapper(RowMapper rowMapper) { @@ -79,7 +79,7 @@ public class JdbcCursorItemReader extends AbstractCursorItemReader { * Set the SQL statement to be used when creating the cursor. This statement * should be a complete and valid SQL statement, as it will be run directly * without any modification. - * + * * @param sql */ public void setSql(String sql) { @@ -89,7 +89,7 @@ public class JdbcCursorItemReader extends AbstractCursorItemReader { /** * Set the PreparedStatementSetter to use if any parameter values that need * to be set in the supplied query. - * + * * @param preparedStatementSetter */ public void setPreparedStatementSetter(PreparedStatementSetter preparedStatementSetter) { @@ -98,11 +98,11 @@ public class JdbcCursorItemReader extends AbstractCursorItemReader { /** * Assert that mandatory properties are set. - * + * * @throws IllegalArgumentException if either data source or sql properties * not set. */ - @Override + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(sql, "The SQL query must be provided"); @@ -110,7 +110,7 @@ public class JdbcCursorItemReader extends AbstractCursorItemReader { } - @Override + @Override protected void openCursor(Connection con) { try { if (isUseSharedExtendedConnection()) { @@ -131,20 +131,20 @@ public class JdbcCursorItemReader extends AbstractCursorItemReader { close(); throw getExceptionTranslator().translate("Executing query", getSql(), se); } - + } - @Override + @Override @SuppressWarnings("unchecked") protected T readCursor(ResultSet rs, int currentRow) throws SQLException { return (T) rowMapper.mapRow(rs, currentRow); } - + /** * Close the cursor and database connection. */ - @Override + @Override protected void cleanupOnClose() throws Exception { JdbcUtils.closeStatement(this.preparedStatement); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaItemWriter.java index 34c158330..803a24809 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaItemWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -33,18 +33,18 @@ import org.springframework.util.Assert; * {@link org.springframework.batch.item.ItemWriter} that is using a JPA * EntityManagerFactory to merge any Entities that aren't part of the * persistence context. - * + * * It is required that {@link #write(List)} is called inside a transaction.
    - * + * * The reader must be configured with an * {@link javax.persistence.EntityManagerFactory} that is capable of * participating in Spring managed transactions. - * + * * The writer is thread safe after its properties are set (normal singleton * behaviour), so it can be used to write in multiple concurrent transactions. - * + * * @author Thomas Risberg - * + * */ public class JpaItemWriter implements ItemWriter, InitializingBean { @@ -54,7 +54,7 @@ public class JpaItemWriter implements ItemWriter, InitializingBean { /** * Set the EntityManager to be used internally. - * + * * @param entityManagerFactory the entityManagerFactory to set */ public void setEntityManagerFactory(EntityManagerFactory entityManagerFactory) { @@ -64,7 +64,7 @@ public class JpaItemWriter implements ItemWriter, InitializingBean { /** * Check mandatory properties - there must be an entityManagerFactory. */ - @Override + @Override public void afterPropertiesSet() throws Exception { Assert.notNull(entityManagerFactory, "An EntityManagerFactory is required"); } @@ -72,10 +72,10 @@ public class JpaItemWriter implements ItemWriter, InitializingBean { /** * Merge all provided items that aren't already in the persistence context * and then flush the entity manager. - * + * * @see org.springframework.batch.item.ItemWriter#write(java.util.List) */ - @Override + @Override public final void write(List items) { EntityManager entityManager = EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerFactory); if (entityManager == null) { @@ -88,7 +88,7 @@ public class JpaItemWriter implements ItemWriter, InitializingBean { /** * Do perform the actual write operation. This can be overridden in a * subclass if necessary. - * + * * @param entityManager the EntityManager to use for the operation * @param items the list of items to use for the write */ diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaPagingItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaPagingItemReader.java index 7f07b3b06..fd8c002fd 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaPagingItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JpaPagingItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -36,7 +36,7 @@ import org.springframework.util.ClassUtils; * {@link org.springframework.batch.item.ItemReader} for reading database * records built on top of JPA. *

    - * + * *

    * It executes the JPQL {@link #setQueryString(String)} to retrieve requested * data. The query is executed using paged requests of a size specified in @@ -44,39 +44,39 @@ import org.springframework.util.ClassUtils; * {@link #read()} method is called, returning an object corresponding to * current position. *

    - * + * *

    * The performance of the paging depends on the JPA implementation and its use * of database specific features to limit the number of returned rows. *

    - * + * *

    * Setting a fairly large page size and using a commit interval that matches the * page size should provide better performance. *

    - * + * *

    * In order to reduce the memory usage for large results the persistence context * is flushed and cleared after each page is read. This causes any entities read * to be detached. If you make changes to the entities and want the changes * persisted then you must explicitly merge the entities. *

    - * + * *

    * The reader must be configured with an * {@link javax.persistence.EntityManagerFactory}. All entity access is * performed within a new transaction, independent of any existing Spring * managed transactions. *

    - * + * *

    * The implementation is thread-safe in between calls to * {@link #open(ExecutionContext)}, but remember to use * saveState=false if used in a multi-threaded client (no restart * available). *

    - * - * + * + * * @author Thomas Risberg * @author Dave Syer * @since 2.0 @@ -118,7 +118,7 @@ public class JpaPagingItemReader extends AbstractPagingItemReader { /** * The parameter values to be used for the query execution. - * + * * @param parameterValues the values keyed by the parameter named used in * the query string. */ @@ -126,7 +126,7 @@ public class JpaPagingItemReader extends AbstractPagingItemReader { this.parameterValues = parameterValues; } - @Override + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/StoredProcedureItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/StoredProcedureItemReader.java index 8ad6e4985..e63387c64 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/StoredProcedureItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/StoredProcedureItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2013 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. @@ -34,27 +34,28 @@ import org.springframework.util.ClassUtils; /** *

    - * Item reader implementation that executes a stored procedure and then reads the returned cursor - * and continually retrieves the next row in the ResultSet. + * Item reader implementation that executes a stored procedure and then reads the returned cursor + * and continually retrieves the next row in the ResultSet. *

    - * + * *

    - * The callable statement used to open the cursor is created with the 'READ_ONLY' option as well as with the - * 'TYPE_FORWARD_ONLY' option. By default the cursor will be opened using a separate connection which means + * The callable statement used to open the cursor is created with the 'READ_ONLY' option as well as with the + * 'TYPE_FORWARD_ONLY' option. By default the cursor will be opened using a separate connection which means * that it will not participate in any transactions created as part of the step processing. *

    - * + * *

    * Each call to {@link #read()} will call the provided RowMapper, passing in the - * ResultSet. + * ResultSet. *

    - * + * *

    - * This class is modeled after the similar JdbcCursorItemReader class. + * This class is modeled after the similar JdbcCursorItemReader class. *

    - * + * * @author Thomas Risberg */ +@SuppressWarnings("rawtypes") public class StoredProcedureItemReader extends AbstractCursorItemReader { private CallableStatement callableStatement; @@ -62,15 +63,15 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { private PreparedStatementSetter preparedStatementSetter; private String procedureName; - + private String callString; private RowMapper rowMapper; private SqlParameter[] parameters = new SqlParameter[0]; - + private boolean function = false; - + private int refCursorPosition = 0; public StoredProcedureItemReader() { @@ -80,7 +81,7 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { /** * Set the RowMapper to be used for all calls to read(). - * + * * @param rowMapper */ public void setRowMapper(RowMapper rowMapper) { @@ -91,7 +92,7 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { * Set the SQL statement to be used when creating the cursor. This statement * should be a complete and valid SQL statement, as it will be run directly * without any modification. - * + * * @param sprocedureName */ public void setProcedureName(String sprocedureName) { @@ -101,7 +102,7 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { /** * Set the PreparedStatementSetter to use if any parameter values that need * to be set in the supplied query. - * + * * @param preparedStatementSetter */ public void setPreparedStatementSetter(PreparedStatementSetter preparedStatementSetter) { @@ -109,15 +110,15 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { } /** - * Add one or more declared parameters. Used for configuring this operation when used in a - * bean factory. Each parameter will specify SQL type and (optionally) the parameter's name. - * + * Add one or more declared parameters. Used for configuring this operation when used in a + * bean factory. Each parameter will specify SQL type and (optionally) the parameter's name. + * * @param parameters Array containing the declared SqlParameter objects */ public void setParameters(SqlParameter[] parameters) { this.parameters = parameters; } - + /** * Set whether this stored procedure is a function. */ @@ -127,9 +128,9 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { /** * Set the parameter position of the REF CURSOR. Only used for Oracle and - * PostgreSQL that use REF CURSORs. For any other database this should be + * PostgreSQL that use REF CURSORs. For any other database this should be * kept as 0 which is the default. - * + * * @param refCursorPosition The parameter position of the REF CURSOR */ public void setRefCursorPosition(int refCursorPosition) { @@ -138,27 +139,27 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { /** * Assert that mandatory properties are set. - * + * * @throws IllegalArgumentException if either data source or sql properties * not set. */ - @Override + @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(procedureName, "The name of the stored procedure must be provided"); Assert.notNull(rowMapper, "RowMapper must be provided"); } - @Override + @Override protected void openCursor(Connection con) { Assert.state(procedureName != null, "Procedure Name must not be null."); - Assert.state(refCursorPosition >= 0, + Assert.state(refCursorPosition >= 0, "invalid refCursorPosition specified as " + refCursorPosition + "; it can't be " + "specified as a negative number."); - Assert.state(refCursorPosition == 0 || refCursorPosition > 0, - "invalid refCursorPosition specified as " + refCursorPosition + "; there are " + - parameters.length + " parameters defined."); + Assert.state(refCursorPosition == 0 || refCursorPosition > 0, + "invalid refCursorPosition specified as " + refCursorPosition + "; there are " + + parameters.length + " parameters defined."); CallMetaDataContext callContext = new CallMetaDataContext(); callContext.setAccessCallParameterMetaData(false); @@ -170,7 +171,7 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { this.callString = callContext.createCallString(); log.debug("Call string is: " + callString); - + int cursorSqlType = Types.OTHER; if (function) { if (cursorParameter instanceof SqlOutParameter) { @@ -182,7 +183,7 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { cursorSqlType = parameters[refCursorPosition - 1].getSqlType(); } } - + try { if (isUseSharedExtendedConnection()) { callableStatement = con.prepareCall(callString, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, @@ -195,7 +196,7 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { if (this.preparedStatementSetter != null) { preparedStatementSetter.setValues(callableStatement); } - + if (function) { callableStatement.registerOutParameter(1, cursorSqlType); } @@ -225,7 +226,7 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { } - @Override + @Override @SuppressWarnings("unchecked") protected T readCursor(ResultSet rs, int currentRow) throws SQLException { return (T) rowMapper.mapRow(rs, currentRow); @@ -234,7 +235,7 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { /** * Close the cursor and database connection. */ - @Override + @Override protected void cleanupOnClose() throws Exception { JdbcUtils.closeStatement(this.callableStatement); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/AbstractHibernateQueryProvider.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/AbstractHibernateQueryProvider.java index 872e5626a..f2e744037 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/AbstractHibernateQueryProvider.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/AbstractHibernateQueryProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -21,44 +21,44 @@ import org.hibernate.Session; import org.hibernate.StatelessSession; /** - *

    Abstract Hibernate Query Provider to serve as a base class for all + *

    Abstract Hibernate Query Provider to serve as a base class for all * Hibernate {@link Query} providers.

    - * - *

    The implementing provider can be configured to use either - * {@link StatelessSession} sufficient for simple mappings without the need - * to cascade to associated objects or standard Hibernate {@link Session} + * + *

    The implementing provider can be configured to use either + * {@link StatelessSession} sufficient for simple mappings without the need + * to cascade to associated objects or standard Hibernate {@link Session} * for more advanced mappings or when caching is desired.

    - * + * * @author Anatoly Polinsky * @author Dave Syer - * + * * @since 2.1 * */ public abstract class AbstractHibernateQueryProvider implements HibernateQueryProvider { - - private StatelessSession statelessSession; - private Session statefulSession; - - @Override - public void setStatelessSession(StatelessSession statelessSession) { + + private StatelessSession statelessSession; + private Session statefulSession; + + @Override + public void setStatelessSession(StatelessSession statelessSession) { this.statelessSession = statelessSession; } - @Override + @Override public void setSession(Session statefulSession) { this.statefulSession = statefulSession; } public boolean isStatelessSession() { - return this.statefulSession==null && this.statelessSession!=null; - } - - protected StatelessSession getStatelessSession() { - return statelessSession; + return this.statefulSession==null && this.statelessSession!=null; } - protected Session getStatefulSession() { - return statefulSession; - } + protected StatelessSession getStatelessSession() { + return statelessSession; + } + + protected Session getStatefulSession() { + return statefulSession; + } } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/AbstractJpaQueryProvider.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/AbstractJpaQueryProvider.java index 3026ebfd9..118dc34bb 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/AbstractJpaQueryProvider.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/orm/AbstractJpaQueryProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2013 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. @@ -26,10 +26,10 @@ import org.springframework.beans.factory.InitializingBean; * Abstract JPA Query Provider to serve as a base class for all JPA * {@link Query} providers. *

    - * + * * @author Anatoly Polinsky * @author Dave Syer - * + * * @since 2.1 */ public abstract class AbstractJpaQueryProvider implements JpaQueryProvider, InitializingBean { @@ -42,10 +42,10 @@ public abstract class AbstractJpaQueryProvider implements JpaQueryProvider, Init * {@link HibernateQueryProvider}. This is currently needed to allow * {@link HibernateQueryProvider} to participate in a user's managed transaction. *

    - * + * * @param entityManager */ - @Override + @Override public void setEntityManager(EntityManager entityManager) { this.entityManager = entityManager; } @@ -54,7 +54,7 @@ public abstract class AbstractJpaQueryProvider implements JpaQueryProvider, Init *

    * Getter for {@link EntityManager} *

    - * + * * @return entityManager the injected {@link EntityManager} */ protected EntityManager getEntityManager() {