public class MongoPersistentEntityIndexCreator extends Object implements ApplicationListener<MappingContextEvent<MongoPersistentEntity<?>,MongoPersistentProperty>>
MongoPersistentEntity
instances contained in the given MongoMappingContext
for indexing metadata and ensures the indexes to be available.Constructor and Description |
---|
MongoPersistentEntityIndexCreator(MongoMappingContext mappingContext,
MongoDbFactory mongoDbFactory)
Creats a new
MongoPersistentEntityIndexCreator for the given MongoMappingContext and
MongoDbFactory . |
Modifier and Type | Method and Description |
---|---|
protected void |
checkForIndexes(MongoPersistentEntity<?> entity) |
protected void |
ensureIndex(String collection,
String name,
com.mongodb.DBObject indexDefinition,
boolean unique,
boolean dropDups,
boolean sparse,
boolean background,
int expireAfterSeconds)
Triggers the actual index creation.
|
boolean |
isIndexCreatorFor(MappingContext<?,?> context)
Returns whether the current index creator was registered for the given
MappingContext . |
void |
onApplicationEvent(MappingContextEvent<MongoPersistentEntity<?>,MongoPersistentProperty> event) |
public MongoPersistentEntityIndexCreator(MongoMappingContext mappingContext, MongoDbFactory mongoDbFactory)
MongoPersistentEntityIndexCreator
for the given MongoMappingContext
and
MongoDbFactory
.mappingContext
- must not be nullmongoDbFactory
- must not be nullpublic void onApplicationEvent(MappingContextEvent<MongoPersistentEntity<?>,MongoPersistentProperty> event)
onApplicationEvent
in interface ApplicationListener<MappingContextEvent<MongoPersistentEntity<?>,MongoPersistentProperty>>
protected void checkForIndexes(MongoPersistentEntity<?> entity)
public boolean isIndexCreatorFor(MappingContext<?,?> context)
MappingContext
.context
- protected void ensureIndex(String collection, String name, com.mongodb.DBObject indexDefinition, boolean unique, boolean dropDups, boolean sparse, boolean background, int expireAfterSeconds)
collection
- the collection to create the index inname
- the name of the index about to be createdindexDefinition
- the index definitionunique
- whether it shall be a unique indexdropDups
- whether to drop duplicatessparse
- sparse or notbackground
- whether the index will be created in the backgroundexpireAfterSeconds
- the time to live for documents in the collectionCopyright © 2011-2013-2013 Pivotal. All Rights Reserved.