Skip to content

Instantly share code, notes, and snippets.

@chkal
Created September 30, 2013 05:48
Show Gist options
  • Save chkal/6759782 to your computer and use it in GitHub Desktop.
Save chkal/6759782 to your computer and use it in GitHub Desktop.
Example for a custom activation strategy that combines two existing strategies
public class UserClientIpActivationStrategy implements ActivationStrategy {
private final ActivationStrategy userStrategy = new UsernameActivationStrategy();
private final ActivationStrategy ipStrategy = new ClientIpActivationStrategy();
@Override
public String getId() {
return "user-ip";
}
@Override
public String getName() {
return "Username & Client IP";
}
@Override
public boolean isActive(FeatureState featureState, FeatureUser user) {
return userStrategy.isActive(featureState, user) &&
ipStrategy.isActive(featureState, user);
}
@Override
public Parameter[] getParameters() {
return new Parameter[] {
userStrategy.getParameters()[0],
ipStrategy.getParameters()[0]
};
}
}
@AshishShetkar
Copy link

AshishShetkar commented Nov 21, 2016

how do we do this in property file, i mean how about this
FEATURE_02=true

FEATURE_02.strategy=user-role,username --- this is not working
FEATURE_02.param.roles=roleb
FEATURE_02.param.users=chkal,john

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment