Package org.craftercms.commons.mongo
Class MongoClientFactory
java.lang.Object
org.springframework.beans.factory.config.AbstractFactoryBean<com.mongodb.MongoClient>
org.craftercms.commons.mongo.MongoClientFactory
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanClassLoaderAware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.FactoryBean<com.mongodb.MongoClient>,org.springframework.beans.factory.InitializingBean
public class MongoClientFactory
extends org.springframework.beans.factory.config.AbstractFactoryBean<com.mongodb.MongoClient>
Creates a Mongo Client based on a connection String
Connection String format host:PORT,[host1:port1],[hostN,portN] the port portion is optional default one 27017 will be use.
If connection String is null or empty or whitespace only, this factory will use as if connection String value is "127.0.0.1:27017"
Will throw IllegalArgumentException if port number is not valid
-
Field Summary
FieldsFields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected com.mongodb.MongoClientClass<?> voidsetConnectionString(String connectionString) voidsetOptions(com.mongodb.MongoClientOptions options) voidsetPassword(String password) voidsetUsername(String username) Methods inherited from class org.springframework.beans.factory.config.AbstractFactoryBean
afterPropertiesSet, destroy, destroyInstance, getBeanFactory, getBeanTypeConverter, getEarlySingletonInterfaces, getObject, isSingleton, setBeanClassLoader, setBeanFactory, setSingleton
-
Field Details
-
DEFAULT_MONGO_HOST
- See Also:
-
DEFAULT_MONGO_PORT
public static final int DEFAULT_MONGO_PORT- See Also:
-
-
Constructor Details
-
MongoClientFactory
public MongoClientFactory()
-
-
Method Details
-
getObjectType
- Specified by:
getObjectTypein interfaceorg.springframework.beans.factory.FactoryBean<com.mongodb.MongoClient>- Specified by:
getObjectTypein classorg.springframework.beans.factory.config.AbstractFactoryBean<com.mongodb.MongoClient>
-
createInstance
- Specified by:
createInstancein classorg.springframework.beans.factory.config.AbstractFactoryBean<com.mongodb.MongoClient>- Throws:
Exception
-
setConnectionString
-
setOptions
public void setOptions(com.mongodb.MongoClientOptions options) -
setUsername
-
setPassword
-