Class Database
java.lang.Object
com.github.darksoulq.abyssallib.common.database.nosql.mongodb.Database
Manages the connection lifecycle for a MongoDB NoSQL database.
This class handles the initialization of the MongoClient, provides access
to specific MongoDatabase instances, and maintains an asynchronous
thread pool for non-blocking operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconnect()Establishes a connection to the MongoDB server and initializes the database instance.voidCloses the MongoDB client connection and shuts down the asynchronous thread pool.executor()Creates a new QueryExecutor to perform operations on collections.Gets the thread pool used for asynchronous operations.com.mongodb.client.MongoDatabaseRetrieves the active MongoDatabase instance.
-
Constructor Details
-
Database
-
-
Method Details
-
connect
public void connect()Establishes a connection to the MongoDB server and initializes the database instance. -
disconnect
public void disconnect()Closes the MongoDB client connection and shuts down the asynchronous thread pool. -
getDatabase
public com.mongodb.client.MongoDatabase getDatabase()Retrieves the active MongoDatabase instance.- Returns:
- The
MongoDatabaseinstance.
-
getAsyncPool
Gets the thread pool used for asynchronous operations.- Returns:
- The
ExecutorServiceinstance.
-
executor
Creates a new QueryExecutor to perform operations on collections.- Returns:
- A new
QueryExecutor.
-