public class MongoDBFactory extends Object implements org.springframework.beans.factory.FactoryBean<com.mongodb.DB>, org.springframework.beans.factory.DisposableBean
DB instances.
Client code should retrieve the DB instance and keep hold of it.
The DB instance will be closed by this factory when the Spring context shuts down.
The use of the Spring FactoryBean means that we can use an instance of this to inject DB instances
into the DAO layers directly.| Constructor and Description |
|---|
MongoDBFactory(com.mongodb.MongoClient mongoClient,
String database)
Create an instance of the factory.
|
| Modifier and Type | Method and Description |
|---|---|
void |
destroy() |
com.mongodb.DB |
getObject()
Get the database that this instance is produces.
|
Class<?> |
getObjectType() |
boolean |
isSingleton() |
public MongoDBFactory(com.mongodb.MongoClient mongoClient,
String database)
mongoClient - the mongo clientdatabase - the database to connect to (never null)IllegalArgumentException - if the arguments are null when not allowed or contain invalid informationpublic void destroy()
destroy in interface org.springframework.beans.factory.DisposableBeanpublic com.mongodb.DB getObject()
getObject in interface org.springframework.beans.factory.FactoryBean<com.mongodb.DB>public Class<?> getObjectType()
getObjectType in interface org.springframework.beans.factory.FactoryBean<com.mongodb.DB>public boolean isSingleton()
isSingleton in interface org.springframework.beans.factory.FactoryBean<com.mongodb.DB>Copyright © 2005–2018 Alfresco Software. All rights reserved.