Created
September 30, 2013 05:48
-
-
Save chkal/6759782 to your computer and use it in GitHub Desktop.
Example for a custom activation strategy that combines two existing strategies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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