Hello
I would like a feature to be activated when a spring profile 'dev' is provided.
I am in a Spring Boot environment.
I defined my features through an enum class :
public enum MyFeature implements Feature {
@Label("Feature for development environment")
@DefaultActivationStrategy(
id = SpringProfileActivationStrategy.ID,
parameters = {
@ActivationParameter(name = SpringProfileActivationStrategy.PARAM_PROFILES, value = "dev")
}
)
DEV,
...
public boolean isActive() {
return FeatureContext.getFeatureManager().isActive(this);
}
}
In application.properties, i only configured the togglz endpoint for actuator, and rename it to 'features':
management.endpoints.web.exposure.include=togglz
management.endpoints.web.path-mapping.togglz=features
So i launched my application with the spring profile 'dev'.
But when i call MyFeatures.DEV.isActive(), then it returns false always.
And when i call the actuator endpoint /features the feature is also false.
I put breakpoints inside SpringProfileActivationStrategy, and it is never called.
When i debug the call stack, it goes inside
org.togglz.core.manager.DefaultFeatureManager#isActive and then in EnumFeatureMetaData.getDefaultFeatureState().
There it gets a copy of the FeatureState. The initialization of the feature state is made by passing parameter enabledByDefault which is false in my case (see MyFeature declaration)
Then in org.togglz.core.manager.DefaultFeatureManager#isActive, state.isEnabled() always returns false, and it never calls the activation strategy.
So i wonder how to activate a feature based on the spring profile. And i wonder also why the state should be enabled to call the activation strategy resolution. Because, in this is case, none strategy could be called.
Regards
Thomas