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
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected com.mongodb.MongoClient
Class<?>
void
setConnectionString
(String connectionString) void
setOptions
(com.mongodb.MongoClientOptions options) void
setPassword
(String password) void
setUsername
(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:
getObjectType
in interfaceorg.springframework.beans.factory.FactoryBean<com.mongodb.MongoClient>
- Specified by:
getObjectType
in classorg.springframework.beans.factory.config.AbstractFactoryBean<com.mongodb.MongoClient>
-
createInstance
- Specified by:
createInstance
in classorg.springframework.beans.factory.config.AbstractFactoryBean<com.mongodb.MongoClient>
- Throws:
Exception
-
setConnectionString
-
setOptions
public void setOptions(com.mongodb.MongoClientOptions options) -
setUsername
-
setPassword
-