001: /*
002: * Copyright 1999,2004 The Apache Software Foundation.
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: * http://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: */
016:
017: package org.apache.catalina;
018:
019: import java.beans.PropertyChangeListener;
020: import javax.naming.directory.DirContext;
021: import org.apache.catalina.deploy.ApplicationParameter;
022: import org.apache.catalina.deploy.ContextEjb;
023: import org.apache.catalina.deploy.ContextEnvironment;
024: import org.apache.catalina.deploy.ContextResource;
025: import org.apache.catalina.deploy.ContextResourceLink;
026: import org.apache.catalina.deploy.NamingResources;
027: import org.apache.catalina.deploy.ResourceParams;
028:
029: /**
030: * Used to store the default configuration a Host will use
031: * when creating a Context. A Context configured in server.xml
032: * can override these defaults by setting the Context attribute
033: * <CODE>override="true"</CODE>.
034: *
035: * @author Glenn Nielsen
036: * @author Remy Maucherat
037: * @version $Revision: 1.6 $ $Date: 2004/05/26 15:26:06 $
038: */
039:
040: public interface DefaultContext {
041:
042: // ------------------------------------------------------------- Properties
043:
044: /**
045: * Return the "use cookies for session ids" flag.
046: */
047: public boolean getCookies();
048:
049: /**
050: * Set the "use cookies for session ids" flag.
051: *
052: * @param cookies The new flag
053: */
054: public void setCookies(boolean cookies);
055:
056: /**
057: * Return the "allow crossing servlet contexts" flag.
058: */
059: public boolean getCrossContext();
060:
061: /**
062: * Set the "allow crossing servlet contexts" flag.
063: *
064: * @param crossContext The new cross contexts flag
065: */
066: public void setCrossContext(boolean crossContext);
067:
068: /**
069: * Return descriptive information about this Container implementation and
070: * the corresponding version number, in the format
071: * <code><description>/<version></code>.
072: */
073: public String getInfo();
074:
075: /**
076: * Return the reloadable flag for this web application.
077: */
078: public boolean getReloadable();
079:
080: /**
081: * Set the reloadable flag for this web application.
082: *
083: * @param reloadable The new reloadable flag
084: */
085: public void setReloadable(boolean reloadable);
086:
087: /**
088: * Return the Java class name of the Wrapper implementation used
089: * for servlets registered in this Context.
090: */
091: public String getWrapperClass();
092:
093: /**
094: * Set the Java class name of the Wrapper implementation used
095: * for servlets registered in this Context.
096: *
097: * @param wrapperClass The new wrapper class
098: */
099: public void setWrapperClass(String wrapperClass);
100:
101: /**
102: * Set the resources DirContext object with which this Container is
103: * associated.
104: *
105: * @param resources The newly associated DirContext
106: */
107: public void setResources(DirContext resources);
108:
109: /**
110: * Get the resources DirContext object with which this Container is
111: * associated.
112: */
113: public DirContext getResources();
114:
115: /**
116: * Return the Loader with which this Container is associated. If there is
117: * no associated Loader return <code>null</code>.
118: */
119: public Loader getLoader();
120:
121: /**
122: * Set the Loader with which this Context is associated.
123: *
124: * @param loader The newly associated loader
125: */
126: public void setLoader(Loader loader);
127:
128: /**
129: * Return the Manager with which this Container is associated. If there is
130: * no associated Manager return <code>null</code>.
131: */
132: public Manager getManager();
133:
134: /**
135: * Set the Manager with which this Container is associated.
136: *
137: * @param manager The newly associated Manager
138: */
139: public void setManager(Manager manager);
140:
141: /**
142: * Return the naming resources associated with this web application.
143: */
144: public NamingResources getNamingResources();
145:
146: // ------------------------------------------------------ Public Properties
147:
148: /**
149: * Return the name of this DefaultContext
150: */
151: public String getName();
152:
153: /**
154: * Set the name of the default context.
155: *
156: * @param name The new name
157: */
158: public void setName(String name);
159:
160: /**
161: * Return the Container for which this Container is a child, if there is
162: * one. If there is no defined parent, return <code>null</code>.
163: */
164: public Container getParent();
165:
166: /**
167: * Set the parent Container to which this Container is being added as a
168: * child. This Container may refuse to become attached to the specified
169: * Container by throwing an exception.
170: *
171: * @param container Container to which this Container is being added
172: * as a child
173: *
174: * @exception IllegalArgumentException if this Container refuses to become
175: * attached to the specified Container
176: */
177: public void setParent(Container container);
178:
179: // -------------------------------------------------------- Context Methods
180:
181: /**
182: * Add a new Listener class name to the set of Listeners
183: * configured for this application.
184: *
185: * @param listener Java class name of a listener class
186: */
187: public void addApplicationListener(String listener);
188:
189: /**
190: * Add a new application parameter for this application.
191: *
192: * @param parameter The new application parameter
193: */
194: public void addApplicationParameter(ApplicationParameter parameter);
195:
196: /**
197: * Add an EJB resource reference for this web application.
198: *
199: * @param ejb New EJB resource reference
200: */
201: public void addEjb(ContextEjb ejb);
202:
203: /**
204: * Add an environment entry for this web application.
205: *
206: * @param environment New environment entry
207: */
208: public void addEnvironment(ContextEnvironment environment);
209:
210: /**
211: * Add resource parameters for this web application.
212: *
213: * @param resourceParameters New resource parameters
214: */
215: public void addResourceParams(ResourceParams resourceParameters);
216:
217: /**
218: * Add the classname of an InstanceListener to be added to each
219: * Wrapper appended to this Context.
220: *
221: * @param listener Java class name of an InstanceListener class
222: */
223: public void addInstanceListener(String listener);
224:
225: /**
226: * Add a new context initialization parameter, replacing any existing
227: * value for the specified name.
228: *
229: * @param name Name of the new parameter
230: * @param value Value of the new parameter
231: *
232: * @exception IllegalArgumentException if the name or value is missing,
233: * or if this context initialization parameter has already been
234: * registered
235: */
236: public void addParameter(String name, String value);
237:
238: /**
239: * Add a property change listener to this component.
240: *
241: * @param listener The listener to add
242: */
243: public void addPropertyChangeListener(
244: PropertyChangeListener listener);
245:
246: /**
247: * Add a resource reference for this web application.
248: *
249: * @param resource New resource reference
250: */
251: public void addResource(ContextResource resource);
252:
253: /**
254: * Add a resource environment reference for this web application.
255: *
256: * @param name The resource environment reference name
257: * @param type The resource environment reference type
258: */
259: public void addResourceEnvRef(String name, String type);
260:
261: /**
262: * Add a resource link for this web application.
263: *
264: * @param resourceLink New resource link
265: */
266: public void addResourceLink(ContextResourceLink resourceLink);
267:
268: /**
269: * Add the classname of a LifecycleListener to be added to each
270: * Wrapper appended to this Context.
271: *
272: * @param listener Java class name of a LifecycleListener class
273: */
274: public void addWrapperLifecycle(String listener);
275:
276: /**
277: * Add the classname of a ContainerListener to be added to each
278: * Wrapper appended to this Context.
279: *
280: * @param listener Java class name of a ContainerListener class
281: */
282: public void addWrapperListener(String listener);
283:
284: /**
285: * Return the set of application listener class names configured
286: * for this application.
287: */
288: public String[] findApplicationListeners();
289:
290: /**
291: * Return the set of application parameters for this application.
292: */
293: public ApplicationParameter[] findApplicationParameters();
294:
295: /**
296: * Return the EJB resource reference with the specified name, if any;
297: * otherwise, return <code>null</code>.
298: *
299: * @param name Name of the desired EJB resource reference
300: */
301: public ContextEjb findEjb(String name);
302:
303: /**
304: * Return the defined EJB resource references for this application.
305: * If there are none, a zero-length array is returned.
306: */
307: public ContextEjb[] findEjbs();
308:
309: /**
310: * Return the environment entry with the specified name, if any;
311: * otherwise, return <code>null</code>.
312: *
313: * @param name Name of the desired environment entry
314: */
315: public ContextEnvironment findEnvironment(String name);
316:
317: /**
318: * Return the set of defined environment entries for this web
319: * application. If none have been defined, a zero-length array
320: * is returned.
321: */
322: public ContextEnvironment[] findEnvironments();
323:
324: /**
325: * Return the set of defined resource parameters for this web
326: * application. If none have been defined, a zero-length array
327: * is returned.
328: */
329: public ResourceParams[] findResourceParams();
330:
331: /**
332: * Return the set of InstanceListener classes that will be added to
333: * newly created Wrappers automatically.
334: */
335: public String[] findInstanceListeners();
336:
337: /**
338: * Return the value for the specified context initialization
339: * parameter name, if any; otherwise return <code>null</code>.
340: *
341: * @param name Name of the parameter to return
342: */
343: public String findParameter(String name);
344:
345: /**
346: * Return the names of all defined context initialization parameters
347: * for this Context. If no parameters are defined, a zero-length
348: * array is returned.
349: */
350: public String[] findParameters();
351:
352: /**
353: * Return the resource reference with the specified name, if any;
354: * otherwise return <code>null</code>.
355: *
356: * @param name Name of the desired resource reference
357: */
358: public ContextResource findResource(String name);
359:
360: /**
361: * Return the resource environment reference type for the specified
362: * name, if any; otherwise return <code>null</code>.
363: *
364: * @param name Name of the desired resource environment reference
365: */
366: public String findResourceEnvRef(String name);
367:
368: /**
369: * Return the set of resource environment reference names for this
370: * web application. If none have been specified, a zero-length
371: * array is returned.
372: */
373: public String[] findResourceEnvRefs();
374:
375: /**
376: * Return the resource link with the specified name, if any;
377: * otherwise return <code>null</code>.
378: *
379: * @param name Name of the desired resource link
380: */
381: public ContextResourceLink findResourceLink(String name);
382:
383: /**
384: * Return the defined resource links for this application. If
385: * none have been defined, a zero-length array is returned.
386: */
387: public ContextResourceLink[] findResourceLinks();
388:
389: /**
390: * Return the defined resource references for this application. If
391: * none have been defined, a zero-length array is returned.
392: */
393: public ContextResource[] findResources();
394:
395: /**
396: * Return the set of LifecycleListener classes that will be added to
397: * newly created Wrappers automatically.
398: */
399: public String[] findWrapperLifecycles();
400:
401: /**
402: * Return the set of ContainerListener classes that will be added to
403: * newly created Wrappers automatically.
404: */
405: public String[] findWrapperListeners();
406:
407: /**
408: * Remove the specified application listener class from the set of
409: * listeners for this application.
410: *
411: * @param listener Java class name of the listener to be removed
412: */
413: public void removeApplicationListener(String listener);
414:
415: /**
416: * Remove the application parameter with the specified name from
417: * the set for this application.
418: *
419: * @param name Name of the application parameter to remove
420: */
421: public void removeApplicationParameter(String name);
422:
423: /**
424: * Remove any EJB resource reference with the specified name.
425: *
426: * @param name Name of the EJB resource reference to remove
427: */
428: public void removeEjb(String name);
429:
430: /**
431: * Remove any environment entry with the specified name.
432: *
433: * @param name Name of the environment entry to remove
434: */
435: public void removeEnvironment(String name);
436:
437: /**
438: * Remove a class name from the set of InstanceListener classes that
439: * will be added to newly created Wrappers.
440: *
441: * @param listener Class name of an InstanceListener class to be removed
442: */
443: public void removeInstanceListener(String listener);
444:
445: /**
446: * Remove the context initialization parameter with the specified
447: * name, if it exists; otherwise, no action is taken.
448: *
449: * @param name Name of the parameter to remove
450: */
451: public void removeParameter(String name);
452:
453: /**
454: * Remove a property change listener from this component.
455: *
456: * @param listener The listener to remove
457: */
458: public void removePropertyChangeListener(
459: PropertyChangeListener listener);
460:
461: /**
462: * Remove any resource reference with the specified name.
463: *
464: * @param name Name of the resource reference to remove
465: */
466: public void removeResource(String name);
467:
468: /**
469: * Remove any resource environment reference with the specified name.
470: *
471: * @param name Name of the resource environment reference to remove
472: */
473: public void removeResourceEnvRef(String name);
474:
475: /**
476: * Remove any resource link with the specified name.
477: *
478: * @param name Name of the resource link to remove
479: */
480: public void removeResourceLink(String name);
481:
482: /**
483: * Remove a class name from the set of LifecycleListener classes that
484: * will be added to newly created Wrappers.
485: *
486: * @param listener Class name of a LifecycleListener class to be removed
487: */
488: public void removeWrapperLifecycle(String listener);
489:
490: /**
491: * Remove a class name from the set of ContainerListener classes that
492: * will be added to newly created Wrappers.
493: *
494: * @param listener Class name of a ContainerListener class to be removed
495: */
496: public void removeWrapperListener(String listener);
497:
498: // --------------------------------------------------------- Public Methods
499:
500: /**
501: * Import the configuration from the DefaultContext into
502: * current Context.
503: *
504: * @param context current web application context
505: */
506: public void importDefaultContext(Context context);
507:
508: }
|