Package org.rapidcontext.app
Class ServerApplication
java.lang.Object
org.rapidcontext.app.ServerApplication
The stand-alone server application.
- Version:
- 1.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
findAvailablePort
(int port) Searches for an available server port to use.void
init()
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
start()
Starts the stand-alone server application.void
stop()
Shuts down a running server application.
-
Field Details
-
PORTS
public static final int[] PORTSThe array of default ports to attempt using. -
appDir
The base application directory. Defaults to the current directory. -
localDir
The local add-on directory. Defaults to the current directory. -
port
public int portThe 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
Starts the stand-alone server application.- Throws:
Exception
- if the server failed to start correctly
-
stop
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
-