KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > Loader


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18
19 package org.apache.catalina;
20
21
22 import java.beans.PropertyChangeListener JavaDoc;
23
24
25 /**
26  * A <b>Loader</b> represents a Java ClassLoader implementation that can
27  * be used by a Container to load class files (within a repository associated
28  * with the Loader) that are designed to be reloaded upon request, as well as
29  * a mechanism to detect whether changes have occurred in the underlying
30  * repository.
31  * <p>
32  * In order for a <code>Loader</code> implementation to successfully operate
33  * with a <code>Context</code> implementation that implements reloading, it
34  * must obey the following constraints:
35  * <ul>
36  * <li>Must implement <code>Lifecycle</code> so that the Context can indicate
37  * that a new class loader is required.
38  * <li>The <code>start()</code> method must unconditionally create a new
39  * <code>ClassLoader</code> implementation.
40  * <li>The <code>stop()</code> method must throw away its reference to the
41  * <code>ClassLoader</code> previously utilized, so that the class loader,
42  * all classes loaded by it, and all objects of those classes, can be
43  * garbage collected.
44  * <li>Must allow a call to <code>stop()</code> to be followed by a call to
45  * <code>start()</code> on the same <code>Loader</code> instance.
46  * <li>Based on a policy chosen by the implementation, must call the
47  * <code>Context.reload()</code> method on the owning <code>Context</code>
48  * when a change to one or more of the class files loaded by this class
49  * loader is detected.
50  * </ul>
51  *
52  * @author Craig R. McClanahan
53  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
54  */

55
56 public interface Loader {
57
58
59     // ------------------------------------------------------------- Properties
60

61
62     /**
63      * Execute a periodic task, such as reloading, etc. This method will be
64      * invoked inside the classloading context of this container. Unexpected
65      * throwables will be caught and logged.
66      */

67     public void backgroundProcess();
68
69
70     /**
71      * Return the Java class loader to be used by this Container.
72      */

73     public ClassLoader JavaDoc getClassLoader();
74
75
76     /**
77      * Return the Container with which this Loader has been associated.
78      */

79     public Container getContainer();
80
81
82     /**
83      * Set the Container with which this Loader has been associated.
84      *
85      * @param container The associated Container
86      */

87     public void setContainer(Container container);
88
89
90     /**
91      * Return the "follow standard delegation model" flag used to configure
92      * our ClassLoader.
93      */

94     public boolean getDelegate();
95
96
97     /**
98      * Set the "follow standard delegation model" flag used to configure
99      * our ClassLoader.
100      *
101      * @param delegate The new flag
102      */

103     public void setDelegate(boolean delegate);
104
105
106     /**
107      * Return descriptive information about this Loader implementation and
108      * the corresponding version number, in the format
109      * <code>&lt;description&gt;/&lt;version&gt;</code>.
110      */

111     public String JavaDoc getInfo();
112
113
114     /**
115      * Return the reloadable flag for this Loader.
116      */

117     public boolean getReloadable();
118
119
120     /**
121      * Set the reloadable flag for this Loader.
122      *
123      * @param reloadable The new reloadable flag
124      */

125     public void setReloadable(boolean reloadable);
126
127
128     // --------------------------------------------------------- Public Methods
129

130
131     /**
132      * Add a property change listener to this component.
133      *
134      * @param listener The listener to add
135      */

136     public void addPropertyChangeListener(PropertyChangeListener JavaDoc listener);
137
138
139     /**
140      * Add a new repository to the set of repositories for this class loader.
141      *
142      * @param repository Repository to be added
143      */

144     public void addRepository(String JavaDoc repository);
145
146
147     /**
148      * Return the set of repositories defined for this class loader.
149      * If none are defined, a zero-length array is returned.
150      */

151     public String JavaDoc[] findRepositories();
152
153
154     /**
155      * Has the internal repository associated with this Loader been modified,
156      * such that the loaded classes should be reloaded?
157      */

158     public boolean modified();
159
160
161     /**
162      * Remove a property change listener from this component.
163      *
164      * @param listener The listener to remove
165      */

166     public void removePropertyChangeListener(PropertyChangeListener JavaDoc listener);
167
168
169 }
170
Popular Tags