Refine contribution #3934
* Add default methods in all listener interfaces * Remove usage of newly deprecated support classes Issue #3924
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2018 the original author or authors.
|
||||
* Copyright 2006-2021 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,8 @@ public interface ItemProcessListener<T, S> extends StepListener {
|
||||
*
|
||||
* @param item to be processed.
|
||||
*/
|
||||
void beforeProcess(T item);
|
||||
default void beforeProcess(T item) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after {@link ItemProcessor#process(Object)} returns. If the
|
||||
@@ -45,7 +46,8 @@ public interface ItemProcessListener<T, S> extends StepListener {
|
||||
* @param item to be processed
|
||||
* @param result of processing
|
||||
*/
|
||||
void afterProcess(T item, @Nullable S result);
|
||||
default void afterProcess(T item, @Nullable S result) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called if an exception was thrown from {@link ItemProcessor#process(Object)}.
|
||||
@@ -53,5 +55,6 @@ public interface ItemProcessListener<T, S> extends StepListener {
|
||||
* @param item attempted to be processed
|
||||
* @param e - exception thrown during processing.
|
||||
*/
|
||||
void onProcessError(T item, Exception e);
|
||||
default void onProcessError(T item, Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ public interface ItemReadListener<T> extends StepListener {
|
||||
/**
|
||||
* Called before {@link ItemReader#read()}
|
||||
*/
|
||||
void beforeRead();
|
||||
default void beforeRead() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after {@link ItemReader#read()}.
|
||||
@@ -39,12 +40,14 @@ public interface ItemReadListener<T> extends StepListener {
|
||||
*
|
||||
* @param item returned from read()
|
||||
*/
|
||||
void afterRead(T item);
|
||||
default void afterRead(T item) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called if an error occurs while trying to read.
|
||||
*
|
||||
* @param ex thrown from {@link ItemReader}
|
||||
*/
|
||||
void onReadError(Exception ex);
|
||||
default void onReadError(Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2013 the original author or authors.
|
||||
* Copyright 2006-2021 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,6 +38,7 @@ import org.springframework.batch.item.ItemWriter;
|
||||
*</p>
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public interface ItemWriteListener<S> extends StepListener {
|
||||
@@ -47,7 +48,8 @@ public interface ItemWriteListener<S> extends StepListener {
|
||||
*
|
||||
* @param items to be written
|
||||
*/
|
||||
void beforeWrite(List<? extends S> items);
|
||||
default void beforeWrite(List<? extends S> items) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after {@link ItemWriter#write(java.util.List)} This will be
|
||||
@@ -56,7 +58,8 @@ public interface ItemWriteListener<S> extends StepListener {
|
||||
*
|
||||
* @param items written items
|
||||
*/
|
||||
void afterWrite(List<? extends S> items);
|
||||
default void afterWrite(List<? extends S> items) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called if an error occurs while trying to write. Will be called inside a
|
||||
@@ -67,5 +70,6 @@ public interface ItemWriteListener<S> extends StepListener {
|
||||
* @param exception thrown from {@link ItemWriter}
|
||||
* @param items attempted to be written.
|
||||
*/
|
||||
void onWriteError(Exception exception, List<? extends S> items);
|
||||
default void onWriteError(Exception exception, List<? extends S> items) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2021 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,6 +25,7 @@ package org.springframework.batch.core;
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Robert Kasanicky
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public interface SkipListener<T,S> extends StepListener {
|
||||
@@ -37,7 +38,8 @@ public interface SkipListener<T,S> extends StepListener {
|
||||
*
|
||||
* @param t cause of the failure
|
||||
*/
|
||||
void onSkipInRead(Throwable t);
|
||||
default void onSkipInRead(Throwable t) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This item failed on write with the given exception, and a skip was called
|
||||
@@ -46,7 +48,8 @@ public interface SkipListener<T,S> extends StepListener {
|
||||
* @param item the failed item
|
||||
* @param t the cause of the failure
|
||||
*/
|
||||
void onSkipInWrite(S item, Throwable t);
|
||||
default void onSkipInWrite(S item, Throwable t) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This item failed on processing with the given exception, and a skip was called
|
||||
@@ -55,6 +58,7 @@ public interface SkipListener<T,S> extends StepListener {
|
||||
* @param item the failed item
|
||||
* @param t the cause of the failure
|
||||
*/
|
||||
void onSkipInProcess(T item, Throwable t);
|
||||
default void onSkipInProcess(T item, Throwable t) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2019 the original author or authors.
|
||||
* Copyright 2006-2021 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,6 +19,7 @@ import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.support.PatternMatcher;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -37,9 +38,10 @@ import org.springframework.util.Assert;
|
||||
* promotion will only occur for steps with an exit code of "COMPLETED".
|
||||
*
|
||||
* @author Dan Garrette
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
public class ExecutionContextPromotionListener extends StepExecutionListenerSupport implements InitializingBean {
|
||||
public class ExecutionContextPromotionListener implements StepExecutionListener, InitializingBean {
|
||||
|
||||
private String[] keys = null;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2018 the original author or authors.
|
||||
* Copyright 2006-2021 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,87 +34,4 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public class ItemListenerSupport<I, O> implements ItemReadListener<I>, ItemProcessListener<I, O>, ItemWriteListener<O> {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.core.domain.ItemReadListener#afterRead(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void afterRead(I item) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.core.domain.ItemReadListener#beforeRead()
|
||||
*/
|
||||
@Override
|
||||
public void beforeRead() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.core.domain.ItemReadListener#onReadError(java.lang.Exception)
|
||||
*/
|
||||
@Override
|
||||
public void onReadError(Exception ex) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.core.ItemProcessListener#afterProcess(java.lang.Object,
|
||||
* java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void afterProcess(I item, @Nullable O result) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.core.ItemProcessListener#beforeProcess(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void beforeProcess(I item) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.core.ItemProcessListener#onProcessError(java.lang.Object,
|
||||
* java.lang.Exception)
|
||||
*/
|
||||
@Override
|
||||
public void onProcessError(I item, Exception e) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.core.domain.ItemWriteListener#afterWrite()
|
||||
*/
|
||||
@Override
|
||||
public void afterWrite(List<? extends O> item) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.core.domain.ItemWriteListener#beforeWrite(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void beforeWrite(List<? extends O> item) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.core.domain.ItemWriteListener#onWriteError(java.lang.Exception,
|
||||
* java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void onWriteError(Exception ex, List<? extends O> item) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Collection;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
|
||||
/**
|
||||
@@ -30,9 +31,10 @@ import org.springframework.batch.item.ExecutionContext;
|
||||
* {@link ExecutionContext} that should be copied.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
public class JobParameterExecutionContextCopyListener extends StepExecutionListenerSupport {
|
||||
public class JobParameterExecutionContextCopyListener implements StepExecutionListener {
|
||||
|
||||
private Collection<String> keys = null;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2013 the original author or authors.
|
||||
* Copyright 2006-2021 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,8 +21,12 @@ import org.springframework.batch.core.SkipListener;
|
||||
* Basic no-op implementations of all {@link SkipListener} implementations.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
* @deprecated as of v5.0 in favor of the default methods in {@link SkipListener}.
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class SkipListenerSupport<T,S> implements SkipListener<T,S> {
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2019 the original author or authors.
|
||||
* Copyright 2006-2021 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,125 +36,7 @@ import org.springframework.lang.Nullable;
|
||||
* @author Robert Kasanicky
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class StepListenerSupport<T,S> implements StepExecutionListener, ChunkListener,
|
||||
ItemReadListener<T>, ItemProcessListener<T,S>, ItemWriteListener<S>, SkipListener<T, S> {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.StepExecutionListener#afterStep(org.springframework.batch.core.StepExecution)
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.StepExecutionListener#beforeStep(org.springframework.batch.core.StepExecution)
|
||||
*/
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ChunkListener#afterChunk(ChunkContext context)
|
||||
*/
|
||||
@Override
|
||||
public void afterChunk(ChunkContext context) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ChunkListener#beforeChunk(ChunkContext context)
|
||||
*/
|
||||
@Override
|
||||
public void beforeChunk(ChunkContext context) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ItemReadListener#afterRead(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void afterRead(T item) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ItemReadListener#beforeRead()
|
||||
*/
|
||||
@Override
|
||||
public void beforeRead() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.domain.ItemReadListener#onReadError(java.lang.Exception)
|
||||
*/
|
||||
@Override
|
||||
public void onReadError(Exception ex) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.ItemWriteListener#afterWrite(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public void afterWrite(List<? extends S> items) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.ItemWriteListener#beforeWrite(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public void beforeWrite(List<? extends S> items) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.ItemWriteListener#onWriteError(java.lang.Exception, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public void onWriteError(Exception exception, List<? extends S> items) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.ItemProcessListener#afterProcess(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void afterProcess(T item, @Nullable S result) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.ItemProcessListener#beforeProcess(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void beforeProcess(T item) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.ItemProcessListener#onProcessError(java.lang.Object, java.lang.Exception)
|
||||
*/
|
||||
@Override
|
||||
public void onProcessError(T item, Exception e) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.SkipListener#onSkipInProcess(java.lang.Object, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
public void onSkipInProcess(T item, Throwable t) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.SkipListener#onSkipInRead(java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
public void onSkipInRead(Throwable t) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.core.SkipListener#onSkipInWrite(java.lang.Object, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
public void onSkipInWrite(S item, Throwable t) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterChunkError(ChunkContext context) {
|
||||
}
|
||||
public class StepListenerSupport<T,S> extends ItemListenerSupport<T, S>
|
||||
implements StepExecutionListener, ChunkListener, SkipListener<T, S> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2013 the original author or authors.
|
||||
* Copyright 2006-2021 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,6 @@ package org.springframework.batch.core.resource;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.repeat.CompletionPolicy;
|
||||
import org.springframework.batch.repeat.RepeatContext;
|
||||
import org.springframework.batch.repeat.RepeatStatus;
|
||||
@@ -44,10 +43,11 @@ import org.springframework.util.Assert;
|
||||
* </p>
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
* @see CompletionPolicy
|
||||
*/
|
||||
public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSupport implements CompletionPolicy {
|
||||
public class StepExecutionSimpleCompletionPolicy implements StepExecutionListener, CompletionPolicy {
|
||||
|
||||
private CompletionPolicy delegate;
|
||||
|
||||
@@ -69,7 +69,7 @@ public class StepExecutionSimpleCompletionPolicy extends StepExecutionListenerSu
|
||||
* 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)
|
||||
* @see org.springframework.batch.core.listener.StepExecutionListener#beforeStep(org.springframework.batch.core.StepExecution)
|
||||
*/
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 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,15 +18,16 @@ package org.springframework.batch.core.step;
|
||||
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Fails the step if no items have been processed ( item count is 0).
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class NoWorkFoundStepExecutionListener extends StepExecutionListenerSupport {
|
||||
public class NoWorkFoundStepExecutionListener implements StepExecutionListener {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2019 the original author or authors.
|
||||
* Copyright 2006-2021 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,8 +28,8 @@ import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInterruptedException;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.explore.JobExplorer;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.scope.context.ChunkContext;
|
||||
import org.springframework.batch.repeat.RepeatStatus;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -59,8 +59,9 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
* @author Will Schipp
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class SystemCommandTasklet extends StepExecutionListenerSupport implements StoppableTasklet, InitializingBean {
|
||||
public class SystemCommandTasklet implements StepExecutionListener, StoppableTasklet, InitializingBean {
|
||||
|
||||
protected static final Log logger = LogFactory.getLog(SystemCommandTasklet.class);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2019 the original author or authors.
|
||||
* Copyright 2006-2021 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,14 @@ import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@@ -57,7 +58,7 @@ public class DefaultUnknownJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
}
|
||||
|
||||
public static class UnknownListener extends StepExecutionListenerSupport {
|
||||
public static class UnknownListener implements StepExecutionListener {
|
||||
@Nullable
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2021 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
|
||||
*
|
||||
* https://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 org.springframework.batch.core.ChunkListener;
|
||||
|
||||
/**
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class DummyChunkListener implements ChunkListener {
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2021 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
|
||||
*
|
||||
* https://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 org.springframework.batch.core.JobExecutionListener;
|
||||
|
||||
/**
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class DummyJobExecutionListener implements JobExecutionListener {
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2021 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
|
||||
*
|
||||
* https://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 org.springframework.batch.core.StepExecutionListener;
|
||||
|
||||
/**
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class DummyStepExecutionListener implements StepExecutionListener {
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2009 the original author or authors.
|
||||
* Copyright 2006-2021 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,6 +39,7 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@@ -80,7 +81,7 @@ public class JobParserParentAttributeTests {
|
||||
if (l instanceof DummyAnnotationJobExecutionListener) {
|
||||
a = true;
|
||||
}
|
||||
else if (l instanceof JobExecutionListenerSupport) {
|
||||
else if (l instanceof DummyJobExecutionListener) {
|
||||
b = true;
|
||||
}
|
||||
}
|
||||
@@ -94,7 +95,7 @@ public class JobParserParentAttributeTests {
|
||||
assertEquals(1, job2Listeners.size());
|
||||
boolean c = false;
|
||||
for (Object l : job2Listeners) {
|
||||
if (l instanceof JobExecutionListenerSupport) {
|
||||
if (l instanceof DummyJobExecutionListener) {
|
||||
c = true;
|
||||
}
|
||||
}
|
||||
@@ -111,7 +112,7 @@ public class JobParserParentAttributeTests {
|
||||
if (l instanceof DummyAnnotationJobExecutionListener) {
|
||||
a = true;
|
||||
}
|
||||
else if (l instanceof JobExecutionListenerSupport) {
|
||||
else if (l instanceof DummyJobExecutionListener) {
|
||||
b = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2019 the original author or authors.
|
||||
* Copyright 2006-2021 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 java.util.List;
|
||||
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.scope.context.ChunkContext;
|
||||
import org.springframework.batch.core.step.tasklet.Tasklet;
|
||||
import org.springframework.batch.repeat.RepeatStatus;
|
||||
@@ -29,9 +29,10 @@ import org.springframework.lang.Nullable;
|
||||
* This class will store the step name when it is executed.
|
||||
*
|
||||
* @author Dan Garrette
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
public class NameStoringTasklet extends StepExecutionListenerSupport implements Tasklet {
|
||||
public class NameStoringTasklet implements StepExecutionListener, Tasklet {
|
||||
|
||||
private String stepName = null;
|
||||
private List<String> stepNamesList = null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2019 the original author or authors.
|
||||
* Copyright 2006-2021 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,14 @@ import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.1.9
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@@ -57,7 +58,7 @@ public class NextAttributeUnknownJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
}
|
||||
|
||||
public static class UnknownListener extends StepExecutionListenerSupport {
|
||||
public static class UnknownListener implements StepExecutionListener {
|
||||
@Nullable
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2021 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,10 +25,9 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.listener.ChunkListenerSupport;
|
||||
import org.springframework.batch.core.listener.ItemListenerSupport;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.step.tasklet.TaskletStep;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -38,6 +37,7 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@@ -52,7 +52,7 @@ public class StepListenerInStepParserTests {
|
||||
Step step = (Step) beanFactory.getBean("s1");
|
||||
List<?> list = getListeners(step);
|
||||
assertEquals(1, list.size());
|
||||
assertTrue(list.get(0) instanceof StepExecutionListenerSupport);
|
||||
assertTrue(list.get(0) instanceof DummyStepExecutionListener );
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -61,7 +61,7 @@ public class StepListenerInStepParserTests {
|
||||
Step step = (Step) beanFactory.getBean("s2");
|
||||
List<?> list = getListeners(step);
|
||||
assertEquals(1, list.size());
|
||||
assertTrue(list.get(0) instanceof ChunkListenerSupport);
|
||||
assertTrue(list.get(0) instanceof DummyChunkListener);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -69,8 +69,8 @@ public class StepListenerInStepParserTests {
|
||||
Step step = (Step) beanFactory.getBean("s3");
|
||||
List<?> list = getListeners(step);
|
||||
assertEquals(2, list.size());
|
||||
assertTrue(list.get(0) instanceof StepExecutionListenerSupport);
|
||||
assertTrue(list.get(1) instanceof ChunkListenerSupport);
|
||||
assertTrue(list.get(0) instanceof DummyStepExecutionListener);
|
||||
assertTrue(list.get(1) instanceof DummyChunkListener);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,7 +78,7 @@ public class StepListenerInStepParserTests {
|
||||
Step step = (Step) beanFactory.getBean("s4");
|
||||
List<?> list = getListeners(step);
|
||||
assertEquals(2, list.size());
|
||||
assertTrue(list.get(0) instanceof StepExecutionListenerSupport);
|
||||
assertTrue(list.get(0) instanceof DummyStepExecutionListener);
|
||||
assertTrue(list.get(1) instanceof ItemListenerSupport);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2021 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,6 @@ import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.listener.CompositeStepExecutionListener;
|
||||
import org.springframework.batch.core.listener.ItemListenerSupport;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.step.tasklet.TaskletStep;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@@ -38,6 +37,7 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@@ -69,7 +69,7 @@ public class StepListenerParserTests {
|
||||
if (listener instanceof DummyAnnotationStepExecutionListener) {
|
||||
a = true;
|
||||
}
|
||||
else if (listener instanceof StepExecutionListenerSupport) {
|
||||
else if (listener instanceof DummyStepExecutionListener) {
|
||||
b = true;
|
||||
}
|
||||
else if (listener instanceof CompositeStepExecutionListener) {
|
||||
@@ -93,7 +93,7 @@ public class StepListenerParserTests {
|
||||
if (listener instanceof DummyAnnotationStepExecutionListener) {
|
||||
a = true;
|
||||
}
|
||||
else if (listener instanceof StepExecutionListenerSupport) {
|
||||
else if (listener instanceof DummyStepExecutionListener) {
|
||||
b = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ import org.junit.Test;
|
||||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.job.flow.FlowStep;
|
||||
import org.springframework.batch.core.job.flow.support.SimpleFlow;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.partition.PartitionHandler;
|
||||
import org.springframework.batch.core.partition.support.PartitionStep;
|
||||
import org.springframework.batch.core.partition.support.SimplePartitioner;
|
||||
@@ -54,6 +54,7 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
public class StepParserStepFactoryBeanTests {
|
||||
@@ -108,7 +109,7 @@ public class StepParserStepFactoryBeanTests {
|
||||
fb.setStartLimit(5);
|
||||
fb.setTasklet(new DummyTasklet());
|
||||
fb.setTransactionManager(new ResourcelessTransactionManager());
|
||||
fb.setListeners(new StepExecutionListenerSupport[] { new StepExecutionListenerSupport() });
|
||||
fb.setListeners(new StepExecutionListener[] { new StepExecutionListener() {} });
|
||||
fb.setIsolation(Isolation.DEFAULT);
|
||||
fb.setTransactionTimeout(-1);
|
||||
fb.setPropagation(Propagation.REQUIRED);
|
||||
@@ -140,7 +141,7 @@ public class StepParserStepFactoryBeanTests {
|
||||
fb.setJobRepository(new JobRepositorySupport());
|
||||
fb.setStartLimit(5);
|
||||
fb.setTransactionManager(new ResourcelessTransactionManager());
|
||||
fb.setListeners(new StepListener[] { new StepExecutionListenerSupport() });
|
||||
fb.setListeners(new StepListener[] { new StepExecutionListener() {} });
|
||||
fb.setIsolation(Isolation.DEFAULT);
|
||||
fb.setTransactionTimeout(-1);
|
||||
fb.setPropagation(Propagation.REQUIRED);
|
||||
@@ -166,7 +167,7 @@ public class StepParserStepFactoryBeanTests {
|
||||
fb.setJobRepository(new JobRepositorySupport());
|
||||
fb.setStartLimit(5);
|
||||
fb.setTransactionManager(new ResourcelessTransactionManager());
|
||||
fb.setListeners(new StepListener[] { new StepExecutionListenerSupport() });
|
||||
fb.setListeners(new StepListener[] { new StepExecutionListener() {} });
|
||||
fb.setIsolation(Isolation.DEFAULT);
|
||||
fb.setTransactionTimeout(-1);
|
||||
fb.setPropagation(Propagation.REQUIRED);
|
||||
@@ -200,7 +201,7 @@ public class StepParserStepFactoryBeanTests {
|
||||
fb.setJobRepository(new JobRepositorySupport());
|
||||
fb.setStartLimit(5);
|
||||
fb.setTransactionManager(new ResourcelessTransactionManager());
|
||||
fb.setListeners(new StepListener[] { new StepExecutionListenerSupport() });
|
||||
fb.setListeners(new StepListener[] { new StepExecutionListener() {} });
|
||||
fb.setIsolation(Isolation.DEFAULT);
|
||||
fb.setTransactionTimeout(-1);
|
||||
fb.setPropagation(Propagation.REQUIRED);
|
||||
@@ -226,7 +227,7 @@ public class StepParserStepFactoryBeanTests {
|
||||
fb.setJobRepository(new JobRepositorySupport());
|
||||
fb.setStartLimit(5);
|
||||
fb.setTransactionManager(new ResourcelessTransactionManager());
|
||||
fb.setListeners(new StepListener[] { new StepExecutionListenerSupport() });
|
||||
fb.setListeners(new StepListener[] { new StepExecutionListener(){} });
|
||||
fb.setChunkCompletionPolicy(new DummyCompletionPolicy());
|
||||
fb.setTaskExecutor(new SyncTaskExecutor());
|
||||
fb.setItemReader(new DummyItemReader());
|
||||
@@ -264,7 +265,7 @@ public class StepParserStepFactoryBeanTests {
|
||||
fb.setAllowStartIfComplete(true);
|
||||
fb.setJobRepository(new JobRepositorySupport());
|
||||
fb.setStartLimit(5);
|
||||
fb.setListeners(new StepListener[] { new StepExecutionListenerSupport() });
|
||||
fb.setListeners(new StepListener[] { new StepExecutionListener(){} });
|
||||
fb.setTaskExecutor(new SyncTaskExecutor());
|
||||
|
||||
SimplePartitioner partitioner = new SimplePartitioner();
|
||||
@@ -284,7 +285,7 @@ public class StepParserStepFactoryBeanTests {
|
||||
fb.setAllowStartIfComplete(true);
|
||||
fb.setJobRepository(new JobRepositorySupport());
|
||||
fb.setStartLimit(5);
|
||||
fb.setListeners(new StepListener[] { new StepExecutionListenerSupport() });
|
||||
fb.setListeners(new StepListener[] { new StepExecutionListener(){} });
|
||||
fb.setTaskExecutor(new SyncTaskExecutor());
|
||||
|
||||
SimplePartitioner partitioner = new SimplePartitioner();
|
||||
@@ -307,7 +308,7 @@ public class StepParserStepFactoryBeanTests {
|
||||
fb.setAllowStartIfComplete(true);
|
||||
fb.setJobRepository(new JobRepositorySupport());
|
||||
fb.setStartLimit(5);
|
||||
fb.setListeners(new StepListener[] { new StepExecutionListenerSupport() });
|
||||
fb.setListeners(new StepListener[] { new StepExecutionListener(){} });
|
||||
fb.setTaskExecutor(new SyncTaskExecutor());
|
||||
|
||||
fb.setFlow(new SimpleFlow("foo"));
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.job.AbstractJob;
|
||||
import org.springframework.batch.core.listener.CompositeStepExecutionListener;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.support.SimpleJobRepository;
|
||||
import org.springframework.batch.core.step.AbstractStep;
|
||||
@@ -170,16 +169,16 @@ public class StepParserTests {
|
||||
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
|
||||
|
||||
// Inline Step
|
||||
assertTrue(getListener("s1", ctx) instanceof StepExecutionListenerSupport);
|
||||
assertTrue(getListener("s1", ctx) instanceof DummyStepExecutionListener);
|
||||
|
||||
// Standalone Step
|
||||
assertTrue(getListener("s2", ctx) instanceof StepExecutionListenerSupport);
|
||||
assertTrue(getListener("s2", ctx) instanceof DummyStepExecutionListener);
|
||||
|
||||
// Inline With Tasklet Attribute Step
|
||||
assertTrue(getListener("s3", ctx) instanceof StepExecutionListenerSupport);
|
||||
assertTrue(getListener("s3", ctx) instanceof DummyStepExecutionListener);
|
||||
|
||||
// Standalone With Tasklet Attribute Step
|
||||
assertTrue(getListener("s4", ctx) instanceof StepExecutionListenerSupport);
|
||||
assertTrue(getListener("s4", ctx) instanceof DummyStepExecutionListener);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -442,7 +441,7 @@ public class StepParserTests {
|
||||
List<Class<? extends ItemStream>> streams = Arrays.asList(CompositeItemStream.class, TestReader.class);
|
||||
List<Class<? extends RetryListener>> retryListeners = Arrays.asList(RetryListenerSupport.class,
|
||||
DummyRetryListener.class);
|
||||
List<Class<? extends StepExecutionListener>> stepListeners = Arrays.asList(StepExecutionListenerSupport.class,
|
||||
List<Class<? extends StepExecutionListener>> stepListeners = Arrays.asList(DummyStepExecutionListener.class,
|
||||
CompositeStepExecutionListener.class);
|
||||
List<Class<? extends SkippableRuntimeException>> noRollback = Arrays.asList(FatalRuntimeException.class,
|
||||
SkippableRuntimeException.class);
|
||||
|
||||
@@ -230,7 +230,7 @@ public class SimpleJobTests {
|
||||
|
||||
@Test
|
||||
public void testRunNormallyWithListener() throws Exception {
|
||||
job.setJobExecutionListeners(new JobExecutionListenerSupport[] { new JobExecutionListenerSupport() {
|
||||
job.setJobExecutionListeners(new JobExecutionListener[] { new JobExecutionListener() {
|
||||
@Override
|
||||
public void beforeJob(JobExecution jobExecution) {
|
||||
list.add("before");
|
||||
@@ -310,7 +310,7 @@ public class SimpleJobTests {
|
||||
|
||||
@Test
|
||||
public void testFailedWithListener() throws Exception {
|
||||
job.setJobExecutionListeners(new JobExecutionListenerSupport[] { new JobExecutionListenerSupport() {
|
||||
job.setJobExecutionListeners(new JobExecutionListener[] { new JobExecutionListener() {
|
||||
@Override
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
list.add("afterJob");
|
||||
|
||||
@@ -22,10 +22,12 @@ import java.util.List;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobExecutionListener;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public class CompositeJobExecutionListenerTests extends TestCase {
|
||||
@@ -39,12 +41,12 @@ public class CompositeJobExecutionListenerTests extends TestCase {
|
||||
* {@link org.springframework.batch.core.listener.CompositeJobExecutionListener#setListeners(List)}
|
||||
*/
|
||||
public void testSetListeners() {
|
||||
listener.setListeners(Arrays.asList(new JobExecutionListenerSupport() {
|
||||
listener.setListeners(Arrays.asList(new JobExecutionListener() {
|
||||
@Override
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
list.add("fail");
|
||||
}
|
||||
}, new JobExecutionListenerSupport() {
|
||||
}, new JobExecutionListener() {
|
||||
@Override
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
list.add("continue");
|
||||
@@ -60,7 +62,7 @@ public class CompositeJobExecutionListenerTests extends TestCase {
|
||||
* .
|
||||
*/
|
||||
public void testSetListener() {
|
||||
listener.register(new JobExecutionListenerSupport() {
|
||||
listener.register(new JobExecutionListener() {
|
||||
@Override
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
list.add("fail");
|
||||
@@ -76,7 +78,7 @@ public class CompositeJobExecutionListenerTests extends TestCase {
|
||||
* .
|
||||
*/
|
||||
public void testOpen() {
|
||||
listener.register(new JobExecutionListenerSupport() {
|
||||
listener.register(new JobExecutionListener() {
|
||||
@Override
|
||||
public void beforeJob(JobExecution stepExecution) {
|
||||
list.add("foo");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2019 the original author or authors.
|
||||
* Copyright 2006-2021 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,6 +28,7 @@ import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public class CompositeStepExecutionListenerTests extends TestCase {
|
||||
@@ -44,7 +45,7 @@ public class CompositeStepExecutionListenerTests extends TestCase {
|
||||
public void testSetListeners() {
|
||||
JobExecution jobExecution = new JobExecution(1L);
|
||||
StepExecution stepExecution = new StepExecution("s1", jobExecution);
|
||||
listener.setListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() {
|
||||
listener.setListeners(new StepExecutionListener[] { new StepExecutionListener() {
|
||||
@Nullable
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
@@ -52,7 +53,7 @@ public class CompositeStepExecutionListenerTests extends TestCase {
|
||||
list.add("fail");
|
||||
return ExitStatus.FAILED;
|
||||
}
|
||||
}, new StepExecutionListenerSupport() {
|
||||
}, new StepExecutionListener() {
|
||||
@Nullable
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
@@ -72,7 +73,7 @@ public class CompositeStepExecutionListenerTests extends TestCase {
|
||||
public void testSetListener() {
|
||||
JobExecution jobExecution = new JobExecution(1L);
|
||||
StepExecution stepExecution = new StepExecution("s1", jobExecution);
|
||||
listener.register(new StepExecutionListenerSupport() {
|
||||
listener.register(new StepExecutionListener() {
|
||||
@Nullable
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
@@ -90,7 +91,7 @@ public class CompositeStepExecutionListenerTests extends TestCase {
|
||||
* .
|
||||
*/
|
||||
public void testOpen() {
|
||||
listener.register(new StepExecutionListenerSupport() {
|
||||
listener.register(new StepExecutionListener() {
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
list.add("foo");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2019 the original author or authors.
|
||||
* Copyright 2006-2021 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,6 +26,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.SkipListener;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
import org.springframework.batch.core.annotation.AfterChunk;
|
||||
@@ -401,11 +402,10 @@ public class MulticasterBatchListenerTests {
|
||||
*/
|
||||
@Test
|
||||
public void testOnSkipInRead() {
|
||||
multicast.register(new SkipListenerSupport<Object,Object>() {
|
||||
multicast.register(new SkipListener<Object,Object>() {
|
||||
@Override
|
||||
public void onSkipInRead(Throwable t) {
|
||||
count++;
|
||||
super.onSkipInRead(t);
|
||||
}
|
||||
});
|
||||
multicast.onSkipInRead(new RuntimeException("foo"));
|
||||
@@ -419,7 +419,7 @@ public class MulticasterBatchListenerTests {
|
||||
*/
|
||||
@Test
|
||||
public void testOnSkipInReadFails() {
|
||||
multicast.register(new SkipListenerSupport<Object,Object>() {
|
||||
multicast.register(new SkipListener<Object,Object>() {
|
||||
@Override
|
||||
public void onSkipInRead(Throwable t) {
|
||||
count++;
|
||||
@@ -445,11 +445,10 @@ public class MulticasterBatchListenerTests {
|
||||
*/
|
||||
@Test
|
||||
public void testOnSkipInWrite() {
|
||||
multicast.register(new SkipListenerSupport<Object,Object>() {
|
||||
multicast.register(new SkipListener<Object,Object>() {
|
||||
@Override
|
||||
public void onSkipInWrite(Object item, Throwable t) {
|
||||
count++;
|
||||
super.onSkipInWrite(item, t);
|
||||
}
|
||||
});
|
||||
multicast.onSkipInWrite(null, new RuntimeException("foo"));
|
||||
@@ -463,7 +462,7 @@ public class MulticasterBatchListenerTests {
|
||||
*/
|
||||
@Test
|
||||
public void testOnSkipInWriteFails() {
|
||||
multicast.register(new SkipListenerSupport<Object,Object>() {
|
||||
multicast.register(new SkipListener<Object,Object>() {
|
||||
@Override
|
||||
public void onSkipInWrite(Object item, Throwable t) {
|
||||
count++;
|
||||
@@ -489,11 +488,10 @@ public class MulticasterBatchListenerTests {
|
||||
*/
|
||||
@Test
|
||||
public void testOnSkipInProcess() {
|
||||
multicast.register(new SkipListenerSupport<Object,Object>() {
|
||||
multicast.register(new SkipListener<Object,Object>() {
|
||||
@Override
|
||||
public void onSkipInProcess(Object item, Throwable t) {
|
||||
count++;
|
||||
super.onSkipInWrite(item, t);
|
||||
}
|
||||
});
|
||||
multicast.onSkipInProcess(null, new RuntimeException("foo"));
|
||||
@@ -507,7 +505,7 @@ public class MulticasterBatchListenerTests {
|
||||
*/
|
||||
@Test
|
||||
public void testOnSkipInProcessFails() {
|
||||
multicast.register(new SkipListenerSupport<Object,Object>() {
|
||||
multicast.register(new SkipListener<Object,Object>() {
|
||||
@Override
|
||||
public void onSkipInProcess(Object item, Throwable t) {
|
||||
count++;
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.SkipListener;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepListener;
|
||||
@@ -452,7 +453,7 @@ public class FaultTolerantStepFactoryBeanRetryTests {
|
||||
@Test
|
||||
public void testSkipAndRetryWithWriteFailure() throws Exception {
|
||||
|
||||
factory.setListeners(new StepListener[] { new SkipListenerSupport<String, String>() {
|
||||
factory.setListeners(new StepListener[] { new SkipListener<String, String>() {
|
||||
@Override
|
||||
public void onSkipInWrite(String item, Throwable t) {
|
||||
recovered.add(item);
|
||||
@@ -517,7 +518,7 @@ public class FaultTolerantStepFactoryBeanRetryTests {
|
||||
throws Exception {
|
||||
|
||||
factory.setCommitInterval(3);
|
||||
factory.setListeners(new StepListener[] { new SkipListenerSupport<String, String>() {
|
||||
factory.setListeners(new StepListener[] { new SkipListener<String, String>() {
|
||||
@Override
|
||||
public void onSkipInWrite(String item, Throwable t) {
|
||||
recovered.add(item);
|
||||
|
||||
@@ -543,7 +543,7 @@ public class FaultTolerantStepFactoryBeanTests {
|
||||
|
||||
final List<Throwable> listenerCalls = new ArrayList<>();
|
||||
|
||||
factory.setListeners(new StepListener[] { new SkipListenerSupport<String, String>() {
|
||||
factory.setListeners(new StepListener[] { new SkipListener<String, String>() {
|
||||
@Override
|
||||
public void onSkipInRead(Throwable t) {
|
||||
listenerCalls.add(t);
|
||||
@@ -578,7 +578,7 @@ public class FaultTolerantStepFactoryBeanTests {
|
||||
writer.setFailures("4");
|
||||
|
||||
factory.setSkipLimit(3);
|
||||
factory.setListeners(new StepListener[] { new SkipListenerSupport<String, String>() {
|
||||
factory.setListeners(new StepListener[] { new SkipListener<String, String>() {
|
||||
@Override
|
||||
public void onSkipInRead(Throwable t) {
|
||||
throw new RuntimeException("oops");
|
||||
@@ -613,7 +613,7 @@ public class FaultTolerantStepFactoryBeanTests {
|
||||
writer.setFailures("4");
|
||||
|
||||
factory.setSkipLimit(3);
|
||||
factory.setListeners(new StepListener[] { new SkipListenerSupport<String, String>() {
|
||||
factory.setListeners(new StepListener[] { new SkipListener<String, String>() {
|
||||
@Override
|
||||
public void onSkipInWrite(String item, Throwable t) {
|
||||
throw new RuntimeException("oops");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2019 the original author or authors.
|
||||
* Copyright 2008-2021 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,6 @@ import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
@@ -62,6 +61,7 @@ import static org.springframework.batch.core.BatchStatus.UNKNOWN;
|
||||
* @author Lucas Ward
|
||||
* @author Dave Syer
|
||||
* @author David Turanski
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public class TaskletStepExceptionTests {
|
||||
@@ -139,7 +139,7 @@ public class TaskletStepExceptionTests {
|
||||
public void testBeforeStepFailure() throws Exception {
|
||||
|
||||
final RuntimeException exception = new RuntimeException();
|
||||
taskletStep.setStepExecutionListeners(new StepExecutionListenerSupport[] { new StepExecutionListenerSupport() {
|
||||
taskletStep.setStepExecutionListeners(new StepExecutionListener[] { new StepExecutionListener() {
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
throw exception;
|
||||
@@ -155,7 +155,7 @@ public class TaskletStepExceptionTests {
|
||||
public void testAfterStepFailureWhenTaskletSucceeds() throws Exception {
|
||||
|
||||
final RuntimeException exception = new RuntimeException();
|
||||
taskletStep.setStepExecutionListeners(new StepExecutionListenerSupport[] { new StepExecutionListenerSupport() {
|
||||
taskletStep.setStepExecutionListeners(new StepExecutionListener[] { new StepExecutionListener() {
|
||||
@Nullable
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
@@ -184,7 +184,7 @@ public class TaskletStepExceptionTests {
|
||||
public void testAfterStepFailureWhenTaskletFails() throws Exception {
|
||||
|
||||
final RuntimeException exception = new RuntimeException();
|
||||
taskletStep.setStepExecutionListeners(new StepExecutionListenerSupport[] { new StepExecutionListenerSupport() {
|
||||
taskletStep.setStepExecutionListeners(new StepExecutionListener[] { new StepExecutionListener() {
|
||||
@Nullable
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
@@ -480,7 +480,7 @@ public class TaskletStepExceptionTests {
|
||||
}
|
||||
}
|
||||
|
||||
private static class InterruptionListener extends StepExecutionListenerSupport {
|
||||
private static class InterruptionListener implements StepExecutionListener {
|
||||
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
|
||||
@@ -39,7 +39,6 @@ import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.dao.Jackson2ExecutionContextStringSerializer;
|
||||
import org.springframework.batch.core.repository.dao.JdbcExecutionContextDao;
|
||||
@@ -326,7 +325,7 @@ public class TaskletStepTests {
|
||||
};
|
||||
|
||||
step.setTasklet(new TestingChunkOrientedTasklet<>(itemReader, itemWriter));
|
||||
step.registerStepExecutionListener(new StepExecutionListenerSupport() {
|
||||
step.registerStepExecutionListener(new StepExecutionListener() {
|
||||
@Nullable
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
@@ -497,7 +496,7 @@ public class TaskletStepTests {
|
||||
|
||||
@Test
|
||||
public void testDirectlyInjectedListener() throws Exception {
|
||||
step.registerStepExecutionListener(new StepExecutionListenerSupport() {
|
||||
step.registerStepExecutionListener(new StepExecutionListener() {
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
list.add("foo");
|
||||
@@ -542,7 +541,7 @@ public class TaskletStepTests {
|
||||
|
||||
final ExitStatus customStatus = new ExitStatus("COMPLETED_CUSTOM");
|
||||
|
||||
step.setStepExecutionListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() {
|
||||
step.setStepExecutionListeners(new StepExecutionListener[] { new StepExecutionListener() {
|
||||
@Nullable
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
@@ -566,7 +565,7 @@ public class TaskletStepTests {
|
||||
|
||||
@Test
|
||||
public void testDirectlyInjectedListenerOnError() throws Exception {
|
||||
step.registerStepExecutionListener(new StepExecutionListenerSupport() {
|
||||
step.registerStepExecutionListener(new StepExecutionListener() {
|
||||
@Nullable
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
@@ -877,7 +876,7 @@ public class TaskletStepTests {
|
||||
*/
|
||||
@Test
|
||||
public void testStepFailureInAfterStepCallback() throws JobInterruptedException {
|
||||
StepExecutionListener listener = new StepExecutionListenerSupport() {
|
||||
StepExecutionListener listener = new StepExecutionListener() {
|
||||
@Nullable
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<listeners merge="true">
|
||||
<listener>
|
||||
<beans:bean
|
||||
class="org.springframework.batch.core.listener.JobExecutionListenerSupport" />
|
||||
class="org.springframework.batch.core.configuration.xml.DummyJobExecutionListener" />
|
||||
</listener>
|
||||
</listeners>
|
||||
</job>
|
||||
@@ -27,7 +27,7 @@
|
||||
<listeners>
|
||||
<listener>
|
||||
<beans:bean
|
||||
class="org.springframework.batch.core.listener.JobExecutionListenerSupport" />
|
||||
class="org.springframework.batch.core.configuration.xml.DummyJobExecutionListener" />
|
||||
</listener>
|
||||
</listeners>
|
||||
</job>
|
||||
@@ -88,7 +88,7 @@
|
||||
<beans:list>
|
||||
<job-listener>
|
||||
<beans:bean
|
||||
class="org.springframework.batch.core.listener.JobExecutionListenerSupport" />
|
||||
class="org.springframework.batch.core.configuration.xml.DummyJobExecutionListener" />
|
||||
</job-listener>
|
||||
</beans:list>
|
||||
</beans:property>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<tasklet ref="dummyTasklet" />
|
||||
<listeners>
|
||||
<listener>
|
||||
<beans:bean class="org.springframework.batch.core.listener.StepExecutionListenerSupport" />
|
||||
<beans:bean class="org.springframework.batch.core.configuration.xml.DummyStepExecutionListener" />
|
||||
</listener>
|
||||
</listeners>
|
||||
</step>
|
||||
@@ -19,7 +19,7 @@
|
||||
<tasklet ref="dummyTasklet" />
|
||||
<listeners>
|
||||
<listener>
|
||||
<beans:bean class="org.springframework.batch.core.listener.ChunkListenerSupport" />
|
||||
<beans:bean class="org.springframework.batch.core.configuration.xml.DummyChunkListener" />
|
||||
</listener>
|
||||
</listeners>
|
||||
</step>
|
||||
@@ -27,13 +27,13 @@
|
||||
<tasklet ref="dummyTasklet">
|
||||
<listeners>
|
||||
<listener>
|
||||
<beans:bean class="org.springframework.batch.core.listener.ChunkListenerSupport" />
|
||||
<beans:bean class="org.springframework.batch.core.configuration.xml.DummyChunkListener" />
|
||||
</listener>
|
||||
</listeners>
|
||||
</tasklet>
|
||||
<listeners>
|
||||
<listener>
|
||||
<beans:bean class="org.springframework.batch.core.listener.StepExecutionListenerSupport" />
|
||||
<beans:bean class="org.springframework.batch.core.configuration.xml.DummyStepExecutionListener" />
|
||||
</listener>
|
||||
</listeners>
|
||||
</step>
|
||||
@@ -49,7 +49,7 @@
|
||||
</tasklet>
|
||||
<listeners>
|
||||
<listener>
|
||||
<beans:bean class="org.springframework.batch.core.listener.StepExecutionListenerSupport" />
|
||||
<beans:bean class="org.springframework.batch.core.configuration.xml.DummyStepExecutionListener" />
|
||||
</listener>
|
||||
</listeners>
|
||||
</step>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<tasklet ref="dummyTasklet">
|
||||
<listeners>
|
||||
<listener>
|
||||
<beans:bean class="org.springframework.batch.core.listener.StepExecutionListenerSupport" />
|
||||
<beans:bean class="org.springframework.batch.core.configuration.xml.DummyStepExecutionListener" />
|
||||
</listener>
|
||||
<listener ref="toplevel2" />
|
||||
</listeners>
|
||||
@@ -49,7 +49,7 @@
|
||||
</job>
|
||||
|
||||
<step-listener id="toplevel1">
|
||||
<beans:bean class="org.springframework.batch.core.listener.StepExecutionListenerSupport" />
|
||||
<beans:bean class="org.springframework.batch.core.configuration.xml.DummyStepExecutionListener" />
|
||||
</step-listener>
|
||||
<step-listener id="toplevel2">
|
||||
<beans:bean class="org.springframework.batch.core.configuration.xml.DummyAnnotationStepExecutionListener" />
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
<transaction-attributes timeout="10"/>
|
||||
<listeners>
|
||||
<listener>
|
||||
<beans:bean class="org.springframework.batch.core.listener.StepExecutionListenerSupport" />
|
||||
<beans:bean class="org.springframework.batch.core.configuration.xml.DummyStepExecutionListener" />
|
||||
</listener>
|
||||
</listeners>
|
||||
</tasklet>
|
||||
@@ -168,7 +168,7 @@
|
||||
</chunk>
|
||||
<listeners>
|
||||
<listener>
|
||||
<beans:bean class="org.springframework.batch.core.listener.StepExecutionListenerSupport"/>
|
||||
<beans:bean class="org.springframework.batch.core.configuration.xml.DummyStepExecutionListener"/>
|
||||
</listener>
|
||||
</listeners>
|
||||
<no-rollback-exception-classes>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2021 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,6 +23,7 @@ package org.springframework.batch.repeat;
|
||||
* framework provides callbacks at key points in the processing.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public interface RepeatListener {
|
||||
@@ -32,7 +33,8 @@ public interface RepeatListener {
|
||||
*
|
||||
* @param context the current batch context.
|
||||
*/
|
||||
void before(RepeatContext context);
|
||||
default void before(RepeatContext context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the framework after each item has been processed, unless the
|
||||
@@ -42,7 +44,8 @@ public interface RepeatListener {
|
||||
* @param context the current batch context
|
||||
* @param result the result of the callback
|
||||
*/
|
||||
void after(RepeatContext context, RepeatStatus result);
|
||||
default void after(RepeatContext context, RepeatStatus result) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called once at the start of a complete batch, before any items are
|
||||
@@ -54,7 +57,8 @@ public interface RepeatListener {
|
||||
*
|
||||
* @param context the current batch context
|
||||
*/
|
||||
void open(RepeatContext context);
|
||||
default void open(RepeatContext context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a repeat callback fails by throwing an exception. There will
|
||||
@@ -67,7 +71,8 @@ public interface RepeatListener {
|
||||
* @param context the current batch context
|
||||
* @param e the error that was encountered in an item callback.
|
||||
*/
|
||||
void onError(RepeatContext context, Throwable e);
|
||||
default void onError(RepeatContext context, Throwable e) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called once at the end of a complete batch, after normal or abnormal
|
||||
@@ -76,5 +81,6 @@ public interface RepeatListener {
|
||||
*
|
||||
* @param context the current batch context.
|
||||
*/
|
||||
void close(RepeatContext context);
|
||||
default void close(RepeatContext context) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2021 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,8 +24,11 @@ import org.springframework.batch.repeat.RepeatListener;
|
||||
* Empty method implementation of {@link RepeatListener}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
* @deprecated as of v5.0 in favor of the default methods in {@link RepeatListener}.
|
||||
*/
|
||||
@Deprecated
|
||||
public class RepeatListenerSupport implements RepeatListener {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2021 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,6 +26,7 @@ import org.springframework.batch.repeat.context.RepeatContextSupport;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public class CompositeRepeatListenerTests extends TestCase {
|
||||
@@ -39,12 +40,12 @@ public class CompositeRepeatListenerTests extends TestCase {
|
||||
* Test method for {@link CompositeRepeatListener#setListeners(RepeatListener[])}.
|
||||
*/
|
||||
public void testSetListeners() {
|
||||
listener.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
|
||||
listener.setListeners(new RepeatListener[] { new RepeatListener() {
|
||||
@Override
|
||||
public void open(RepeatContext context) {
|
||||
list.add("fail");
|
||||
}
|
||||
}, new RepeatListenerSupport() {
|
||||
}, new RepeatListener() {
|
||||
@Override
|
||||
public void open(RepeatContext context) {
|
||||
list.add("continue");
|
||||
@@ -59,7 +60,7 @@ public class CompositeRepeatListenerTests extends TestCase {
|
||||
* {@link CompositeRepeatListener#register(RepeatListener)}.
|
||||
*/
|
||||
public void testSetListener() {
|
||||
listener.register(new RepeatListenerSupport() {
|
||||
listener.register(new RepeatListener() {
|
||||
@Override
|
||||
public void before(RepeatContext context) {
|
||||
list.add("fail");
|
||||
@@ -70,7 +71,7 @@ public class CompositeRepeatListenerTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testClose() {
|
||||
listener.register(new RepeatListenerSupport() {
|
||||
listener.register(new RepeatListener() {
|
||||
@Override
|
||||
public void close(RepeatContext context) {
|
||||
list.add("foo");
|
||||
@@ -81,7 +82,7 @@ public class CompositeRepeatListenerTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testOnError() {
|
||||
listener.register(new RepeatListenerSupport() {
|
||||
listener.register(new RepeatListener() {
|
||||
@Override
|
||||
public void onError(RepeatContext context, Throwable e) {
|
||||
list.add(e);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2021 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,12 +36,12 @@ public class RepeatListenerTests extends TestCase {
|
||||
public void testBeforeInterceptors() throws Exception {
|
||||
RepeatTemplate template = new RepeatTemplate();
|
||||
final List<Object> calls = new ArrayList<>();
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
|
||||
template.setListeners(new RepeatListener[] { new RepeatListener() {
|
||||
@Override
|
||||
public void before(RepeatContext context) {
|
||||
calls.add("1");
|
||||
}
|
||||
}, new RepeatListenerSupport() {
|
||||
}, new RepeatListener() {
|
||||
@Override
|
||||
public void before(RepeatContext context) {
|
||||
calls.add("2");
|
||||
@@ -65,7 +65,7 @@ public class RepeatListenerTests extends TestCase {
|
||||
public void testBeforeInterceptorCanVeto() throws Exception {
|
||||
RepeatTemplate template = new RepeatTemplate();
|
||||
final List<Object> calls = new ArrayList<>();
|
||||
template.registerListener(new RepeatListenerSupport() {
|
||||
template.registerListener(new RepeatListener() {
|
||||
@Override
|
||||
public void before(RepeatContext context) {
|
||||
calls.add("1");
|
||||
@@ -87,12 +87,12 @@ public class RepeatListenerTests extends TestCase {
|
||||
public void testAfterInterceptors() throws Exception {
|
||||
RepeatTemplate template = new RepeatTemplate();
|
||||
final List<Object> calls = new ArrayList<>();
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
|
||||
template.setListeners(new RepeatListener[] { new RepeatListener() {
|
||||
@Override
|
||||
public void after(RepeatContext context, RepeatStatus result) {
|
||||
calls.add("1");
|
||||
}
|
||||
}, new RepeatListenerSupport() {
|
||||
}, new RepeatListener() {
|
||||
@Override
|
||||
public void after(RepeatContext context, RepeatStatus result) {
|
||||
calls.add("2");
|
||||
@@ -114,12 +114,12 @@ public class RepeatListenerTests extends TestCase {
|
||||
public void testOpenInterceptors() throws Exception {
|
||||
RepeatTemplate template = new RepeatTemplate();
|
||||
final List<Object> calls = new ArrayList<>();
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
|
||||
template.setListeners(new RepeatListener[] { new RepeatListener() {
|
||||
@Override
|
||||
public void open(RepeatContext context) {
|
||||
calls.add("1");
|
||||
}
|
||||
}, new RepeatListenerSupport() {
|
||||
}, new RepeatListener() {
|
||||
@Override
|
||||
public void open(RepeatContext context) {
|
||||
calls.add("2");
|
||||
@@ -140,7 +140,7 @@ public class RepeatListenerTests extends TestCase {
|
||||
public void testSingleOpenInterceptor() throws Exception {
|
||||
RepeatTemplate template = new RepeatTemplate();
|
||||
final List<Object> calls = new ArrayList<>();
|
||||
template.registerListener(new RepeatListenerSupport() {
|
||||
template.registerListener(new RepeatListener() {
|
||||
@Override
|
||||
public void open(RepeatContext context) {
|
||||
calls.add("1");
|
||||
@@ -161,12 +161,12 @@ public class RepeatListenerTests extends TestCase {
|
||||
public void testCloseInterceptors() throws Exception {
|
||||
RepeatTemplate template = new RepeatTemplate();
|
||||
final List<Object> calls = new ArrayList<>();
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
|
||||
template.setListeners(new RepeatListener[] { new RepeatListener() {
|
||||
@Override
|
||||
public void close(RepeatContext context) {
|
||||
calls.add("1");
|
||||
}
|
||||
}, new RepeatListenerSupport() {
|
||||
}, new RepeatListener() {
|
||||
@Override
|
||||
public void close(RepeatContext context) {
|
||||
calls.add("2");
|
||||
@@ -189,12 +189,12 @@ public class RepeatListenerTests extends TestCase {
|
||||
public void testOnErrorInterceptors() throws Exception {
|
||||
RepeatTemplate template = new RepeatTemplate();
|
||||
final List<Object> calls = new ArrayList<>();
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
|
||||
template.setListeners(new RepeatListener[] { new RepeatListener() {
|
||||
@Override
|
||||
public void onError(RepeatContext context, Throwable t) {
|
||||
calls.add("1");
|
||||
}
|
||||
}, new RepeatListenerSupport() {
|
||||
}, new RepeatListener() {
|
||||
@Override
|
||||
public void onError(RepeatContext context, Throwable t) {
|
||||
calls.add("2");
|
||||
@@ -219,12 +219,12 @@ public class RepeatListenerTests extends TestCase {
|
||||
public void testOnErrorInterceptorsPrecedence() throws Exception {
|
||||
RepeatTemplate template = new RepeatTemplate();
|
||||
final List<Object> calls = new ArrayList<>();
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
|
||||
template.setListeners(new RepeatListener[] { new RepeatListener() {
|
||||
@Override
|
||||
public void after(RepeatContext context, RepeatStatus result) {
|
||||
calls.add("1");
|
||||
}
|
||||
}, new RepeatListenerSupport() {
|
||||
}, new RepeatListener() {
|
||||
@Override
|
||||
public void onError(RepeatContext context, Throwable t) {
|
||||
calls.add("2");
|
||||
@@ -252,12 +252,12 @@ public class RepeatListenerTests extends TestCase {
|
||||
template.setTaskExecutor(new SimpleAsyncTaskExecutor());
|
||||
final List<Object> calls = new ArrayList<>();
|
||||
final List<Object> fails = new ArrayList<>();
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
|
||||
template.setListeners(new RepeatListener[] { new RepeatListener() {
|
||||
@Override
|
||||
public void after(RepeatContext context, RepeatStatus result) {
|
||||
calls.add("1");
|
||||
}
|
||||
}, new RepeatListenerSupport() {
|
||||
}, new RepeatListener() {
|
||||
@Override
|
||||
public void onError(RepeatContext context, Throwable t) {
|
||||
calls.add("2");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2021 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.
|
||||
@@ -42,6 +42,7 @@ import org.springframework.batch.repeat.policy.SimpleCompletionPolicy;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests {
|
||||
|
||||
@@ -458,7 +459,7 @@ public class SimpleRepeatTemplateTests extends AbstractTradeBatchTests {
|
||||
}
|
||||
ExceptionHandlerStub exHandler = new ExceptionHandlerStub();
|
||||
|
||||
class RepeatListenerStub extends RepeatListenerSupport {
|
||||
class RepeatListenerStub implements RepeatListener {
|
||||
boolean called = false;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.ItemStreamException;
|
||||
@@ -41,7 +41,7 @@ import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
public class ChunkMessageChannelItemWriter<T> extends StepExecutionListenerSupport implements ItemWriter<T>,
|
||||
public class ChunkMessageChannelItemWriter<T> implements StepExecutionListener, ItemWriter<T>,
|
||||
ItemStream, StepContributionSource {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ChunkMessageChannelItemWriter.class);
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
|
||||
/**
|
||||
@@ -30,9 +30,10 @@ import org.springframework.batch.item.ItemWriter;
|
||||
* jobs.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public class InfiniteLoopWriter extends StepExecutionListenerSupport implements ItemWriter<Object> {
|
||||
public class InfiniteLoopWriter implements StepExecutionListener, ItemWriter<Object> {
|
||||
private static final Log LOG = LogFactory.getLog(InfiniteLoopWriter.class);
|
||||
|
||||
private StepExecution stepExecution;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2019 the original author or authors.
|
||||
* Copyright 2006-2021 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.sample.domain.trade;
|
||||
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.item.file.transform.FieldSet;
|
||||
import org.springframework.batch.item.file.transform.LineTokenizer;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -29,9 +29,10 @@ import org.springframework.lang.Nullable;
|
||||
* will delegate accordingly.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
public class CompositeCustomerUpdateLineTokenizer extends StepExecutionListenerSupport implements LineTokenizer {
|
||||
public class CompositeCustomerUpdateLineTokenizer implements StepExecutionListener, LineTokenizer {
|
||||
|
||||
private LineTokenizer customerTokenizer;
|
||||
private LineTokenizer footerTokenizer;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2019 the original author or authors.
|
||||
* Copyright 2006-2021 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.sample.loop;
|
||||
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.sample.domain.trade.internal.GeneratingTradeItemReader;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -28,9 +28,10 @@ import org.springframework.util.Assert;
|
||||
* step.
|
||||
*
|
||||
* @author Dan Garrette
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 2.0
|
||||
*/
|
||||
public class GeneratingTradeResettingListener extends StepExecutionListenerSupport implements InitializingBean {
|
||||
public class GeneratingTradeResettingListener implements StepExecutionListener, InitializingBean {
|
||||
|
||||
private GeneratingTradeItemReader reader;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2021 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,13 +20,13 @@ import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.item.file.FlatFileFooterCallback;
|
||||
|
||||
/**
|
||||
* Writes summary info in the footer of a file.
|
||||
*/
|
||||
public class SummaryFooterCallback extends StepExecutionListenerSupport implements FlatFileFooterCallback{
|
||||
public class SummaryFooterCallback implements StepExecutionListener, FlatFileFooterCallback{
|
||||
|
||||
private StepExecution stepExecution;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2018 the original author or authors.
|
||||
* Copyright 2006-2021 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.
|
||||
@@ -144,7 +144,7 @@ public class StepRunner {
|
||||
// Dump the given Job ExecutionContext using a listener
|
||||
//
|
||||
if (jobExecutionContext != null && !jobExecutionContext.isEmpty()) {
|
||||
job.setJobExecutionListeners(new JobExecutionListener[] { new JobExecutionListenerSupport() {
|
||||
job.setJobExecutionListeners(new JobExecutionListener[] { new JobExecutionListener() {
|
||||
@Override
|
||||
public void beforeJob(JobExecution jobExecution) {
|
||||
ExecutionContext jobContext = jobExecution.getExecutionContext();
|
||||
|
||||
Reference in New Issue
Block a user