001/*
002 * Copyright 2006-2018 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.springframework.batch.core;
017
018import org.springframework.lang.Nullable;
019
020/**
021 * Listener interface for the lifecycle of a {@link Step}.
022 *
023 * @author Lucas Ward
024 * @author Dave Syer
025 * @author Mahmoud Ben Hassine
026 *
027 */
028public interface StepExecutionListener extends StepListener {
029
030        /**
031         * Initialize the state of the listener with the {@link StepExecution} from
032         * the current scope.
033         *
034         * @param stepExecution instance of {@link StepExecution}.
035         */
036        void beforeStep(StepExecution stepExecution);
037
038        /**
039         * Give a listener a chance to modify the exit status from a step. The value
040         * returned will be combined with the normal exit status using
041         * {@link ExitStatus#and(ExitStatus)}.
042         *
043         * Called after execution of step's processing logic (both successful or
044         * failed). Throwing exception in this method has no effect, it will only be
045         * logged.
046         *
047         * @param stepExecution {@link StepExecution} instance.
048         * @return an {@link ExitStatus} to combine with the normal value. Return
049         * {@code null} to leave the old value unchanged.
050         */
051        @Nullable
052        ExitStatus afterStep(StepExecution stepExecution);
053}