Skip to content

Commit

Permalink
Add default methods in listener interfaces
Browse files Browse the repository at this point in the history
Resolves #3924
  • Loading branch information
parikshitdutta authored and fmbenhassine committed Sep 10, 2021
1 parent dacf5bc commit fecf8a5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
@@ -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.
Expand All @@ -25,7 +25,7 @@
* @author Lucas Ward
* @author Michael Minella
* @author Mahmoud Ben Hassine
*
* @author Parikshit Dutta
*/
public interface ChunkListener extends StepListener {

Expand All @@ -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
Expand All @@ -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) {
}
}
@@ -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.
Expand All @@ -22,7 +22,7 @@
* instances themselves are not used by more than one thread.
*
* @author Dave Syer
*
* @author Parikshit Dutta
*/
public interface JobExecutionListener {

Expand All @@ -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
Expand All @@ -40,6 +41,7 @@ public interface JobExecutionListener {
*
* @param jobExecution the current {@link JobExecution}
*/
void afterJob(JobExecution jobExecution);
default void afterJob(JobExecution jobExecution) {
}

}
@@ -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.
Expand All @@ -23,7 +23,7 @@
* @author Lucas Ward
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
* @author Parikshit Dutta
*/
public interface StepExecutionListener extends StepListener {

Expand All @@ -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
Expand All @@ -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;
}
}

0 comments on commit fecf8a5

Please sign in to comment.