public class HServer
extends java.lang.Object
implements java.lang.Runnable
| Modifier and Type | Field and Description |
|---|---|
static int |
BUF_SIZE
The standard buffer size that will be allocated to read data from the socket.
|
static int |
DEFAULT_NUM_WORKERS
The default number of workers that the web server uses.
|
static int |
DEFAULT_PORT
The default port that the web server listens on.
|
| Constructor and Description |
|---|
HServer()
Initializes the new instance to listen on the default port which is
set by the
DEFAULT_PORT static member. |
HServer(int port)
Initializes the new instance to listen on the specified port.
|
HServer(nxm.sys.lib.Midas midas,
int port,
int prange)
Initializes the new instance to listen on the specified port.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addSource(HSource source)
Adds the specified HSource to the server under the given name.
|
void |
addSource(HSource source,
boolean override)
Adds the specified HSource to the server under the given name.
|
void |
addSource(java.lang.String name,
HSource source)
Adds the specified HSource to the server under the given name.
|
void |
addSource(java.lang.String name,
HSource source,
boolean override)
Adds the specified HSource to the server under the given name.
|
int |
close() |
java.lang.String |
getHomeDir() |
java.lang.String |
getHost()
Get the server's host name.
|
java.lang.String |
getHostAddr() |
static java.net.InetAddress |
getHostIA() |
java.lang.String |
getHostPort()
Get the server's host:port name.
|
nxm.sys.lib.Midas |
getMidas()
Get the servers Midas context.
|
int |
getPort()
Get the servers port number.
|
java.lang.Object |
getResult(java.lang.String name) |
nxm.sys.lib.Table |
getResults() |
HSource |
getSource(java.lang.String req)
Return the registered HSource object for the given request.
|
boolean |
isRunning() |
static HServer |
launch(nxm.sys.lib.Midas midas,
java.lang.String title,
int port,
int prange)
Create an HServer and start its thread
|
static HServer |
launch(java.lang.Object ref,
java.lang.String title,
int port,
int prange,
java.lang.String homepage,
java.lang.String auxlist)
Open a HTTP server.
|
static HServer |
launch(java.lang.Object ref,
java.lang.String title,
int port,
java.lang.String homepage,
java.lang.String auxlist)
Open a HTTP server.
|
static HServer |
launch(java.lang.String title,
int port)
Create an HServer and start its thread.
|
int |
open() |
int |
process() |
void |
removeSource(HSource source)
Removes the specified HSource.
|
void |
removeSource(java.lang.String name)
Removes the specified HSource by name.
|
void |
run()
Begins the web server running and accepting connections on the currently
configured port.
|
void |
setAppName(java.lang.String name) |
static void |
setDebug(boolean val) |
static void |
setDebug(int val)
Deprecated.
|
void |
setHomePage(java.lang.String page) |
static void |
setHttps(boolean isHttps) |
static void |
setHTTPS(java.lang.String mode) |
static void |
setOneWay(boolean oneWay) |
void |
setParent(nxm.sys.lib.Command parent)
Set the command that is running this server.
|
void |
setTitle(java.lang.String title) |
void |
stopThread()
Set the thread to stop executing after handling the current client.
|
public static final int DEFAULT_PORT
public static final int DEFAULT_NUM_WORKERS
public static final int BUF_SIZE
public HServer()
DEFAULT_PORT static member.public HServer(int port)
port - the port number, or 0 to use any free port.public HServer(nxm.sys.lib.Midas midas,
int port,
int prange)
midas - the midas context.port - the port number, or 0 to use any free port.prange - the range of port numbers above port to use if already allocated.public static HServer launch(nxm.sys.lib.Midas midas, java.lang.String title, int port, int prange)
midas - Midas contexttitle - Title of the data sources pageport - The port to be used by this HServerprange - The range of port numbers above port to use if already allocatedpublic static HServer launch(java.lang.String title, int port)
title - Title of the data sources pageport - The port to be used by this HServerlaunch(Midas, String, int, int)public static HServer launch(java.lang.Object ref, java.lang.String title, int port, int prange, java.lang.String homepage, java.lang.String auxlist)
ref - The reference (Midas context or Command).title - The title of the server (to be displayed to users).port - The port to be used by the server.prange - The range of port numbers above port to use if already allocatedhomepage - The home page to show (null = don't show).auxlist - The AUX list to show. One or more AUX names separated by a "|"
or "*" to serve up all AUXs in AUX.READ. (Use null or "NULL" to
disable serving up of AUXs.public static HServer launch(java.lang.Object ref, java.lang.String title, int port, java.lang.String homepage, java.lang.String auxlist)
ref - The reference (Midas context or Command).title - The title of the server (to be displayed to users).port - The port to be used by the server.homepage - The home page to show (null = don't show).auxlist - The AUX list to show. One or more AUX names separated by a "|"
or "*" to serve up all AUXs in AUX.READ. (Use null or "NULL" to
disable serving up of AUXs.public void setTitle(java.lang.String title)
public nxm.sys.lib.Midas getMidas()
public java.lang.Object getResult(java.lang.String name)
public nxm.sys.lib.Table getResults()
public int getPort()
public java.lang.String getHost()
public java.lang.String getHostAddr()
public java.lang.String getHostPort()
public void setAppName(java.lang.String name)
public void setParent(nxm.sys.lib.Command parent)
parent - The parent for this server. This is usually the primitive that started the service.public void addSource(java.lang.String name,
HSource source,
boolean override)
name or source are null.name - The name of the source.source - The source that handles the requests.override - If true, the source will be put on the front of the source list, if false the
source will be put on the end of the source list. When a request comes in the
sources are checked front-to-back to see if there is a match, if multiple
sources could match the request, the first one found will be used.public void addSource(java.lang.String name,
HSource source)
addSource(name,source,false).name - The name of the source.source - The source that handles the requests.public void addSource(HSource source)
addSource(name,source,false) where name is equal to source.getName().source - The source that handles the requests.public void addSource(HSource source, boolean override)
addSource(name,source,override) where name is equal to source.getName().source - The source that handles the requests.override - Override other requests?public void removeSource(java.lang.String name)
name - The name of the source.public void removeSource(HSource source)
source - The source to remove.public HSource getSource(java.lang.String req)
req - The requested pathpublic static void setHTTPS(java.lang.String mode)
public int open()
public int process()
public int close()
public void run()
run in interface java.lang.Runnablepublic void stopThread()
public boolean isRunning()
public void setHomePage(java.lang.String page)
public java.lang.String getHomeDir()
public static void setDebug(boolean val)
@Deprecated public static void setDebug(int val)
public static java.net.InetAddress getHostIA()
public static void setHttps(boolean isHttps)
isHttps - the isHttps to setpublic static void setOneWay(boolean oneWay)
oneWay - the oneWay to set