RESOLVED - issue BATCH-201: Move responsibility for deciding if an exception terminates a batch to ExceptionHandler

http://opensource.atlassian.com/projects/spring/browse/BATCH-201

Change RepeatInterceptor as well to use ExitStatus instead of Object
This commit is contained in:
dsyer
2007-11-20 19:24:45 +00:00
parent 85ced3551d
commit 70571b1ec3
7 changed files with 16 additions and 14 deletions

View File

@@ -42,11 +42,9 @@ public interface RepeatInterceptor {
* @param context
* the current batch context
* @param result
* the result of the callback item - ExitStatus in normal
* circumstances, but might be null or an Exception in abnormal
* cases.
* the result of the callback
*/
void after(RepeatContext context, Object result);
void after(RepeatContext context, ExitStatus result);
/**
* Called once at the start of a complete batch, before any items are

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.batch.repeat.interceptor;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.batch.repeat.RepeatContext;
import org.springframework.batch.repeat.RepeatInterceptor;
import org.springframework.context.ApplicationEventPublisher;
@@ -41,7 +42,7 @@ public class ApplicationEventPublisherRepeatInterceptor implements ApplicationEv
* @see org.springframework.batch.repeat.RepeatInterceptor#after(org.springframework.batch.repeat.RepeatContext,
* java.lang.Object)
*/
public void after(RepeatContext context, Object result) {
public void after(RepeatContext context, ExitStatus result) {
publish(context, "After repeat callback with result=[" + result + "]", RepeatOperationsApplicationEvent.AFTER);
}

View File

@@ -16,6 +16,7 @@
package org.springframework.batch.repeat.interceptor;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.batch.repeat.RepeatContext;
import org.springframework.batch.repeat.RepeatInterceptor;
@@ -24,7 +25,7 @@ public class RepeatInterceptorAdapter implements RepeatInterceptor {
public void before(RepeatContext context) {
}
public void after(RepeatContext context, Object result) {
public void after(RepeatContext context, ExitStatus result) {
}
public void close(RepeatContext context) {

View File

@@ -50,7 +50,7 @@ import org.springframework.util.Assert;
* the {@link RepeatCallback} can consider using a custom
* {@link RepeatInterceptor} instead of trying to customise the
* {@link CompletionPolicy}. This is generally a friendlier interface to
* implement, and the {@link RepeatInterceptor#after(RepeatContext, Object)}
* implement, and the {@link RepeatInterceptor#after(RepeatContext, ExitStatus)}
* method is passed in the result of the callback, which would be an instance of
* {@link Throwable} if the business processing had thrown an exception. If the
* exception is not to be propagated to the caller, then a non-default

View File

@@ -18,6 +18,7 @@ package org.springframework.batch.repeat.interceptor;
import java.util.ArrayList;
import java.util.List;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.batch.repeat.RepeatContext;
import org.springframework.batch.repeat.context.RepeatContextSupport;
import org.springframework.context.ApplicationEvent;
@@ -50,10 +51,10 @@ public class ApplicationEventPublisherRepeatInterceptorTests extends TestCase {
}
/**
* Test method for {@link org.springframework.batch.repeat.interceptor.ApplicationEventPublisherRepeatInterceptor#after(org.springframework.batch.repeat.RepeatContext, java.lang.Object)}.
* Test method for {@link org.springframework.batch.repeat.interceptor.ApplicationEventPublisherRepeatInterceptor#after(org.springframework.batch.repeat.RepeatContext, ExitStatus)}.
*/
public void testAfter() {
interceptor.after(context, Boolean.TRUE);
interceptor.after(context, ExitStatus.CONTINUABLE);
assertEquals(1, list.size());
RepeatOperationsApplicationEvent event = (RepeatOperationsApplicationEvent) list.get(0);
assertEquals(RepeatOperationsApplicationEvent.AFTER, event.getType());

View File

@@ -83,11 +83,11 @@ public class RepeatInterceptorTests extends TestCase {
RepeatTemplate template = new RepeatTemplate();
final List calls = new ArrayList();
template.setInterceptors(new RepeatInterceptor[] { new RepeatInterceptorAdapter() {
public void after(RepeatContext context, Object result) {
public void after(RepeatContext context, ExitStatus result) {
calls.add("1");
}
}, new RepeatInterceptorAdapter() {
public void after(RepeatContext context, Object result) {
public void after(RepeatContext context, ExitStatus result) {
calls.add("2");
}
} });
@@ -201,7 +201,7 @@ public class RepeatInterceptorTests extends TestCase {
RepeatTemplate template = new RepeatTemplate();
final List calls = new ArrayList();
template.setInterceptors(new RepeatInterceptor[] { new RepeatInterceptorAdapter() {
public void after(RepeatContext context, Object result) {
public void after(RepeatContext context, ExitStatus result) {
calls.add("1");
}
}, new RepeatInterceptorAdapter() {
@@ -231,7 +231,7 @@ public class RepeatInterceptorTests extends TestCase {
final List calls = new ArrayList();
final List fails = new ArrayList();
template.setInterceptors(new RepeatInterceptor[] { new RepeatInterceptorAdapter() {
public void after(RepeatContext context, Object result) {
public void after(RepeatContext context, ExitStatus result) {
calls.add("1");
}
}, new RepeatInterceptorAdapter() {

View File

@@ -18,6 +18,7 @@ package org.springframework.batch.sample.dao;
import java.util.ArrayList;
import java.util.List;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.batch.repeat.RepeatContext;
import org.springframework.batch.repeat.RepeatInterceptor;
import org.springframework.batch.sample.domain.CustomerCredit;
@@ -80,7 +81,7 @@ public class HibernateCreditWriter extends HibernateDaoSupport implements
this.failOnFlush = failOnFlush;
}
public void after(RepeatContext context, Object result) {
public void after(RepeatContext context, ExitStatus result) {
}
public void before(RepeatContext context) {