001: // ServerHandler.java
002: // $Id: ServerHandler.java,v 1.8 2000/08/16 21:37:35 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.jigsaw.daemon;
007:
008: import java.net.InetAddress;
009:
010: import org.w3c.util.ObservableProperties;
011:
012: import org.w3c.tools.resources.ResourceReference;
013:
014: /**
015: * A ServerHandler is a class that handles an accepting socket.
016: */
017:
018: public interface ServerHandler {
019:
020: /**
021: * Get this server identifier.
022: * @return A String identifying this server context.
023: */
024:
025: public String getIdentifier();
026:
027: /**
028: * Log an error into this server's error log.
029: * @param msg The message to log.
030: */
031:
032: public void errlog(String msg);
033:
034: /**
035: * Log a normal message into this server's log.
036: * @param msg The message to log.
037: */
038:
039: public void log(String msg);
040:
041: /**
042: * Emit a debugging trace on behalf of this server.
043: * @param msg The trace to emit.
044: */
045:
046: public void trace(String msg);
047:
048: /**
049: * Get the network addresses on which this server is listening.
050: * @return The InetAddress this server is listening to.
051: */
052:
053: public InetAddress getInetAddress();
054:
055: /**
056: * Get the root, configuration resource for that server.
057: * @return A ContainerResource instance.
058: */
059:
060: public ResourceReference getConfigResource();
061:
062: /**
063: * Clone this server handler, and custmozie it with the given properties.
064: * <p>Once cloned, the new server is assumed to be running happily,
065: * as if it had been initialized.
066: * @param shm The global server handler manager.
067: * @param identifier The new ServerHandler identifier.
068: * @param props The properties that overide part of the configuration of
069: * the cloned server.
070: * @return A newly created server, <em>sharing</em> the configuration
071: * of the cloned server, except for the config options defined by
072: * the given property set.
073: * @exception ServerHandlerInitException if initialization failed.
074: */
075:
076: public ServerHandler clone(ServerHandlerManager shm,
077: String identifier, ObservableProperties props)
078: throws ServerHandlerInitException;
079:
080: /**
081: * Initialize the server from the given set of properties.
082: * This method is called by the ServerManager instance, when launching
083: * the appropriate servers.
084: * <p>A Server instance that has initialize itself successfully is
085: * considered to be running.
086: * @param shm The global server handler manager.
087: * @param identifier A String identifying the server.
088: * @param props The property set this server should use to initialize
089: * itself.
090: * @exception ServerHandlerInitException if initialization failed.
091: */
092:
093: public void initialize(ServerHandlerManager shm, String id,
094: ObservableProperties props)
095: throws ServerHandlerInitException;
096:
097: /**
098: * Start the server, after everything has been initialized.
099: * itself.
100: * @exception ServerHandlerInitException if initialization failed.
101: */
102: public void start() throws ServerHandlerInitException;
103:
104: /**
105: * Shutdown this server handler.
106: * This is a synchronous method, that will return only once the server
107: * has been shutdown entirely (all the resources it uses have been
108: * released).
109: * <p>This server handler clones are considered shutdown too.
110: */
111:
112: public void shutdown();
113:
114: }
|