org.eclipse.actf.validation.javapp.server
Class AbstractSingletonServer

java.lang.Object
  extended by org.eclipse.actf.validation.javapp.server.AbstractSingletonServer
Direct Known Subclasses:
ResourceServer

public abstract class AbstractSingletonServer
extends Object

basic services for a singleton server in ACTF

Author:
Mike Squillace

Field Summary
static Charset CHARSET
           
static CharsetDecoder CHARSET_DECODER
           
static CharsetEncoder CHARSET_ENCODER
           
static String REQUEST_CLOSE
           
static String RESOURCE_SERVER_HOST_DEFAULT
           
static String RESOURCE_SERVER_HOST_KEY
           
static String RESOURCE_SERVER_PORT_DEFAULT
           
static String RESOURCE_SERVER_PORT_KEY
           
static int transaction_id
           
 
Constructor Summary
AbstractSingletonServer()
           
 
Method Summary
 String getHostName()
           
 int getPort()
          returns the port on which this server is accepting connection requests
 boolean isShutdown()
          returns whether or not this server has been shutdown.
 boolean isSuspended()
           
protected  String receiveMessage(SocketChannel client)
           
static byte[] requestAsBytes(SocketChannel client)
           
static void sendResource(SocketChannel client, byte[] bytes, int size)
           
 void setHostName(String name)
          set the host name for this server.
 void setPort(int port)
          set the port for this server to receive conection requests
 void setSuspended(boolean suspended)
           
 void shutdown()
          shut down the server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transaction_id

public static int transaction_id

RESOURCE_SERVER_HOST_KEY

public static final String RESOURCE_SERVER_HOST_KEY
See Also:
Constant Field Values

RESOURCE_SERVER_PORT_KEY

public static final String RESOURCE_SERVER_PORT_KEY
See Also:
Constant Field Values

RESOURCE_SERVER_HOST_DEFAULT

public static final String RESOURCE_SERVER_HOST_DEFAULT
See Also:
Constant Field Values

RESOURCE_SERVER_PORT_DEFAULT

public static final String RESOURCE_SERVER_PORT_DEFAULT
See Also:
Constant Field Values

CHARSET

public static final Charset CHARSET

CHARSET_ENCODER

public static final CharsetEncoder CHARSET_ENCODER

CHARSET_DECODER

public static final CharsetDecoder CHARSET_DECODER

REQUEST_CLOSE

public static final String REQUEST_CLOSE
See Also:
Constant Field Values
Constructor Detail

AbstractSingletonServer

public AbstractSingletonServer()
Method Detail

getHostName

public String getHostName()
Returns:
host name for this server

setHostName

public void setHostName(String name)
set the host name for this server. The default host name is 'localhost'.

Parameters:
name - - the host name

getPort

public int getPort()
returns the port on which this server is accepting connection requests

Returns:
the port for this server

setPort

public void setPort(int port)
set the port for this server to receive conection requests

Parameters:
port - - port number

isSuspended

public boolean isSuspended()

setSuspended

public void setSuspended(boolean suspended)

shutdown

public void shutdown()
shut down the server


isShutdown

public boolean isShutdown()
returns whether or not this server has been shutdown. This method returns true as soon as shutdown() is invoked.

Returns:
true if server has been shut down

receiveMessage

protected String receiveMessage(SocketChannel client)
                         throws IOException
Throws:
IOException

sendResource

public static void sendResource(SocketChannel client,
                                byte[] bytes,
                                int size)
                         throws IOException
Throws:
IOException

requestAsBytes

public static byte[] requestAsBytes(SocketChannel client)
                             throws IOException
Throws:
IOException