public class WebServerUtilities
extends java.lang.Object
WebServerManager
Red (ltrnc) |
Red (ltrnc) |
Modifier and Type | Field and Description |
---|---|
(package private) org.eclipse.jetty.server.nio.SelectChannelConnector |
_selectChannelConnector
The connector binding a port to the server.
|
(package private) static int |
DEFAULT_MAX_IDLE_TIME
Use 30 seconds (30000 milliseconds) as the default time the server
will wait before returning a timeout response page.
|
(package private) static int |
DEFAULT_PORT_NUMBER
Use 8078 as the default port number that the server listens to for
incoming requests.
|
Constructor and Description |
---|
WebServerUtilities()
Construct a new instance of this class with the default port number
and maximum idle time.
|
WebServerUtilities(int portNumber)
Construct a new instance of this class with the specified port number.
|
WebServerUtilities(int portNumber,
int maxIdleTime)
Construct a new instance of this class with the specified port number
and maximum idle time.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_createResourceHandlers(WebApplicationInfo appInfo)
Create or re-use resource handler(s) to serve files such as images,
audio, etc.
|
protected void |
_createServletHandler(WebApplicationInfo appInfo)
Create a ContextHandler to store all of the servlets defined in the
given application (e.g. a Ptolemy model).
|
boolean |
getDynamicPortSelection()
Return true if dynamic port selection is permitted; false otherwise
|
int |
getMaxIdleTime()
Return the maximum amount of time the server will wait before returning
a timeout response page.
|
int |
getPortNumber()
Return the port number that the server listens to for requests.
|
boolean |
isHostingModel(java.lang.String fullModelName)
Return true if this web server is hosting the given model; false
otherwise.
|
boolean |
isRunning()
Return true if the web server is running; false otherwise.
|
void |
register(WebApplicationInfo appInfo)
Register the following application on this server.
|
void |
setDynamicPortSelection(boolean dynamicPortSelection)
Set a flag indicating if dynamic port selection is permitted.
|
void |
setMaxIdleTime(int maxIdleTime)
Set the maximum amount of time, in milliseconds, that the server will
wait before returning a timeout response page.
|
void |
unregister(WebApplicationInfo appInfo)
Unregister the given application from this server.
|
static final int DEFAULT_PORT_NUMBER
static final int DEFAULT_MAX_IDLE_TIME
org.eclipse.jetty.server.nio.SelectChannelConnector _selectChannelConnector
public WebServerUtilities()
public WebServerUtilities(int portNumber)
portNumber
- The port number the web server receives requests onpublic WebServerUtilities(int portNumber, int maxIdleTime)
portNumber
- The port number the web server receives requests onmaxIdleTime
- The maximum amount of time the web server will wait
before sending a timeout response pagepublic boolean getDynamicPortSelection()
setDynamicPortSelection(boolean)
public int getMaxIdleTime()
setMaxIdleTime(int)
public int getPortNumber()
public boolean isHostingModel(java.lang.String fullModelName)
fullModelName
- The full name of the model to search forpublic boolean isRunning()
public void register(WebApplicationInfo appInfo) throws java.lang.Exception
appInfo
- The application to add to this serverjava.lang.Exception
- If the new application conflicts with existing
applications, for example, by requesting the same URL mapping.public void setDynamicPortSelection(boolean dynamicPortSelection)
dynamicPortSelection
- True if dynamic port selection is permitted;
false otherwisegetDynamicPortSelection()
public void setMaxIdleTime(int maxIdleTime)
maxIdleTime
- The maximum amount of time, in milliseconds, that the
server will wait before returning a timeout response pagegetMaxIdleTime()
public void unregister(WebApplicationInfo appInfo) throws java.lang.Exception
appInfo
- The application to remove from the server.java.lang.Exception
- if the application is not registered with this
server or if the server cannot be stopped when the last application
is unregisteredprotected void _createServletHandler(WebApplicationInfo appInfo) throws java.lang.Exception
appInfo
- Information about the web application.java.lang.Exception
- If the servlet cannot be started on the serverprotected void _createResourceHandlers(WebApplicationInfo appInfo) throws java.lang.Exception
appInfo
- An object containing information needed to register the
new applicationjava.lang.Exception
- If a FileParameter is found that is not a valid URI or
references a resource that cannot be found, or if the handler cannot
be started on the server