diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/ChunkListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/ChunkListener.java index b9ab2f6051..e85171b64a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/ChunkListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/ChunkListener.java @@ -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. @@ -25,7 +25,7 @@ * @author Lucas Ward * @author Michael Minella * @author Mahmoud Ben Hassine - * + * @author Parikshit Dutta */ public interface ChunkListener extends StepListener { @@ -36,14 +36,16 @@ public interface ChunkListener extends StepListener { * * @param context The current {@link ChunkContext} */ - void beforeChunk(ChunkContext context); + default void beforeChunk(ChunkContext context) { + } /** * Callback after the chunk is executed, outside the transaction. * * @param context The current {@link ChunkContext} */ - void afterChunk(ChunkContext context); + default void afterChunk(ChunkContext context) { + } /** * Callback after a chunk has been marked for rollback. It is invoked @@ -57,5 +59,6 @@ public interface ChunkListener extends StepListener { * @param context the chunk context containing the exception that caused * the underlying rollback. */ - void afterChunkError(ChunkContext context); + default void afterChunkError(ChunkContext context) { + } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecutionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecutionListener.java index 52a24f1227..6e088e20ff 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecutionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/JobExecutionListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-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. @@ -22,7 +22,7 @@ * instances themselves are not used by more than one thread. * * @author Dave Syer - * + * @author Parikshit Dutta */ public interface JobExecutionListener { @@ -31,7 +31,8 @@ public interface JobExecutionListener { * * @param jobExecution the current {@link JobExecution} */ - void beforeJob(JobExecution jobExecution); + default void beforeJob(JobExecution jobExecution) { + } /** * Callback after completion of a job. Called after both both successful and @@ -40,6 +41,7 @@ public interface JobExecutionListener { * * @param jobExecution the current {@link JobExecution} */ - void afterJob(JobExecution jobExecution); + default void afterJob(JobExecution jobExecution) { + } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecutionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecutionListener.java index 0bb362df88..bdfebaa698 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecutionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecutionListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-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. @@ -23,7 +23,7 @@ * @author Lucas Ward * @author Dave Syer * @author Mahmoud Ben Hassine - * + * @author Parikshit Dutta */ public interface StepExecutionListener extends StepListener { @@ -33,7 +33,8 @@ public interface StepExecutionListener extends StepListener { * * @param stepExecution instance of {@link StepExecution}. */ - void beforeStep(StepExecution stepExecution); + default void beforeStep(StepExecution stepExecution) { + } /** * Give a listener a chance to modify the exit status from a step. The value @@ -49,5 +50,7 @@ public interface StepExecutionListener extends StepListener { * {@code null} to leave the old value unchanged. */ @Nullable - ExitStatus afterStep(StepExecution stepExecution); + default ExitStatus afterStep(StepExecution stepExecution) { + return null; + } }