KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quartz > simpl > LoadingLoaderClassLoadHelper


1 /*
2  * Copyright 2004-2005 OpenSymphony
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations
14  * under the License.
15  *
16  */

17
18 /*
19  * Previously Copyright (c) 2001-2004 James House
20  */

21 package org.quartz.simpl;
22
23 import org.quartz.spi.ClassLoadHelper;
24
25 import java.net.URL JavaDoc;
26 import java.io.InputStream JavaDoc;
27
28 /**
29  * A <code>ClassLoadHelper</code> that uses either the loader of it's own
30  * class (<code>this.getClass().getClassLoader().loadClass( .. )</code>).
31  *
32  * @see org.quartz.spi.ClassLoadHelper
33  * @see org.quartz.simpl.InitThreadContextClassLoadHelper
34  * @see org.quartz.simpl.SimpleClassLoadHelper
35  * @see org.quartz.simpl.CascadingClassLoadHelper
36  *
37  * @author jhouse
38  */

39 public class LoadingLoaderClassLoadHelper implements ClassLoadHelper {
40
41     /*
42      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43      *
44      * Interface.
45      *
46      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
47      */

48
49     /**
50      * Called to give the ClassLoadHelper a chance to initialize itself,
51      * including the oportunity to "steal" the class loader off of the calling
52      * thread, which is the thread that is initializing Quartz.
53      */

54     public void initialize() {
55     }
56
57     /**
58      * Return the class with the given name.
59      */

60     public Class JavaDoc loadClass(String JavaDoc name) throws ClassNotFoundException JavaDoc {
61         return getClassLoader().loadClass(name);
62     }
63
64     /**
65      * Finds a resource with a given name. This method returns null if no
66      * resource with this name is found.
67      * @param name name of the desired resource
68      * @return a java.net.URL object
69      */

70     public URL JavaDoc getResource(String JavaDoc name) {
71         return getClassLoader().getResource(name);
72     }
73
74     /**
75      * Finds a resource with a given name. This method returns null if no
76      * resource with this name is found.
77      * @param name name of the desired resource
78      * @return a java.io.InputStream object
79      */

80     public InputStream JavaDoc getResourceAsStream(String JavaDoc name) {
81         return getClassLoader().getResourceAsStream(name);
82     }
83
84     private ClassLoader JavaDoc getClassLoader() {
85         return this.getClass().getClassLoader();
86     }
87 }
88
Popular Tags