restart.server
Class RestServer

java.lang.Object
  extended by restart.server.RestServer

public class RestServer
extends java.lang.Object

Author:
Thibault Ducray

Constructor Summary
RestServer(int port)
          Create a REST Server listening on a given port, with default RestServer policies
RestServer(int port, RestServerPolicy policy)
          Create a REST Server listening on a given port with the given policies.
 
Method Summary
 void addService(Service service)
          Add (expose) a service to the server.
 ServerThread[] getConnections()
          Get connections
 java.lang.String getHostName()
          Get the current hostname.
 Service getService(java.lang.String name)
          Get a service by its name.
 java.lang.String[] getServiceNames()
          Get all service names.
 void removeService(Service service)
          Remove the given service from the server.
 void start()
          Start the server : expose the services and listen for connections
 boolean stopServer()
          Should stop the server ?
 void stopServer(boolean stopAllThreads)
          Gently stop the server if the given param is false, or force stop the server if the given param is true.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RestServer

public RestServer(int port)
Create a REST Server listening on a given port, with default RestServer policies

Parameters:
port - the port the server will listen to (default : 80)

RestServer

public RestServer(int port,
                  RestServerPolicy policy)
Create a REST Server listening on a given port with the given policies.

Parameters:
port - the port the server will listen to (default : 80)
soTimeout - the so_timeout to be affected to accepted sockets
Method Detail

addService

public void addService(Service service)
Add (expose) a service to the server. A service does not have to be started. Once it is added to the already started server, it is exposed.

Parameters:
service - the service to be added

removeService

public void removeService(Service service)
Remove the given service from the server. This causes the service to be inaccessible. Current invocations to the service are not stoped by this action.

Parameters:
service - the service to be removed

getService

public Service getService(java.lang.String name)
Get a service by its name.

Parameters:
name -
Returns:

getServiceNames

public java.lang.String[] getServiceNames()
Get all service names.

Returns:
the services'names of this server.

start

public void start()
           throws java.io.IOException
Start the server : expose the services and listen for connections

Throws:
java.io.IOException

getConnections

public ServerThread[] getConnections()
Get connections


stopServer

public boolean stopServer()
Should stop the server ?

Returns:
true if the server has to shutdown

stopServer

public void stopServer(boolean stopAllThreads)
Gently stop the server if the given param is false, or force stop the server if the given param is true.

Parameters:
stopAllThreads - true to force kill all running threads and active connections

getHostName

public java.lang.String getHostName()
Get the current hostname.