Using PropertyFeatureProvider

110 views
Skip to first unread message

Rohit

unread,
Jul 12, 2017, 12:23:53 PM7/12/17
to togglz-dev
Hi i am new to togglz, i am trying to implement TogglzBootstrap and for the feature manger i am suppling a properties file to PropertyFeatureProvider. Now i have an issue with this,

i have my properties file like this.

# The feature 'FEATURE_ONE' is disabled
FEATURE_ONE=false

# The feature 'FEATURE_TWO' is enabled for the users 'chkal' and 'joe'
FEATURE_TWO=true
FEATURE_TWO.strategy = username
FEATURE_TWO.param.users = chkal, john

and this is how my Config looks

@Override
public FeatureManager createFeatureManager() {

Properties properties = new Properties();
try {
properties.load(getClass().getClassLoader().getResourceAsStream("/features.properties"));
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Exception has occured", e);
}
FeatureManager featureManager = new FeatureManagerBuilder()
.featureProvider(new PropertyFeatureProvider(properties)).stateRepository(getStateRepository())
.userProvider(getUserProvider()).build();

return featureManager;
}

when i go into the console this what i see.(see attached Picture)

Any ideas?


Sample.jpg

Christian Kaltepoth

unread,
Jul 13, 2017, 1:48:42 AM7/13/17
to toggl...@googlegroups.com
You are using the wrong properties format. Please have a look at the javadocs of PropertyFeatureProvider for details:


Basically PropertyFeatureProvider uses a properties file to define which features your application supports, but not their state. Managing state is the responsibility of the StateRepository. And if you use the FileBasedStateRepository for feature state storage, you will have a separate properties file for the state.

Christian

Rohit

unread,
Jul 13, 2017, 10:36:01 AM7/13/17
to togglz-dev
Christian,

When i configure the same property file for Both PropertyFeatureProvider and FileBasedStateRepository its causing issues.

I have provided the following features.properties to both the above classes

FEATURE_ONE=A useful feature;true;Group 1,Group 3
FEATURE_TWO
=Some other feature;false;Group 2


When i enable/disable a feature on the console it turns out like this

FEATURE_ONE.param.time=00\:00\:00
FEATURE_TWO
=true
FEATURE_ONE
=true
FEATURE_ONE
.param.date=2017-07-14
FEATURE_ONE
.strategy=release-date

It completely get rids of the groups. I'm quite confused.

Christian Kaltepoth

unread,
Jul 13, 2017, 11:34:27 AM7/13/17
to toggl...@googlegroups.com
Please don't use the same property file for those two classes. They are totally different and use a totally different storage format. Therefore they will overwrite the data of the other one.

Rohit

unread,
Jul 13, 2017, 11:38:25 AM7/13/17
to togglz-dev
How do i keep these files in sync?

Lets say i've provided a file for PropertyFeatureProvider and have a feature enabled.

And i've provided another file for FileBasedStateRepository and have a feature enabled here as well, now when i toggle off the feature from the console does it reflect the same in both the places?

Christian Kaltepoth

unread,
Jul 13, 2017, 11:47:15 AM7/13/17
to toggl...@googlegroups.com
PropertyFeatureProvider is only about "metadata" of features. Enabling a feature there only sets the "enabled by default" flag.

FileBasedStateRepository is about feature state. So if you toggle a feature at runtime, the state gets updated here.

You have to understand that 99% of the users don't use PropertyFeatureProvider but EnumFeatureProvider which allows to specify this metadata via a feature enum and annotations.

Rohit

unread,
Jul 13, 2017, 12:04:03 PM7/13/17
to togglz-dev
Yeah i understand that but i am trying to integrate togglz in a distributed environment for an enterprise.

One more question can we use an SQL database for FeatureProvider? Is there a schema or a utility class for the same? Or do i have to implement the FeatureProvider?

Christian Kaltepoth

unread,
Jul 14, 2017, 4:25:11 AM7/14/17
to toggl...@googlegroups.com
Currently there is not implementation of FeatureProvider for JDBC datasources. But contributions are welcome. ;-)

Rohit

unread,
Jul 14, 2017, 10:31:10 AM7/14/17
to togglz-dev
OK cool!

One more thing i have one of my property like this:

FEATURE_THREE.param.date=09\:25\:00
FEATURE_THREE=false
FEATURE_THREE.strategy=release-date
FEATURE_THREE.param.date=2017-07-14


But the feature didnt activate at that particular given time. Can i know why?

Christian Kaltepoth

unread,
Jul 15, 2017, 2:15:32 AM7/15/17
to toggl...@googlegroups.com
There are two issues:
  • You are using "FEATURE_THREE.param.date" twice. I guess that's a typo.
  • You need to enable the feature by setting "FEATURE_THREE=true"
Christian
Reply all
Reply to author
Forward
0 new messages