0

I need to retrieve the togglz feature name for which the status is changed. Is there any way to do that? I'm stuck with this for the past 1 day. Any help is highly appreciated. Please find my sample code below

    public enum MyFeatures implements Feature {

        @EnabledByDefault
        @Label("First Feature")
        FEATURE_ONE,

        @Label("Second Feature")
        FEATURE_TWO;
    }

    @Bean
    public FeatureProvider featureProvider() {
        return new EnumBasedFeatureProvider(MyFeatures.class);
    }

Whenever there is a change in the togglz status from togglz-console I need a way to get the name of the feature which got changed.

zypro
  • 1,158
  • 3
  • 12
  • 33

1 Answers1

1

I thinks tooglz doesn't have a feature to do it like you want. But it can be achieved using CompositeStateRepository and implementing a new StateRepository to listen the changes. PS: You should set the setter selction on CompositeStateRepository to 'ALL'. I'm leaving here a dummy listener implementation:

public class ListenerStateRepository implements StateRepository {


    @Override
    public FeatureState getFeatureState(Feature feature) {
        return null;
    }

    @Override
    public void setFeatureState(FeatureState featureState) {
        log.info("{} was changed"); //you should handle the state change here
    }
}
Rodolfo Oliveira
  • 235
  • 3
  • 11