org.hackystat.sensorbase.server
Class Server

java.lang.Object
  extended by org.restlet.Uniform
      extended by org.restlet.Restlet
          extended by org.restlet.Application
              extended by org.hackystat.sensorbase.server.Server

public class Server
extends org.restlet.Application

Sets up the HTTP Server process and dispatching to the associated resources.

Author:
Philip Johnson

Constructor Summary
Server()
           
 
Method Summary
 org.restlet.Restlet createRoot()
          Dispatch to the Projects, SensorData, SensorDataTypes, or Users Resource depending on the URL.
 java.lang.String getHostName()
          Returns the host name associated with this server.
 java.util.logging.Logger getLogger()
          Returns the logger for the SensorBase.
 ServerProperties getServerProperties()
          Returns the ServerProperties instance associated with this server.
static java.lang.String getVersion()
          Returns the version associated with this Package, if available from the jar file manifest.
static void main(java.lang.String[] args)
          Starts up the SensorBase web service using the properties specified in sensor.properties.
static Server newInstance()
          Creates a new instance of a SensorBase HTTP server, listening on the supplied port.
static Server newInstance(ServerProperties serverProperties)
          Creates a new instance of a SensorBase HTTP server, listening on the supplied port.
static Server newTestInstance()
          Creates a new instance of a SensorBase HTTP server suitable for unit testing.
 
Methods inherited from class org.restlet.Application
getAuthor, getConnectorService, getConverterService, getCurrent, getDecoderService, getDescription, getMetadataService, getName, getOwner, getRangeService, getRoot, getStatusService, getTaskService, getTunnelService, handle, setAuthor, setConnectorService, setConverterService, setCurrent, setDecoderService, setDescription, setMetadataService, setName, setOwner, setRangeService, setRoot, setStatusService, setTaskService, setTunnelService, start, stop
 
Methods inherited from class org.restlet.Restlet
getApplication, getContext, init, isStarted, isStopped, setContext
 
Methods inherited from class org.restlet.Uniform
delete, delete, get, get, handle, head, head, options, options, post, post, put, put
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Server

public Server()
Method Detail

newInstance

public static Server newInstance()
                          throws java.lang.Exception
Creates a new instance of a SensorBase HTTP server, listening on the supplied port. SensorBase properties are initialized from the User's sensorbase.properties file.

Returns:
The Server instance created.
Throws:
java.lang.Exception - If problems occur starting up this server.

newTestInstance

public static Server newTestInstance()
                              throws java.lang.Exception
Creates a new instance of a SensorBase HTTP server suitable for unit testing. SensorBase properties are initialized from the User's sensorbase.properties file, then set to their "testing" versions.

Returns:
The Server instance created.
Throws:
java.lang.Exception - If problems occur starting up this server.

newInstance

public static Server newInstance(ServerProperties serverProperties)
                          throws java.lang.Exception
Creates a new instance of a SensorBase HTTP server, listening on the supplied port.

Parameters:
serverProperties - The ServerProperties used to initialize this server.
Returns:
The Server instance created.
Throws:
java.lang.Exception - If problems occur starting up this server.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Starts up the SensorBase web service using the properties specified in sensor.properties. Control-c to exit.

Parameters:
args - Ignored.
Throws:
java.lang.Exception - if problems occur.

createRoot

public org.restlet.Restlet createRoot()
Dispatch to the Projects, SensorData, SensorDataTypes, or Users Resource depending on the URL. We will authenticate all requests except for registration (users?email={email}).

Overrides:
createRoot in class org.restlet.Application
Returns:
The router Restlet.

getVersion

public static java.lang.String getVersion()
Returns the version associated with this Package, if available from the jar file manifest. If not being run from a jar file, then returns "Development".

Returns:
The version.

getHostName

public java.lang.String getHostName()
Returns the host name associated with this server. Example: "http://localhost:9876/sensorbase/"

Returns:
The host name.

getServerProperties

public ServerProperties getServerProperties()
Returns the ServerProperties instance associated with this server.

Returns:
The server properties.

getLogger

public java.util.logging.Logger getLogger()
Returns the logger for the SensorBase.

Overrides:
getLogger in class org.restlet.Restlet
Returns:
The logger.