Package org.togglz.mongodb
Class MongoStateRepository
- java.lang.Object
-
- org.togglz.mongodb.MongoStateRepository
-
- All Implemented Interfaces:
StateRepository
public class MongoStateRepository extends Object implements StateRepository
A state repository which stores the feature state in a MongoDB database.
The class provides a builder which can be used to configure the repository:
StateRepository repository = MongoStateRepository .newBuilder(mongoClient, "mydb") .collection("togglz") .writeConcern(WriteConcern.REPLICA_ACKNOWLEDGED) .build();- Author:
- Christian Kaltepoth
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMongoStateRepository.BuilderBuilder for aMongoStateRepository.
-
Field Summary
Fields Modifier and Type Field Description protected Stringcollectionprotected Stringdbnameprotected static StringFIELD_ENABLEDprotected static StringFIELD_FEATUREprotected static StringFIELD_PARAMSprotected static StringFIELD_STRATEGYprotected com.mongodb.client.MongoClientmongoClientprotected com.mongodb.WriteConcernwriteConcern
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FeatureStategetFeatureState(Feature feature)static MongoStateRepository.BuildernewBuilder(com.mongodb.client.MongoClient client, String dbname)Creates a new builder for creating aMongoStateRepository.protected org.bson.DocumentqueryFor(Feature feature)voidsetFeatureState(FeatureState featureState)protected com.mongodb.client.MongoCollectiontogglzCollection()
-
-
-
Field Detail
-
FIELD_FEATURE
protected static final String FIELD_FEATURE
- See Also:
- Constant Field Values
-
FIELD_ENABLED
protected static final String FIELD_ENABLED
- See Also:
- Constant Field Values
-
FIELD_STRATEGY
protected static final String FIELD_STRATEGY
- See Also:
- Constant Field Values
-
FIELD_PARAMS
protected static final String FIELD_PARAMS
- See Also:
- Constant Field Values
-
mongoClient
protected final com.mongodb.client.MongoClient mongoClient
-
dbname
protected final String dbname
-
collection
protected final String collection
-
writeConcern
protected final com.mongodb.WriteConcern writeConcern
-
-
Method Detail
-
getFeatureState
public FeatureState getFeatureState(Feature feature)
- Specified by:
getFeatureStatein interfaceStateRepository
-
setFeatureState
public void setFeatureState(FeatureState featureState)
- Specified by:
setFeatureStatein interfaceStateRepository
-
queryFor
protected org.bson.Document queryFor(Feature feature)
-
togglzCollection
protected com.mongodb.client.MongoCollection togglzCollection()
-
newBuilder
public static MongoStateRepository.Builder newBuilder(com.mongodb.client.MongoClient client, String dbname)
Creates a new builder for creating aMongoStateRepository.- Parameters:
client- the client instance to use for connecting to MongoDBdbname- the database name used for storing features state.
-
-