Package org.togglz.core.logging
Class LoggingStateRepository
- java.lang.Object
-
- org.togglz.core.logging.LoggingStateRepository
-
- All Implemented Interfaces:
StateRepository
public class LoggingStateRepository extends Object implements StateRepository
Simple implementation ofStateRepositorywhich adds logging capabilities to an existing repository. You should consider using this class if you want to log all feature toggled events.- Author:
- Martin Günther
-
-
Constructor Summary
Constructors Modifier Constructor Description LoggingStateRepository(StateRepository delegate)Creates a logging facade for the suppliedStateRepository.LoggingStateRepository(StateRepository delegate, String customLogMessage)Creates a logging facade for the suppliedStateRepositoryusing a custom log message.protectedLoggingStateRepository(StateRepository delegate, String customLogMessage, org.slf4j.Logger log)protectedLoggingStateRepository(StateRepository delegate, org.slf4j.Logger log)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FeatureStategetFeatureState(Feature feature)Get the persisted state of a feature from the repository.voidsetFeatureState(FeatureState featureState)Persist the supplied feature state.
-
-
-
Constructor Detail
-
LoggingStateRepository
public LoggingStateRepository(StateRepository delegate)
Creates a logging facade for the suppliedStateRepository.- Parameters:
delegate- The repository to delegate invocations to
-
LoggingStateRepository
public LoggingStateRepository(StateRepository delegate, String customLogMessage)
Creates a logging facade for the suppliedStateRepositoryusing a custom log message. In your custom log message, mark the position of the feature name as {1} and the position for the new feature state which will be replaced by "enabled" or "disabled" as {2}.- Parameters:
delegate- The repository to delegate invocations tocustomLogMessage- Your custom log message. It may contain a placeholder {1} for the feature name and a placeholder {2} for the new feature state which will be replaced by "enabled" or "disabled"
-
LoggingStateRepository
protected LoggingStateRepository(StateRepository delegate, org.slf4j.Logger log)
-
LoggingStateRepository
protected LoggingStateRepository(StateRepository delegate, String customLogMessage, org.slf4j.Logger log)
-
-
Method Detail
-
getFeatureState
public FeatureState getFeatureState(Feature feature)
Description copied from interface:StateRepositoryGet the persisted state of a feature from the repository. If the repository doesn't contain any information regarding this feature it must returnnull.- Specified by:
getFeatureStatein interfaceStateRepository- Parameters:
feature- The feature to read the state for- Returns:
- The persisted feature state or
null
-
setFeatureState
public void setFeatureState(FeatureState featureState)
Description copied from interface:StateRepositoryPersist the supplied feature state. The repository implementation must ensure that subsequent calls toStateRepository.getFeatureState(Feature)return the same state as persisted using this method.- Specified by:
setFeatureStatein interfaceStateRepository- Parameters:
featureState- The feature state to persist
-
-