0

All the ActivationStrategy of togglez uses input from HttpRequest or from other context.

However, If I am using togglez for stand alone java application is there any way to pass parameters into isActive method.

Features.DOWNLOAD_ACCESS.isActive(availableBalance);

instead of

Features.DOWNLOAD_ACCESS.isActive();

Below is ReleaseDateActivationStrategy uses current date. But if some one change system date than it will fail. https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ReleaseDateActivationStrategy.java

Nitul
  • 917
  • 9
  • 31

1 Answers1

1

ActivationStrategies in Togglz have an IsActive method take two parameters, the FeatureState and a FeatureUser. These are supplied by a StateRepository implementation and a UserProvider implementation respectively. If you want to have that level of customization in stand alone applications you should provide and implement a custom FeatureManagerProvider which provides the feature manager as described in the Togglz advanced config. You create a custom StateRepository and UserProvider as well.

Rob Obdeijn
  • 253
  • 2
  • 9
  • It is not about user id only. See edited question. If you want to restrict download feature for user based on available data balance. And this data balance is not available from UserProvider. – Nitul Oct 17 '17 at 13:19
  • In that case I would recommend implementing a custom StateRepository to get that information into the FeatureState. You cannot simply add additional parameters to the isActive method as it is an implementation of the Feature interface. – Rob Obdeijn Oct 17 '17 at 13:32