1 /*
2 * Copyright 2006-2013 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.springframework.batch.core;
17
18 /**
19 * Provide callbacks at specific points in the lifecycle of a {@link Job}.
20 * Implementations can be stateful if they are careful to either ensure thread
21 * safety, or to use one instance of a listener per job, assuming that job
22 * instances themselves are not used by more than one thread.
23 *
24 * @author Dave Syer
25 *
26 */
27 public interface JobExecutionListener {
28
29 /**
30 * Callback before a job executes.
31 *
32 * @param jobExecution the current {@link JobExecution}
33 */
34 void beforeJob(JobExecution jobExecution);
35
36 /**
37 * Callback after completion of a job. Called after both both successful and
38 * failed executions. To perform logic on a particular status, use
39 * "if (jobExecution.getStatus() == BatchStatus.X)".
40 *
41 * @param jobExecution the current {@link JobExecution}
42 */
43 void afterJob(JobExecution jobExecution);
44
45 }