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 exposeMongoClientdirectly, 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 StringCOMPONENT_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 intgetApplicationStartedOrder()The component notification order forComponent.applicationStarted(org.nuxeo.runtime.model.ComponentContext).com.mongodb.client.MongoClientgetClient(String id)Gets the MongoDB client for the given id.MongoDBConnectionConfiggetConfig(String id)Gets the MongoDB configuration for the given id.com.mongodb.client.MongoDatabasegetDatabase(String id)StringgetDatabaseName(String id)Gets the MongoDB database name for the given id.Iterable<com.mongodb.client.MongoDatabase>getDatabases()voidstart(ComponentContext context)Start the component.voidstop(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:ComponentStart the component. This method is called after all the components were resolved and activated- Specified by:
startin interfaceComponent- Overrides:
startin classDefaultComponent
-
stop
public void stop(ComponentContext context) throws InterruptedException
Description copied from interface:ComponentStop the component.- Specified by:
stopin interfaceComponent- Overrides:
stopin classDefaultComponent- Throws:
InterruptedException
-
getApplicationStartedOrder
public int getApplicationStartedOrder()
Description copied from interface:ComponentThe 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:
getApplicationStartedOrderin interfaceComponent- Returns:
- the order, 1000 by default
-
getClient
public com.mongodb.client.MongoClient getClient(String id)
Description copied from interface:MongoDBConnectionServiceGets the MongoDB client for the given id.- Specified by:
getClientin interfaceMongoDBConnectionService- Parameters:
id- the connection id- Returns:
- the client configured by
MongoDBConnectionConfigfor the input id, or the default one if it doesn't exist
-
getConfig
public MongoDBConnectionConfig getConfig(String id)
Description copied from interface:MongoDBConnectionServiceGets the MongoDB configuration for the given id.- Specified by:
getConfigin interfaceMongoDBConnectionService
-
getDatabaseName
public String getDatabaseName(String id)
Description copied from interface:MongoDBConnectionServiceGets the MongoDB database name for the given id.- Specified by:
getDatabaseNamein interfaceMongoDBConnectionService- Parameters:
id- the connection id- Returns:
- the database name configured by
MongoDBConnectionConfigfor the input id, or the default one if it doesn't exist
-
getDatabase
public com.mongodb.client.MongoDatabase getDatabase(String id)
- Specified by:
getDatabasein interfaceMongoDBConnectionService- Parameters:
id- the connection id- Returns:
- the database configured by
MongoDBConnectionConfigfor the input id, or the default one if it doesn't exist
-
getDatabases
public Iterable<com.mongodb.client.MongoDatabase> getDatabases()
- Specified by:
getDatabasesin interfaceMongoDBConnectionService- Returns:
- all configured databases
-
-