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
public class MongoDBComponent extends DefaultComponent implements MongoDBConnectionService
Component used to get a database connection to MongoDB. Don't exposeMongoClient
directly, because it's this component which is responsible for creating and closing it.- Since:
- 9.1
-
-
Field Summary
Fields Modifier and Type Field Description static String
COMPONENT_NAME
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description MongoDBComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getApplicationStartedOrder()
The component notification order forComponent.applicationStarted(org.nuxeo.runtime.model.ComponentContext)
.com.mongodb.client.MongoClient
getClient(String id)
Gets the MongoDB client for the given id.MongoDBConnectionConfig
getConfig(String id)
Gets the MongoDB configuration for the given id.com.mongodb.client.MongoDatabase
getDatabase(String id)
String
getDatabaseName(String id)
Gets the MongoDB database name for the given id.Iterable<com.mongodb.client.MongoDatabase>
getDatabases()
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted
-
-
-
-
Field Detail
-
COMPONENT_NAME
public static final String COMPONENT_NAME
- Since:
- 10.3
- See Also:
- Constant Field Values
-
-
Method Detail
-
start
public void start(ComponentContext context)
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
public void stop(ComponentContext context) throws InterruptedException
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.applicationStarted(org.nuxeo.runtime.model.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
public com.mongodb.client.MongoClient getClient(String id)
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
public MongoDBConnectionConfig getConfig(String id)
Description copied from interface:MongoDBConnectionService
Gets the MongoDB configuration for the given id.- Specified by:
getConfig
in interfaceMongoDBConnectionService
-
getDatabaseName
public String getDatabaseName(String id)
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
public com.mongodb.client.MongoDatabase getDatabase(String id)
- 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
public Iterable<com.mongodb.client.MongoDatabase> getDatabases()
- Specified by:
getDatabases
in interfaceMongoDBConnectionService
- Returns:
- all configured databases
-
-