View Javadoc

1   /*
2    * Copyright 2009-2010 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.configuration.support;
17  
18  import java.util.Collection;
19  
20  import org.springframework.batch.core.Job;
21  import org.springframework.batch.core.configuration.DuplicateJobException;
22  
23  /**
24   * @author Dave Syer
25   * 
26   * @since 2.1
27   */
28  public interface JobLoader {
29  
30  	/**
31  	 * Load an application context and register all the jobs.
32  	 * 
33  	 * @param factory a factory for an application context (containing jobs)
34  	 * @return a collection of the jobs created
35  	 * 
36  	 * @throws DuplicateJobException if a job with the same name was already
37  	 * registered
38  	 */
39  	Collection<Job> load(ApplicationContextFactory factory) throws DuplicateJobException;
40  
41  	/**
42  	 * Load an application context and register all the jobs, having first
43  	 * unregistered them if already registered. Implementations should also take
44  	 * care to close and clean up the application context previously created if
45  	 * possible (either from this factory or from one with the same jobs).
46  	 * 
47  	 * @param factory a factory for an application context (containing jobs)
48  	 * @return a collection of the jobs created
49  	 * 
50  	 * @throws DuplicateJobException if a job with the same name was already
51  	 * registered
52  	 */
53  	Collection<Job> reload(ApplicationContextFactory factory);
54  
55  	/**
56  	 * Unregister all the jobs and close all the contexts created by this
57  	 * loader.
58  	 */
59  	void clear();
60  
61  }