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>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
SpringDataMongoBundle.Builder<T extends io.dropwizard.core.Configuration>
static interface
SpringDataMongoBundle.CaCertificateConfigProviderBuilder<C extends io.dropwizard.core.Configuration>
static interface
SpringDataMongoBundle.CustomConverterBuilder<C extends io.dropwizard.core.Configuration>
static interface
SpringDataMongoBundle.FinalBuilder<C extends io.dropwizard.core.Configuration>
static interface
static interface
SpringDataMongoBundle.MorphiaCompatibilityBuilder<C extends io.dropwizard.core.Configuration>
static interface
SpringDataMongoBundle.ScanPackageBuilder<C extends io.dropwizard.core.Configuration>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
<T extends org.springframework.data.repository.Repository<S,
ID>, S, ID extends Serializable>
TcreateRepository
(Class<T> repositoryType) org.springframework.data.mongodb.gridfs.GridFsOperations
Provides theGridFsOperations
that can be used to store and retrieve binary files inside MongoDBs filesystem GridFS.org.springframework.data.mongodb.core.MongoOperations
void
initialize
(io.dropwizard.core.setup.Bootstrap<?> bootstrap) com.mongodb.client.MongoClient
void
-
Constructor Details
-
SpringDataMongoBundle
-
-
Method Details
-
builder
-
initialize
public void initialize(io.dropwizard.core.setup.Bootstrap<?> bootstrap) - Specified by:
initialize
in interfaceio.dropwizard.core.ConfiguredBundle<C extends io.dropwizard.core.Configuration>
-
run
- Specified by:
run
in interfaceio.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 inrun(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 theGridFsOperations
that can be used to store and retrieve binary files inside MongoDBs filesystem GridFS.- Returns:
- the
GridFsTemplate
implementingGridFsOperations
.
-
createRepository
public <T extends org.springframework.data.repository.Repository<S,ID>, T createRepositoryS, ID extends Serializable> (Class<T> repositoryType) - Type Parameters:
T
- the repository class or interfaceS
- the type of the entityID
- 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
-