Class sun.server.Server
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sun.server.Server

java.lang.Object
   |
   +----sun.server.Server

public class Server
extends Object
implements Runnable
An abstract class for implementing network servers that manage multiple connection handler threads.

Variable Index

 o avail
The number of handler threads waiting for connections.
 o connections
Queue of pending connections.
 o handlers
The thread group for handler threads.
 o maxThreads
Maximum number of handler threads.
 o minThreads
Minimum number of handler threads.
 o params
The parameters for this server.
 o port
The server port number.
 o shutdown
Set to true when server shutdown is in progress.
 o timeout
Handler thread timeout.
 o total
The total number of handler threads.
 o useNative
Set to true if native library support is available.

Constructor Index

 o Server()
Creates a new server with default parameters.
 o Server(ServerParameters)

Method Index

 o createHandler()
Creates a new connection handler.
 o error(String)
Issues a non-fatal error message and returns.
 o error(String, Exception)
Issues a non-fatal error message with exception trace and returns.
 o fatal(String)
Issues a fatal (non-recoverable) error message and then exits.
 o fatal(String, Exception)
Issues a fatal (non-recoverable) error message with exception trace and then exits.
 o getConnection()
Gets a connection socket from the connection queue.
 o getServerParameters()
Returns the parameters for this server.
 o inShutdown()
Returns true if this server is in the process of a shutdown.
 o putConnection(Socket)
Adds a new connection socket to the connection queue.
 o run()
Starts the server.
 o setGroup(String)
Sets the current group to the specified group name or group id.
 o setUser(String)
Sets the current user to the specified user name or user id.
 o shutdown()
Initiates server shutdown.
 o waitJeevesEvent()
Blocks until the Jeeves Event is triggered.

Variables

 o connections
  protected Queue connections
Queue of pending connections.
 o handlers
  protected ThreadGroup handlers
The thread group for handler threads.
 o minThreads
  protected int minThreads
Minimum number of handler threads.
 o maxThreads
  protected int maxThreads
Maximum number of handler threads.
 o timeout
  protected long timeout
Handler thread timeout.
 o port
  protected int port
The server port number.
 o avail
  protected int avail
The number of handler threads waiting for connections.
 o total
  protected int total
The total number of handler threads.
 o shutdown
  protected boolean shutdown
Set to true when server shutdown is in progress.
 o params
  protected ServerParameters params
The parameters for this server.
 o useNative
  protected static boolean useNative
Set to true if native library support is available.

Constructors

 o Server
  protected Server(ServerParameters params)
 o Server
  protected Server()
Creates a new server with default parameters.

Methods

 o run
  public void run()
Starts the server. Will return when server has been stopped.
 o putConnection
  protected void putConnection(Socket s)
Adds a new connection socket to the connection queue.
Parameters:
s - the socket to be added
 o getConnection
  protected Socket getConnection()
Gets a connection socket from the connection queue.
Returns:
the socket, or null if the handler has timed-out.
 o createHandler
  protected abstract ServerHandler createHandler()
Creates a new connection handler.
Returns:
the handler object
 o getServerParameters
  public ServerParameters getServerParameters()
Returns the parameters for this server.
 o shutdown
  public synchronized void shutdown()
Initiates server shutdown.
 o inShutdown
  public synchronized boolean inShutdown()
Returns true if this server is in the process of a shutdown.
 o error
  public void error(String s)
Issues a non-fatal error message and returns.
Parameters:
s - the error message
 o error
  public void error(String s,
                    Exception e)
Issues a non-fatal error message with exception trace and returns.
Parameters:
s - the error message
e - the error exception
 o fatal
  public void fatal(String s)
Issues a fatal (non-recoverable) error message and then exits.
Parameters:
s - the error message
 o fatal
  public void fatal(String s,
                    Exception e)
Issues a fatal (non-recoverable) error message with exception trace and then exits.
Parameters:
s - the error message
e - the error exception
 o setUser
  protected static boolean setUser(String user)
Sets the current user to the specified user name or user id.
Parameters:
user - the user name or id
Returns:
true if user was changed, false if permission denied
Throws: IllegalArgumentException
if the user name or id was invalid
 o setGroup
  protected static boolean setGroup(String group)
Sets the current group to the specified group name or group id.
Parameters:
group - the group name or id
Returns:
true if group was changed, false if permission denied
Throws: IllegalArgumentException
if the group name or id was invalid
 o waitJeevesEvent
  public void waitJeevesEvent()
Blocks until the Jeeves Event is triggered. The thread invoking this method should invoke the shutdown() method on returning from this method.

All Packages  Class Hierarchy  This Package  Previous  Next  Index