001: // HttpServer.java
002: // $Id: HttpServer.java,v 1.11 2004/03/11 15:11:04 ylafon Exp $
003: // (c) COPYRIGHT MIT and INRIA, 1996.
004: // Please first read the full copyright statement in file COPYRIGHT.html
005:
006: package org.w3c.www.protocol.http;
007:
008: /**
009: * The HttpServer interface.
010: * This interface is used to control the communication between the HttpManager
011: * and the HttpServer on one side, and between the HttpServer and the
012: * HttpConnection on the other side.
013: * <p>The implementation of the Connection part of the interface is optional
014: * and should be provided only if your server instance uses the connection
015: * concept.
016: */
017:
018: public abstract class HttpServer {
019: protected HttpServerState state = null;
020:
021: /**
022: * Get this servers' protocol.
023: * @return A String encoding the protocol used to dialog with the target
024: * server.
025: */
026:
027: abstract public String getProtocol();
028:
029: /**
030: * Get the manager's state for that server.
031: * @return The manager state.
032: */
033:
034: protected final HttpServerState getState() {
035: return state;
036: }
037:
038: /**
039: * Get this server's major version number.
040: * @return The server's major number version, or <strong>-1</strong>
041: * if still unknown.
042: */
043:
044: abstract public short getMajorVersion();
045:
046: /**
047: * Get this server's minor version number.
048: * @return The server's minor number version, or <strong>-1</strong>
049: * if still unknown.
050: */
051:
052: abstract public short getMinorVersion();
053:
054: /**
055: * HTTP manager interface - Handle this request in sync mode.
056: * @param request The request this server should run.
057: * @return A Reply instance, containing the target server's reply.
058: * @exception HttpException If anything failed during request processing.
059: */
060:
061: abstract public Reply runRequest(Request request)
062: throws HttpException;
063:
064: /**
065: * Interrupt the given request (that was launched by that server).
066: * @param request The request to interrupt.
067: */
068:
069: abstract protected void interruptRequest(Request request);
070:
071: /**
072: * Set the new timeout for this server
073: * @param timeout The timeout value in milliseconds
074: */
075:
076: abstract protected void setTimeout(int timeout);
077:
078: /**
079: * Set the new connection timeout for this server
080: * @param timeout The timeout value in milliseconds
081: */
082:
083: abstract protected void setConnTimeout(int conn_timeout);
084:
085: /**
086: * Initialize this server instance for the given target location.
087: * @param manager The central HTTP protocol manager.
088: * @param state The manager's state for that server.
089: * @param host The target server's FQDN.
090: * @param port The target server's port number.
091: * @param timeout The timeout in millisecond for the sockets
092: * @exception HttpException If host coulnd't be resolved.
093: */
094:
095: abstract public void initialize(HttpManager manager,
096: HttpServerState state, String host, int port, int timeout)
097: throws HttpException;
098:
099: /**
100: * Initialize this server instance for the given target location.
101: * @param manager The central HTTP protocol manager.
102: * @param state The manager's state for that server.
103: * @param host The target server's FQDN.
104: * @param port The target server's port number.
105: * @param timeout The timeout in millisecond for the sockets
106: * @param timeout The connection timeout in millisecond for the sockets
107: * @exception HttpException If host coulnd't be resolved.
108: */
109:
110: abstract public void initialize(HttpManager manager,
111: HttpServerState state, String host, int port, int timeout,
112: int connect_timeout) throws HttpException;
113: }
|