001/* 002 * Copyright 2009-2013 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.configuration.support; 017 018import java.util.Collection; 019 020import org.springframework.batch.core.Job; 021import org.springframework.batch.core.configuration.DuplicateJobException; 022 023/** 024 * @author Dave Syer 025 * 026 * @since 2.1 027 */ 028public interface JobLoader { 029 030 /** 031 * Load an application context and register all the jobs. 032 * 033 * @param factory a factory for an application context (containing jobs) 034 * @return a collection of the jobs created 035 * 036 * @throws DuplicateJobException if a job with the same name was already 037 * registered 038 */ 039 Collection<Job> load(ApplicationContextFactory factory) throws DuplicateJobException; 040 041 /** 042 * Load an application context and register all the jobs, having first 043 * unregistered them if already registered. Implementations should also take 044 * care to close and clean up the application context previously created if 045 * possible (either from this factory or from one with the same jobs). 046 * 047 * @param factory a factory for an application context (containing jobs) 048 * @return a collection of the jobs created 049 */ 050 Collection<Job> reload(ApplicationContextFactory factory); 051 052 /** 053 * Unregister all the jobs and close all the contexts created by this 054 * loader. 055 */ 056 void clear(); 057 058}