Package ca.spatial.reportwriter
Class PatchServer
java.lang.Object
java.lang.Thread
ca.spatial.reportwriter.PatchServer
- All Implemented Interfaces:
Runnable
This class provides a simple web server (http server) for Patchworks.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsConstructorDescriptionPatchServer(int port, PrintStream logStream, boolean daemon)
Create a web server and listen on the specified port. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addServer(OutputServer server)
Add a new pluging to the web server.void
Add a user/password to the web server and enable authentication.getDocBase(ReportWriter rw)
static boolean[]
getParametersBoolean(String[] args, boolean[] def)
Convenience method to convert an array of String to an array of boolean.static double[]
getParametersDouble(String[] args, double[] def)
Convenience method to convert an array of String to an array of boolean.static int[]
getParametersInt(String[] args, int[] def)
Convenience method to convert an array of String to an array of int.static String[]
getParametersString(String[] args, String[] def)
Convenience method to copy an array of String.int
getPort()
Return the port number that the server is listening on.static String
Return the MIME type for this file type (if known).void
run()
The method that is run in the listening ann dispatch thread of the web server.void
toString()
This method will return a string version of the URL prefix containing the protocol, host and port.Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, yield
-
Field Details
-
defaultType
The default MIME type- See Also:
- Constant Field Values
-
-
Constructor Details
-
PatchServer
Create a web server and listen on the specified port.- Parameters:
port
- The port to listen on (usually 8081).logStream
- A stream to write log messages.daemon
- A flag to indicate if the server thread should behave as a daemon, and not prevent the application from exiting.
-
-
Method Details
-
toString
This method will return a string version of the URL prefix containing the protocol, host and port. -
getPort
public int getPort()Return the port number that the server is listening on. -
setAlertOwner
-
addUser
Add a user/password to the web server and enable authentication. This method may be called multiple times to add several username and password combinations. Once authentication has been activated by this method all accesses to the builtin web server will require authentication. -
addServer
Add a new pluging to the web server. See the documentation forOutputServer
and its sub-classes for further details. -
run
public void run()The method that is run in the listening ann dispatch thread of the web server. -
getDocBase
-
getType
Return the MIME type for this file type (if known). If unknown return the default type. -
getParametersInt
Convenience method to convert an array of String to an array of int. Conversion is performed byDouble.valueOf(java.lang.String)
. If the arguments string array is null, then the default values are returned instead.- Parameters:
args
- A String array containing a list of values.def
- A list of values to be returned in case the the args parameter is null.
-
getParametersDouble
Convenience method to convert an array of String to an array of boolean. Conversion is performed byDouble.valueOf(java.lang.String)
. If the arguments string array is null, then the default values are returned instead.- Parameters:
args
- A String array containing a list of values.def
- A list of values to be returned in case the the args parameter is null.
-
getParametersBoolean
Convenience method to convert an array of String to an array of boolean. Conversion is performed byBoolean.valueOf(boolean)
. If the arguments string array is null, then the default values are returned instead.- Parameters:
args
- A String array containing a list of values.def
- A list of values to be returned in case the the args parameter is null.
-
getParametersString
Convenience method to copy an array of String. If the arguments string array is null, then the default values are returned instead.- Parameters:
args
- A String array containing a list of values.def
- A list of values to be returned in case the the args parameter is null.
-