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.
-
avail
- The number of handler threads waiting for connections.
-
connections
- Queue of pending connections.
-
handlers
- The thread group for handler threads.
-
maxThreads
- Maximum number of handler threads.
-
minThreads
- Minimum number of handler threads.
-
params
- The parameters for this server.
-
port
- The server port number.
-
shutdown
- Set to true when server shutdown is in progress.
-
timeout
- Handler thread timeout.
-
total
- The total number of handler threads.
-
useNative
- Set to true if native library support is available.
-
Server()
- Creates a new server with default parameters.
-
Server(ServerParameters)
-
-
createHandler()
- Creates a new connection handler.
-
error(String)
- Issues a non-fatal error message and returns.
-
error(String, Exception)
- Issues a non-fatal error message with exception trace and returns.
-
fatal(String)
- Issues a fatal (non-recoverable) error message and then exits.
-
fatal(String, Exception)
- Issues a fatal (non-recoverable) error message with exception trace
and then exits.
-
getConnection()
- Gets a connection socket from the connection queue.
-
getServerParameters()
- Returns the parameters for this server.
-
inShutdown()
- Returns true if this server is in the process of a shutdown.
-
putConnection(Socket)
- Adds a new connection socket to the connection queue.
-
run()
- Starts the server.
-
setGroup(String)
- Sets the current group to the specified group name or group id.
-
setUser(String)
- Sets the current user to the specified user name or user id.
-
shutdown()
- Initiates server shutdown.
-
waitJeevesEvent()
- Blocks until the Jeeves Event is triggered.
connections
protected Queue connections
- Queue of pending connections.
handlers
protected ThreadGroup handlers
- The thread group for handler threads.
minThreads
protected int minThreads
- Minimum number of handler threads.
maxThreads
protected int maxThreads
- Maximum number of handler threads.
timeout
protected long timeout
- Handler thread timeout.
port
protected int port
- The server port number.
avail
protected int avail
- The number of handler threads waiting for connections.
total
protected int total
- The total number of handler threads.
shutdown
protected boolean shutdown
- Set to true when server shutdown is in progress.
params
protected ServerParameters params
- The parameters for this server.
useNative
protected static boolean useNative
- Set to true if native library support is available.
Server
protected Server(ServerParameters params)
Server
protected Server()
- Creates a new server with default parameters.
run
public void run()
- Starts the server. Will return when server has been stopped.
putConnection
protected void putConnection(Socket s)
- Adds a new connection socket to the connection queue.
- Parameters:
- s - the socket to be added
getConnection
protected Socket getConnection()
- Gets a connection socket from the connection queue.
- Returns:
- the socket, or null if the handler has timed-out.
createHandler
protected abstract ServerHandler createHandler()
- Creates a new connection handler.
- Returns:
- the handler object
getServerParameters
public ServerParameters getServerParameters()
- Returns the parameters for this server.
shutdown
public synchronized void shutdown()
- Initiates server shutdown.
inShutdown
public synchronized boolean inShutdown()
- Returns true if this server is in the process of a shutdown.
error
public void error(String s)
- Issues a non-fatal error message and returns.
- Parameters:
- s - the error message
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
fatal
public void fatal(String s)
- Issues a fatal (non-recoverable) error message and then exits.
- Parameters:
- s - the error message
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
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
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
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