Class Context

java.lang.Object
com.renomad.minum.state.Context

public final class Context extends Object
Holds important system-wide data and methods, such as the logger, constants, and the FullSystem instance.

The common situations:

  • Building a Minum Db database
  • Getting system constants like the database directory
  • Getting the system ExecutorService for starting threads or an ActionQueue
  • Getting a FullSystem object, which has
    • the WebFramework, which registers endpoints
    • the TheBrig, which handles bad actors on the internet
  • Constructor Details

  • Method Details

    • getLogger

      public ILogger getLogger()
    • getExecutorService

      public ExecutorService getExecutorService()
    • getConstants

      public Constants getConstants()
    • setFullSystem

      public void setFullSystem(FullSystem fullSystem)
    • getFullSystem

      public FullSystem getFullSystem()
    • getActionQueueState

      public ActionQueueState getActionQueueState()
    • getDb

      public <T extends DbData<?>> Db<T> getDb(String name, T instance)
      This is a helper method to instantiate a Db class, avoiding the need for a user to provide the root database directory and the context.

      Since this is a generic method, a bit of care is required when calling. Try to use a pattern like the following pseudocode:

       Db<Photograph> photoDb = context.getDb("photos", new Photograph());
      
      Parameters:
      name - the name of this data. Note that this will be used as the directory for the data, so use characters your operating system would allow.
      instance - an instance of the DbData data. This is used in the Db code to deserialize the data when reading.
    • getDb2

      public <T extends DbData<?>> DbEngine2<T> getDb2(String name, T instance)
      This is a helper method to instantiate a DbEngine2 class, using the engine2 database implementation. It is similar to getDb(String, DbData) in all other respects.

      By switching your old database calls to use this, when it runs it will convert the file schema.

      Please backup your database before conversion

    • isDbPathRegistered

      public boolean isDbPathRegistered(Path path)
      Return true if the input path exists in the set
    • addToDbPaths

      public void addToDbPaths(Path path)
      Add a path to the set of paths we are tracking as registered for a database. This is used to prevent pointing two databases at the same directory, which would lead to data corruption.
    • removeFromPaths

      public void removeFromPaths(Path path)
      Remove an item from the set of registered database paths, run when a database shuts down.
    • clearDatabasePaths

      public void clearDatabasePaths()
      Remove all registered paths from the set, mostly used when testing