Class BaseServer
java.lang.Object
org.globus.net.BaseServer
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
CallbackHandler, GassServer
This class provides the basics for writing various servers.
Note: Sockets created by this server have a 5 minute default timeout.
The timeout can be changed using the
setTimeout()
function.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ServerSocketprotected booleanprotected Authorizationprotected GSSCredentialprotected AbstractServerDeactivatorA handler for the deactivation framework.protected Integerprivate static org.apache.commons.logging.Logprivate booleanprivate Threadstatic final intSocket timeout in milliseconds.protected intprotected String -
Constructor Summary
ConstructorsConstructorDescriptionBaseServer(boolean secure, int port) BaseServer(int port) BaseServer(GSSCredential cred, int port) -
Method Summary
Modifier and TypeMethodDescriptiongetHost()Returns hostname of this server.Returns hostname of this serverintgetPort()Returns port of this serverintgetURL()Returns url of this serverprotected abstract voidhandleConnection(Socket socket) This method needs to be implemented by subclasses.protected voidThis method should be called by all subclasses.voidRegisters a default deactivation handler.voidrun()voidvoidsetGssMode(Integer mode) voidsetTimeout(int timeout) Sets timeout for the created sockets.voidshutdown()Stops the server but does not stop all the client threadsprotected voidstart()Starts the server.voidUnregisters a default deactivation handler.protected SocketwrapSocket(Socket socket)
-
Field Details
-
logger
private static org.apache.commons.logging.Log logger -
SO_TIMEOUT
public static final int SO_TIMEOUTSocket timeout in milliseconds.- See Also:
-
accept
protected boolean accept -
_server
-
secure
private boolean secure -
url
-
serverThread
-
credentials
-
authorization
-
gssMode
-
timeout
protected int timeout -
deactivator
A handler for the deactivation framework.
-
-
Constructor Details
-
BaseServer
- Throws:
IOException
-
BaseServer
- Throws:
IOException
-
BaseServer
- Throws:
IOException
-
BaseServer
- Throws:
IOException
-
-
Method Details
-
initialize
protected void initialize()This method should be called by all subclasses. -
start
protected void start()Starts the server. -
setTimeout
public void setTimeout(int timeout) Sets timeout for the created sockets. By default if not set, 5 minute timeout is used. -
getTimeout
public int getTimeout() -
shutdown
public void shutdown()Stops the server but does not stop all the client threads -
getCredentials
-
getProtocol
-
getURL
-
getPort
public int getPort()Returns port of this server- Returns:
- port number
-
getHostname
-
getHost
Returns hostname of this server. The format of the host conforms to RFC 2732, i.e. for a literal IPv6 address, this method will return the IPv6 address enclosed in square brackets ('[' and ']').- Returns:
- hostname
-
run
-
wrapSocket
- Throws:
GSSException
-
setGssMode
-
setAuthorization
-
handleConnection
This method needs to be implemented by subclasses. Optimmaly, it should be a non-blocking call starting a separate thread to handle the client. Note that to start an SSL handshake, you need to call socket.getInput(Output) stream(). -
registerDefaultDeactivator
public void registerDefaultDeactivator()Registers a default deactivation handler. It is used to shutdown the server without having a reference to the server. Call Deactivate.deactivateAll() to shutdown all registered servers. -
unregisterDefaultDeactivator
public void unregisterDefaultDeactivator()Unregisters a default deactivation handler.
-