Package org.nuxeo.runtime.mongodb
Class MongoDBComponent
java.lang.Object
org.nuxeo.runtime.model.DefaultComponent
org.nuxeo.runtime.mongodb.MongoDBComponent
- All Implemented Interfaces:
Adaptable
,Component
,Extensible
,MongoDBConnectionService
,TimestampedService
Component used to get a database connection to MongoDB. Don't expose
MongoClient
directly, because it's this
component which is responsible for creating and closing it.- Since:
- 9.1
-
Field Summary
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
The component notification order forComponent.start(ComponentContext)
.com.mongodb.client.MongoClient
Gets the MongoDB client for the given id.Gets the MongoDB configuration for the given id.com.mongodb.client.MongoDatabase
getDatabase
(String id) Gets the MongoDB database name for the given id.Iterable<com.mongodb.client.MongoDatabase>
void
start
(ComponentContext context) Start the component.void
stop
(ComponentContext context) Stop the component.Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, deactivate, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerContribution, registerExtension, setLastModified, setModifiedNow, setName, unregister, unregisterContribution, unregisterExtension
-
Field Details
-
COMPONENT_NAME
- Since:
- 10.3
- See Also:
-
-
Constructor Details
-
MongoDBComponent
public MongoDBComponent()
-
-
Method Details
-
start
Description copied from interface:Component
Start the component. This method is called after all the components were resolved and activated- Specified by:
start
in interfaceComponent
- Overrides:
start
in classDefaultComponent
-
stop
Description copied from interface:Component
Stop the component.- Specified by:
stop
in interfaceComponent
- Overrides:
stop
in classDefaultComponent
- Throws:
InterruptedException
-
getApplicationStartedOrder
public int getApplicationStartedOrder()Description copied from interface:Component
The component notification order forComponent.start(ComponentContext)
.Components are notified in increasing order. Order 1000 is the default order for components that don't care. Order 100 is the repository initialization.
- Specified by:
getApplicationStartedOrder
in interfaceComponent
- Returns:
- the order, 1000 by default
-
getClient
Description copied from interface:MongoDBConnectionService
Gets the MongoDB client for the given id.- Specified by:
getClient
in interfaceMongoDBConnectionService
- Parameters:
id
- the connection id- Returns:
- the client configured by
MongoDBConnectionConfig
for the input id, or the default one if it doesn't exist
-
getConfig
Description copied from interface:MongoDBConnectionService
Gets the MongoDB configuration for the given id.- Specified by:
getConfig
in interfaceMongoDBConnectionService
-
getDatabaseName
Description copied from interface:MongoDBConnectionService
Gets the MongoDB database name for the given id.- Specified by:
getDatabaseName
in interfaceMongoDBConnectionService
- Parameters:
id
- the connection id- Returns:
- the database name configured by
MongoDBConnectionConfig
for the input id, or the default one if it doesn't exist
-
getDatabase
- Specified by:
getDatabase
in interfaceMongoDBConnectionService
- Parameters:
id
- the connection id- Returns:
- the database configured by
MongoDBConnectionConfig
for the input id, or the default one if it doesn't exist
-
getDatabases
- Specified by:
getDatabases
in interfaceMongoDBConnectionService
- Returns:
- all configured databases
-