Class PatchServer

java.lang.Object
java.lang.Thread
ca.spatial.reportwriter.PatchServer
All Implemented Interfaces:
Runnable

public class PatchServer extends Thread
This class provides a simple web server (http server) for Patchworks.
  • Field Details

  • Constructor Details

    • PatchServer

      public PatchServer(int port, PrintStream logStream, boolean daemon)
      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

      public String toString()
      This method will return a string version of the URL prefix containing the protocol, host and port.
      Overrides:
      toString in class Thread
    • getPort

      public int getPort()
      Return the port number that the server is listening on.
    • setAlertOwner

      public void setAlertOwner(Component c)
    • addUser

      public void addUser(String username, String password)
      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

      public void addServer(OutputServer server)
      Add a new pluging to the web server. See the documentation for OutputServer 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.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • getDocBase

      public String getDocBase(ReportWriter rw)
    • getType

      public static String getType(String request)
      Return the MIME type for this file type (if known). If unknown return the default type.
    • getParametersInt

      public static int[] getParametersInt(String[] args, int[] def)
      Convenience method to convert an array of String to an array of int. Conversion is performed by Double.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

      public static double[] getParametersDouble(String[] args, double[] def)
      Convenience method to convert an array of String to an array of boolean. Conversion is performed by Double.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

      public static boolean[] getParametersBoolean(String[] args, boolean[] def)
      Convenience method to convert an array of String to an array of boolean. Conversion is performed by Boolean.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

      public static String[] getParametersString(String[] args, String[] def)
      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.