BaseServer (Java Globus API)

org.globus.net
Class BaseServer

java.lang.Object
  |
  +--org.globus.net.BaseServer
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
CallbackHandler, CallbackHandler, GassServer, GateKeeperServer, JobManagerServer

public abstract class BaseServer
extends java.lang.Object
implements java.lang.Runnable

This class provides the basics for writing various servers.


Field Summary
protected  java.net.ServerSocket _server
           
protected  boolean accept
           
protected  Authorization authorization
           
protected  GlobusProxy credentials
           
protected  org.globus.net.AbstractServerDeactivator deactivator
          A handler for the deactivation framework.
static int SO_TIMEOUT
          Socket timeout in milliseconds.
 
Constructor Summary
BaseServer()
           
BaseServer(boolean secure, int port)
           
BaseServer(GlobusProxy proxy, int port)
           
BaseServer(int port)
           
 
Method Summary
 GlobusProxy getCredentials()
           
 java.lang.String getHostname()
          Returns hostname of this server
 int getPort()
          Returns port of this server
 java.lang.String getProtocol()
           
 java.lang.String getURL()
          Returns url of this server
protected abstract  void handleConnection(java.net.Socket socket)
          This method needs to be implemented by subclasses.
protected  void initialize()
          This method should be called by all subclasses.
 void registerDefaultDeactivator()
          Registers a default deactivation handler.
 void run()
           
 void setAuthorization(Authorization auth)
           
 void shutdown()
          Stops the server but does not stop all the client threads
protected  void start()
          Starts the server.
 void unregisterDefaultDeactivator()
          Unregisters a default deactivation handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SO_TIMEOUT

public static final int SO_TIMEOUT
Socket timeout in milliseconds.

See Also:
Constant Field Values

accept

protected boolean accept

_server

protected java.net.ServerSocket _server

credentials

protected GlobusProxy credentials

authorization

protected Authorization authorization

deactivator

protected org.globus.net.AbstractServerDeactivator deactivator
A handler for the deactivation framework.

Constructor Detail

BaseServer

public BaseServer()
           throws java.io.IOException,
                  GlobusProxyException

BaseServer

public BaseServer(int port)
           throws java.io.IOException,
                  GlobusProxyException

BaseServer

public BaseServer(GlobusProxy proxy,
                  int port)
           throws java.io.IOException,
                  GlobusProxyException

BaseServer

public BaseServer(boolean secure,
                  int port)
           throws java.io.IOException,
                  GlobusProxyException
Method Detail

initialize

protected void initialize()
This method should be called by all subclasses.


start

protected void start()
Starts the server.


shutdown

public void shutdown()
Stops the server but does not stop all the client threads


getCredentials

public GlobusProxy getCredentials()

getProtocol

public java.lang.String getProtocol()

getURL

public java.lang.String getURL()
Returns url of this server

Returns:
url of this server

getPort

public int getPort()
Returns port of this server

Returns:
port number

getHostname

public java.lang.String getHostname()
Returns hostname of this server

Returns:
hostname

run

public void run()
Specified by:
run in interface java.lang.Runnable

setAuthorization

public void setAuthorization(Authorization auth)

handleConnection

protected abstract void handleConnection(java.net.Socket socket)
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.