Class MongoClientFromUriFactoryBean

  • 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 MongoClientFromUriFactoryBean
    extends org.springframework.beans.factory.config.AbstractFactoryBean<com.mongodb.MongoClient>
    FactoryBean that besides creating a MongoClient from a Mongo URI, closes the client when it's destroyed.
    Author:
    avasquez
    See Also:
    MongoClientURI
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected String uri  
      • Fields inherited from class org.springframework.beans.factory.config.AbstractFactoryBean

        logger
      • Fields inherited from interface org.springframework.beans.factory.FactoryBean

        OBJECT_TYPE_ATTRIBUTE
    • Field Detail

    • Constructor Detail

      • MongoClientFromUriFactoryBean

        public MongoClientFromUriFactoryBean()
    • Method Detail

      • setUri

        public void setUri​(String uri)
      • getObjectType

        public Class<?> getObjectType()
        Specified by:
        getObjectType in interface org.springframework.beans.factory.FactoryBean<com.mongodb.MongoClient>
        Specified by:
        getObjectType in class org.springframework.beans.factory.config.AbstractFactoryBean<com.mongodb.MongoClient>
      • createInstance

        protected com.mongodb.MongoClient createInstance()
                                                  throws Exception
        Specified by:
        createInstance in class org.springframework.beans.factory.config.AbstractFactoryBean<com.mongodb.MongoClient>
        Throws:
        Exception
      • destroyInstance

        protected void destroyInstance​(com.mongodb.MongoClient mongoClient)
                                throws Exception
        Overrides:
        destroyInstance in class org.springframework.beans.factory.config.AbstractFactoryBean<com.mongodb.MongoClient>
        Throws:
        Exception