Interface IServer

All Superinterfaces:
IAppLoader
All Known Implementing Classes:
JakartaEEServer, JettyRunConfiguration, RuntimeBuilderServer, ServerShell, StandardServer

public interface IServer extends IAppLoader
The interface to the Server instance, whether running in a JakartaEE Application Server or stand-alone using another web server and/or WebSocket implementation.
  • Field Details

    • MAX_VALID_APP_ID_LENGTH

      static final int MAX_VALID_APP_ID_LENGTH
      The maximum valid length of an App ID in characters = 64.
      See Also:
  • Method Details

    • validateAppID

      static IServer.InvalidAppID validateAppID(String id)
      Checks an App ID for validity.

      Valid App ID's are the characters A-Z, a-z, 0-9, and the characters ._, where the first character must be A-Z or a-z. App ID's are case sensitive. The maximum length of an App ID is 64 characters.

      Parameters:
      id - The application ID.
      Returns:
      The IServer.InvalidAppID instance of the error, or null for valid.
    • addDisposeListener

      boolean addDisposeListener(IServerDisposeListener listener)
      Adds a server dispose. Calling this method multiple times with the same listener will have no effect (but to return false).
      Parameters:
      listener - The listener to add.
      Returns:
      true if the listener was added, false otherwise.
      Throws:
      NullPointerException - If the listener is null.
    • removeDisposeListener

      boolean removeDisposeListener(IServerDisposeListener listener)
      Removes a server dispose listener.
      Parameters:
      listener - The listener to remove.
      Returns:
      true if listener is successfully removed, false otherwise.
    • startServer

      void startServer() throws Throwable
      Starts the server synchronously.
      Throws:
      Throwable - for start-up errors.
    • onStartServer

      void onStartServer() throws Throwable
      Processes server start-up asynchronously.
      Throws:
      Throwable - for start-up errors.
    • loadApplications

      void loadApplications() throws Throwable
      Called to load the application.
      Throws:
      Throwable - for start-up errors.
    • registerApplication

      AppDefinition registerApplication(String id, AppDefinition app) throws ServerApplicationSetupException
      Registers an application with an ID available in the server.
      Parameters:
      id - The ID of the application.
      app - The application.
      Returns:
      The previous overwritten application, or null for a new application.
      Throws:
      ServerApplicationSetupException - In case a plug-in fail to initialize.
    • dispose

      boolean dispose()
      Disposes of the server, e.g. at shut-down. This dispose call will wait until the server has shut-down successfully.
      Returns:
      true for success, false if already disposed of or stopping/disposing.
    • getState

      IServer.State getState()
      Gets the state of the server.
      Returns:
      The server state: STARTING, STARTED, STOPPING or STOPPED.
    • getServerProperties

      ServerProps getServerProperties()
      Gets the Server Properties.
    • getDefaultMailSender

      Gets the default mail sender.
      Returns:
      The default mail sender.
      Throws:
      NotFoundException - If the mail sender is not found.
      IOException - If the mail queue directory does not exist.
      NoSuchProviderException - If the "smtp" or "smtps" providers do not exist!
      AddressException - If the default sender failed to parse.
    • getMailSender

      Gets the default mail sender.
      Parameters:
      name - The mail sender name, null for default or the first one found if no default is configured.
      Returns:
      The default mail sender.
      Throws:
      NotFoundException - If the mail sender is not found.
      IOException - If the mail queue directory does not exist.
      NoSuchProviderException - If the "smtp" or "smtps" providers do not exist!
      AddressException - If the default sender failed to parse.
    • addModule

      boolean addModule(IServerModule<?> module)
      Adds a server module for processing. The module can have an end point constructor that is added during initialization.
      Parameters:
      module - The server module.
      Returns:
      true for success, false if already added.
    • removeModule

      boolean removeModule(IServerModule<?> module)
      Removes a server module for processing. This will unregister a potential end point constructor and dispose of the module.
      Parameters:
      module - The server module.
      Returns:
      true for success, false if already removed.
    • getEndPointsInstances

      IEndPoint[] getEndPointsInstances()
      Gets an array of all end points. Avoid this method as it causes unnecessary garbage collection, use getEndPointsCollection instead.
      Returns:
      an array of EndPoint instances.
    • onEndPointDisposed

      void onEndPointDisposed(IEndPoint endPoint)
      Called when an end point is disposed of.
    • addEndPointListener

      IEndPoint[] addEndPointListener(IEndPointListener listener)
      Adds a listener of end point create/dispose and retrieves the list of current end points. Calling this method several times with the same listener does not add a new one, it is similar to calling getEndPointInstances().
      Parameters:
      listener - The end point listener.
      Returns:
      An array of EndPoint instances.
    • removeEndPointListener

      boolean removeEndPointListener(IEndPointListener listener)
      Adds a listener of end point create/dispose and retrieves the list of current end points. Calling this method several times with the same listener does not add a new one, it is similar to calling getEndPointInstances().
      Parameters:
      listener - The end point listener.
      Returns:
      true for success, false if not added as listener.
    • getTXPCoordinator

      ITXPCoordinator getTXPCoordinator()
      The transaction processor coordinator.
    • getRootDirectory

      String getRootDirectory()
      Gets the web server root directory.
      Returns:
      The directory, or null if web server is not started.
    • registerRequestPrinter

      boolean registerRequestPrinter(String target, IWebServerRequestPrinter processor)
      Registers a new request printer.
      Parameters:
      target - The target URL, always starting with "/" and doesn't contain the query.
      processor - The print processor.
      Returns:
      true if added successfully, false if the print processor already exists or the server is not started yet.
    • unregisterRequestPrinter

      boolean unregisterRequestPrinter(String target, IWebServerRequestPrinter processor)
      Unregister a previously registered request printer.
      Parameters:
      target - The target URL, always starting with "/" and doesn't contain the query.
      processor - The print processor.
      Returns:
      true if removed successfully, false if the print processor does not exist or doesn't match, or the server is not yet started.