java.lang.Object
com.renomad.minum.state.Context
Holds important system-wide data and methods, such as the
logger, constants, and the
FullSystem instance.
The common situations:
- Building a Minum
Dbdatabase - Getting system constants like the database directory
- Getting the system
ExecutorServicefor starting threads or anActionQueue - Getting a
FullSystemobject, which has- the
WebFramework, which registers endpoints - the
TheBrig, which handles bad actors on the internet
- the
-
Constructor Summary
ConstructorsConstructorDescriptionContext(ExecutorService executorService, Constants constants, ILogger logger) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToDbPaths(Path path) Add a path to the set of paths we are tracking as registered for a database.voidRemove all registered paths from the set, mostly used when testingThis is a helper method to instantiate aDbclass, avoiding the need for a user to provide the root database directory and the context.This is a helper method to instantiate aDbEngine2class, using the engine2 database implementation.booleanisDbPathRegistered(Path path) Return true if the input path exists in the setvoidremoveFromPaths(Path path) Remove an item from the set of registered database paths, run when a database shuts down.voidsetFullSystem(FullSystem fullSystem)
-
Constructor Details
-
Context
-
-
Method Details
-
getLogger
-
getExecutorService
-
getConstants
-
setFullSystem
-
getFullSystem
-
getActionQueueState
-
getDb
This is a helper method to instantiate aDbclass, 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 theDbDatadata. This is used in the Db code to deserialize the data when reading.
-
getDb2
This is a helper method to instantiate aDbEngine2class, using the engine2 database implementation. It is similar togetDb(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
Return true if the input path exists in the set -
addToDbPaths
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
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
-