Class SpringDataMongoBundle<C extends io.dropwizard.core.Configuration>

java.lang.Object
org.sdase.commons.server.spring.data.mongo.SpringDataMongoBundle<C>
All Implemented Interfaces:
io.dropwizard.core.ConfiguredBundle<C>

public class SpringDataMongoBundle<C extends io.dropwizard.core.Configuration> extends Object implements io.dropwizard.core.ConfiguredBundle<C>
  • Constructor Details

  • Method Details

    • builder

      public static SpringDataMongoBundle.InitialBuilder builder()
    • initialize

      public void initialize(io.dropwizard.core.setup.Bootstrap<?> bootstrap)
      Specified by:
      initialize in interface io.dropwizard.core.ConfiguredBundle<C extends io.dropwizard.core.Configuration>
    • run

      public void run(C configuration, io.dropwizard.core.setup.Environment environment)
      Specified by:
      run in interface io.dropwizard.core.ConfiguredBundle<C extends io.dropwizard.core.Configuration>
    • mongoClient

      public com.mongodb.client.MongoClient mongoClient()
      Returns:
      the MongoClient that is connected to the MongoDB cluster. The client may be used for raw MongoDB operations. Usually the Morphia getMongoOperations() should be preferred for database operations.
      Throws:
      IllegalStateException - if the method is called before the mongoClient is initialized in run(Configuration, Environment)
    • getMongoOperations

      public org.springframework.data.mongodb.core.MongoOperations getMongoOperations()
      Returns:
      the MongoOperations that can be used to interact with your MongoDB instance
    • getGridFsOperations

      public org.springframework.data.mongodb.gridfs.GridFsOperations getGridFsOperations()
      Provides the GridFsOperations that can be used to store and retrieve binary files inside MongoDBs filesystem GridFS.
      Returns:
      the GridFsTemplate implementing GridFsOperations.
    • createRepository

      public <T extends org.springframework.data.repository.Repository<S, ID>, S, ID extends Serializable> T createRepository(Class<T> repositoryType)
      Type Parameters:
      T - the repository class or interface
      S - the type of the entity
      ID - the type of primary key of the entity
      Parameters:
      repositoryType - the type of the repository that is created
      Returns:
      a new Spring Data Mongo repository