Class BaseServer

java.lang.Object
ch.autumo.beetroot.server.BaseServer
Direct Known Subclasses:
BeetRootServer

public abstract class BaseServer extends Object
Base server.
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
    • serverSocketFactory

      protected ServerSocketFactory serverSocketFactory
      Default or SSL.
    • startFileServer

      protected boolean startFileServer
    • startWebServer

      protected boolean startWebServer
    • name

      protected String name
    • ansiServerName

      protected static String ansiServerName
    • ansiErrServerName

      protected static String ansiErrServerName
  • Constructor Details

    • BaseServer

      public BaseServer(String[] params)
      Create a base server.
      Parameters:
      params - start or stop
  • Method Details

    • initializeLogging

      protected void initializeLogging(String logCfgFile)
      Initialize logging. Can be overwritten.
      Parameters:
      logCfgFile - logging config file
    • getHelpText

      public String getHelpText()
      Get argument help text.
      Returns:
      argument help text
    • getServerName

      public String getServerName()
      Get server name.
      Returns:
      server name
    • getRootPath

      protected static String getRootPath()
      Get root path of this server.
      Returns:
      root path
    • startServer

      protected void startServer()
      Start server and web server if configured.
    • stopServer

      protected void stopServer()
      Stop server and web server if configured.
    • delete

      protected boolean delete(String uniqueFileId, String domain) throws Exception
      Internal delete method if no file-storage has been configured. -> Must be overwritten if this internal module is used.
      Parameters:
      uniqueFileId - unique file ID
      domain - domain or null
      Returns:
      true if at least one (of all versions) has been found and deleted
      Throws:
      Exception - exception
    • findFile

      protected Download findFile(String uniqueFileId, String domain) throws Exception
      Internal find-file method if no file-storage has been configured. -> Must be overwritten if this internal module is used.
      Parameters:
      uniqueFileId - unique file ID
      domain - domain or null
      Returns:
      Download for the server to queue
      Throws:
      Exception - exception
    • store

      protected String store(File file, String name, String user, String domain) throws Exception
      Internal file-store method if no file-storage has been configured. -> Must be overwritten if this internal module is used.
      Parameters:
      file - file
      name - file name
      user - user or null
      domain - domain or null (default)
      Returns:
      unique file ID
      Throws:
      Exception - exception
    • getShutDownHook

      protected Thread getShutDownHook()
      OS shutdown hook. Don't overwrite this, unless you know exactly what you are doing. This implementation calls all methods necessary to properly stop the server.
      Returns:
      thread for runtime shutdown hook.
    • sendServerCommand

      protected void sendServerCommand(ServerCommand command)
      You can send local server commands to be send to the running server for possible custom operations. You might want to force them over sockets, see ServerCommand.forceSockets().
      Parameters:
      command - server command
    • getValidCustomOperations

      protected String[] getValidCustomOperations()
      Return a list of valid custom operations
      Returns:
      custom operations possible
    • customOperation

      protected void customOperation(String operation, String[] params)
      Custom operation has been defined when starting the server, we possibly want to do something else. Overwrite if needed. Of you overwrite, you have to implement customOperation(String, String[])!
      Parameters:
      operation - the operation = params[0], 1st argument of all program arguments
      params - all program arguments
    • processServerCommand

      public ClientAnswer processServerCommand(ServerCommand command)
      This method is called when a server command has been received. At this point security checks have been made. Usually mustn't be overwritten, because configured module/component dispatchers do the work beside internal commands.
      Parameters:
      command - received server command
      Returns:
      client answer
    • beforeStart

      protected abstract boolean beforeStart()
      Overwrite to do something before starting the server. Handle exceptions by your own!
      Returns:
      true id server should be started, otherwise false; e.g. a pre-condition is not met
    • afterStart

      protected abstract void afterStart()
      Overwrite to do something after starting the server. Handle exceptions by your own!
    • beforeStop

      protected abstract void beforeStop()
      Overwrite to do something before stopping the server. Handle exceptions by your own!
    • afterStop

      protected abstract void afterStop()
      Overwrite to do something after stopping the server. Handle exceptions by your own!
    • printHealthStatus

      protected boolean printHealthStatus(boolean hasNoIssues)
      Prints out the health status of this server. Overwrite if necessary.
      Parameters:
      hasNoIssues - any pre-existing issues for the overall state; false if there are issues!
      Returns:
      overall state, true if good