01: /*
02: * <copyright>
03: *
04: * Copyright 2000-2004 BBNT Solutions, LLC
05: * under sponsorship of the Defense Advanced Research Projects
06: * Agency (DARPA).
07: *
08: * You can redistribute this software and/or modify it under the
09: * terms of the Cougaar Open Source License as published on the
10: * Cougaar Open Source Website (www.cougaar.org).
11: *
12: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: *
24: * </copyright>
25: */
26: package org.cougaar.lib.web.arch;
27:
28: import java.util.List;
29:
30: import javax.servlet.Servlet;
31: import javax.servlet.ServletConfig;
32:
33: /**
34: * A table of servlets.
35: */
36: public interface ServletRegistry {
37:
38: /**
39: * Get a Servlet with the matching name.
40: * <p>
41: * A PrefixMatch will be returned if the name matches a registered
42: * regular expression. For example:<pre>
43: * register("foo", myServlet);
44: * Object o = get("foo/bar");
45: * assert (o instanceof PrefixMatch);
46: * Object oo = ((PrefixMatch) o).getValue();
47: * assert (oo == myServlet);
48: * </pre>
49: *
50: * @return null, Servlet, or PrefixMatch
51: * @see org.cougaar.lib.web.arch.util.PrefixMatch
52: */
53: Object get(String name);
54:
55: /**
56: * List the registered names.
57: */
58: List listNames();
59:
60: /**
61: * Initialize with the {@link ServletConfig}.
62: */
63: void init(ServletConfig config);
64:
65: /**
66: * Get the {@link ServletConfig} set in {@link #init}.
67: */
68: ServletConfig getServletConfig();
69:
70: /**
71: * Register a (name, servlet) for future "get(name)" requests.
72: * <p>
73: * The name must be HTTP-safe -- see RFC 1945 for details.
74: * <p>
75: * If the same Servlet is registered multiple times, or
76: * multiple threads attempt the simultaneous register
77: * and unregister of a Servlet, then the order of
78: * "Servlet.init()" and "Servlet.destroy()" is not
79: * defined.
80: *
81: * @see #unregister(String)
82: */
83: void register(String name, Servlet servlet);
84:
85: /**
86: * Unregister and "Servlet.destroy()" the Servlet with the
87: * matching name.
88: *
89: * @see #register(String,Servlet)
90: */
91: boolean unregister(String name);
92:
93: /**
94: * Unregister all Servlets that have been registered by
95: * <b>this</b> instance's "register(..)" method.
96: */
97: void unregisterAll();
98:
99: }
|