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
  • Field Details

    • EMPTY

      public static final Context EMPTY
  • Constructor Details

  • Method Details

    • setLogger

      public void setLogger(ILogger logger)
    • 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.