001: /*
002: * <copyright>
003: *
004: * Copyright 1997-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */
026:
027: package org.cougaar.core.service;
028:
029: import javax.servlet.Servlet;
030:
031: import org.cougaar.core.component.Service;
032:
033: /**
034: * This service can be used to register a <code>Servlet</code>
035: * for all HTTP requests that match a specified String path.
036: * <p>
037: * This is analogous to a <code>java.util.Map</code>:<pre>
038: * - register with "put(name, value)"
039: * - unregister with "remove(name)"
040: * - unregister-all with "clear()"
041: * </pre>
042: * <p>
043: * "unregisterAll" is called automatically when this service
044: * is released back to the ServiceBroker.
045: * <p>
046: * "Servlet.init(..)" will be called upon <tt>register</tt>
047: * and "Servlet.destroy()" will be called upon <tt>unregister</tt>.
048: * <p>
049: * Also note that multiple concurrent "Servlet.service(..)" calls
050: * can occur, so your Servlet must be reentrant.
051: * <p>
052: * See:
053: * <a href=
054: * "http://java.sun.com/docs/books/tutorial/servlets">
055: * http://java.sun.com/docs/books/tutorial/servlets</a> for
056: * tutorials on how to write Servlets and HttpServlets.
057: */
058: public interface ServletService extends Service {
059:
060: /**
061: * Register a path to call the given <code>Servlet</code>.
062: * <p>
063: * This method will throw an <code>IllegalArgumentException</code>
064: * if the path has already been registered by another ServletService
065: * instance..
066: *
067: * @see #unregister(String)
068: */
069: void register(String path, Servlet servlet) throws Exception;
070:
071: /**
072: * Unregister the <code>Servlet</code> with the specified path.
073: * <p>
074: * This method can only be used to unregister Servlets that have
075: * been registered with <b>this</b> service instance.
076: *
077: * @see #register(String,Servlet)
078: * @see #unregisterAll()
079: */
080: void unregister(String path);
081:
082: /**
083: * Unregister all <code>Servlet</code>s that have been registered
084: * by <b>this</b> registration service instance.
085: * <p>
086: * This can be used as a one-stop cleanup utility.
087: *
088: * @see #unregister(String)
089: */
090: void unregisterAll();
091:
092: /**
093: * Get the HTTP port for the local servlet server.
094: * <p>
095: * A typical HTTP port is 8800, but a different port may be
096: * used due to either node configuration or to support multiple
097: * nodes on the same machine.
098: *
099: * @return the HTTP port, or -1 if HTTP is disabled.
100: */
101: int getHttpPort();
102:
103: /**
104: * Get the HTTPS port for the local servlet server.
105: * <p>
106: * A typical HTTPS port is 8400, but a different port may be
107: * used due to either node configuration or to support multiple
108: * nodes on the same machine.
109: *
110: * @return the HTTPS port, or -1 if HTTPS is disabled.
111: */
112: int getHttpsPort();
113:
114: }
|