Class ServerApplication

java.lang.Object
org.rapidcontext.app.ServerApplication

public class ServerApplication extends Object
The stand-alone server application.
Version:
1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The base application directory.
    The local add-on directory.
    int
    The port number to use.
    static final int[]
    The array of default ports to attempt using.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new stand-alone application instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    Searches for an available server port to use.
    void
    Initializes the stand-alone server application.
    static boolean
    isPortAvailable(int port)
    Checks if the specified server port can be used.
    boolean
    Checks if the server is currently running.
    void
    Starts the stand-alone server application.
    void
    Shuts down a running server application.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PORTS

      public static final int[] PORTS
      The array of default ports to attempt using.
    • appDir

      public File appDir
      The base application directory. Defaults to the current directory.
    • localDir

      public File localDir
      The local add-on directory. Defaults to the current directory.
    • port

      public int port
      The port number to use.
  • Constructor Details

    • ServerApplication

      public ServerApplication()
      Creates a new stand-alone application instance.
  • Method Details

    • isPortAvailable

      public static boolean isPortAvailable(int port)
      Checks if the specified server port can be used.
      Parameters:
      port - the suggested port number
      Returns:
      true if the port number can be used, or false otherwise
    • findAvailablePort

      public static int findAvailablePort(int port)
      Searches for an available server port to use.
      Parameters:
      port - the initial port number to test
      Returns:
      the suggested port number, or zero (0) if none of the suggestions worked
    • isRunning

      public boolean isRunning()
      Checks if the server is currently running.
      Returns:
      true if the server is running, or false otherwise
    • init

      public void init()
      Initializes the stand-alone server application.
    • start

      public void start() throws Exception
      Starts the stand-alone server application.
      Throws:
      Exception - if the server failed to start correctly
    • stop

      public void stop() throws Exception
      Shuts down a running server application. The start and stop methods can be called multiple times.
      Throws:
      Exception - if the server failed to stop correctly