KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > scheduling > quartz > ResourceJobSchedulingDataProcessor


1 /*
2  * Copyright 2002-2005 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
17 package org.springframework.scheduling.quartz;
18
19 import java.io.IOException JavaDoc;
20 import java.io.InputStream JavaDoc;
21
22 import org.quartz.xml.JobSchedulingDataProcessor;
23
24 import org.springframework.context.ResourceLoaderAware;
25 import org.springframework.core.io.DefaultResourceLoader;
26 import org.springframework.core.io.ResourceLoader;
27 import org.springframework.scheduling.SchedulingException;
28
29 /**
30  * Subclass of Quartz' JobSchedulingDataProcessor that considers
31  * given filenames as Spring resource locations.
32  *
33  * @author Juergen Hoeller
34  * @since 1.1
35  * @see org.springframework.core.io.ResourceLoader
36  */

37 public class ResourceJobSchedulingDataProcessor extends JobSchedulingDataProcessor
38     implements ResourceLoaderAware {
39
40     private ResourceLoader resourceLoader = new DefaultResourceLoader();
41
42
43     public void setResourceLoader(ResourceLoader resourceLoader) {
44         this.resourceLoader = (resourceLoader != null ? resourceLoader : new DefaultResourceLoader());
45     }
46
47
48     protected InputStream JavaDoc getInputStream(String JavaDoc fileName) {
49         try {
50             return this.resourceLoader.getResource(fileName).getInputStream();
51         }
52         catch (IOException JavaDoc ex) {
53             throw new SchedulingException("Could not load job scheduling data XML file", ex);
54         }
55     }
56
57 }
58
Popular Tags