From 9524084e5b60507f3b812b9893223472e732313b Mon Sep 17 00:00:00 2001 From: Michael Minella Date: Mon, 29 Jul 2013 09:39:41 -0500 Subject: [PATCH] BATCH-2004: Updated per review comments --- spring-batch-core/pom.xml | 2 +- .../xml/StepParserStepFactoryBean.java | 2 +- .../batch/core/jsr/ChunkListenerAdapter.java | 2 +- .../core/jsr/ItemProcessListenerAdapter.java | 4 ++-- .../batch/core/jsr/JsrJobListenerMetaData.java | 10 ++++------ .../batch/core/jsr/SkipListenerAdapter.java | 7 ++++--- .../batch/core/jsr/launch/JsrJobOperator.java | 15 +++++++++------ 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/spring-batch-core/pom.xml b/spring-batch-core/pom.xml index 2b8268cfa..6432c8ea2 100644 --- a/spring-batch-core/pom.xml +++ b/spring-batch-core/pom.xml @@ -21,7 +21,7 @@ javax.batch javax.batch-api - 1.0-b29 + 1.0 com.ibm.jbatch 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 a48d4be9a..bc4b687f3 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 @@ -402,7 +402,7 @@ public class StepParserStepFactoryBean implements FactoryBean, BeanNameAwa CompositeCompletionPolicy completionPolicy = new CompositeCompletionPolicy(); CompletionPolicy [] policies = new CompletionPolicy[2]; policies[0] = new SimpleCompletionPolicy(commitInterval); - policies[1] = new TimeoutTerminationPolicy(timeout); + policies[1] = new TimeoutTerminationPolicy(timeout * 1000); completionPolicy.setPolicies(policies); builder.chunk(completionPolicy); } else if(timeout != null) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/ChunkListenerAdapter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/ChunkListenerAdapter.java index 68e902422..bfae4112a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/ChunkListenerAdapter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/ChunkListenerAdapter.java @@ -67,7 +67,7 @@ public class ChunkListenerAdapter implements ChunkListener { throw new BatchRuntimeException(e); } } else { - throw new BatchRuntimeException("Unable to retrieve causing exception"); + throw new BatchRuntimeException("Unable to retrieve causing exception due to null ChunkContext"); } } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/ItemProcessListenerAdapter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/ItemProcessListenerAdapter.java index ac031de69..5a514f270 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/ItemProcessListenerAdapter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/ItemProcessListenerAdapter.java @@ -22,7 +22,7 @@ import org.springframework.util.Assert; /** * Wrapper class for {@link javax.batch.api.chunk.listener.ItemProcessListener} - * + * * @author Michael Minella * * @param input type @@ -64,7 +64,7 @@ public class ItemProcessListenerAdapter implements ItemProcessListener annotation; private static final Map propertyMap; - JsrJobListenerMetaData(String methodName, String propertyName, Class annotation) { + JsrJobListenerMetaData(String methodName, String propertyName) { this.methodName = methodName; this.propertyName = propertyName; - this.annotation = annotation; } static{ @@ -59,7 +57,7 @@ public enum JsrJobListenerMetaData implements ListenerMetaData { @Override public Class getAnnotation() { - return annotation; + return null; } @Override diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/SkipListenerAdapter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/SkipListenerAdapter.java index 60904a0c7..ab0834c5f 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/SkipListenerAdapter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/SkipListenerAdapter.java @@ -3,6 +3,7 @@ package org.springframework.batch.core.jsr; import javax.batch.api.chunk.listener.SkipProcessListener; import javax.batch.api.chunk.listener.SkipReadListener; import javax.batch.api.chunk.listener.SkipWriteListener; +import javax.batch.operations.BatchRuntimeException; import org.springframework.batch.core.SkipListener; @@ -24,14 +25,14 @@ public class SkipListenerAdapter implements SkipListener { try { skipReadDelegate.onSkipReadItem((Exception) t); } catch (Exception e) { - //TODO: Do something here + throw new BatchRuntimeException(e); } } } @Override public void onSkipInWrite(S item, Throwable t) { - //TODO: Awating information on the JSR's method + //TODO: This will take more than just wrapping... } @Override @@ -40,7 +41,7 @@ public class SkipListenerAdapter implements SkipListener { try { skipProcessDelegate.onSkipProcessItem(item, (Exception) t); } catch (Exception e) { - //TODO: Do something here + throw new BatchRuntimeException(e); } } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/launch/JsrJobOperator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/launch/JsrJobOperator.java index f6becc767..c1d4347d7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/launch/JsrJobOperator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/launch/JsrJobOperator.java @@ -21,6 +21,7 @@ import java.util.List; import java.util.Properties; import java.util.Set; +import javax.batch.operations.BatchRuntimeException; import javax.batch.operations.JobExecutionAlreadyCompleteException; import javax.batch.operations.JobExecutionIsRunningException; import javax.batch.operations.JobExecutionNotMostRecentException; @@ -62,29 +63,29 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; /** * The entrance for executing batch jobs as defined by JSR-352. This class provides * a base {@link ApplicationContext} that is the equivalent to the following: - * + * *
  * 	@Configuration
  * 	@EnableBatchProcessing
  * 	public static class BaseConfiguration extends DefaultBatchConfigurer {
- * 
+ *
  * 		@Bean
  * 		JobLauncher jobLauncher() { ... }
- * 
+ *
  * 		@Bean
  * 		org.springframework.batch.core.launch.JobOperator batchJobOperator(JobExplorer jobExplorer,
  * 																		   JobLauncher jobLauncher,
  * 																		   JobRepository jobRepository,
  * 																		   JobRegistry jobRegistry)  { ... }
- * 
+ *
  * 		@Bean
  * 		JobExplorerFactoryBean jobExplorer(final DataSource dataSource)  { ... }
- * 
+ *
  * 		@Bean
  * 		DataSource dataSource()  { ... }
  * 	}
  * 
- * + * * @author Michael Minella * @since 3.0 * @see EnableBatchProcessing @@ -105,6 +106,7 @@ public class JsrJobOperator implements JobOperator { ((SimpleJobLauncher) jobLauncher).afterPropertiesSet(); ((SimpleJobOperator) batchJobOperator).afterPropertiesSet(); } catch (Exception e) { + throw new BatchRuntimeException("Unable to bootstrap JobOperator", e); } } @@ -220,6 +222,7 @@ public class JsrJobOperator implements JobOperator { } @Override + @SuppressWarnings("resource") public long start(String jobName, Properties params) throws JobStartException, JobSecurityException { GenericXmlApplicationContext batchContext = new GenericXmlApplicationContext();