code
stringlengths
23
201k
docstring
stringlengths
17
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
72
path
stringlengths
11
317
url
stringlengths
57
377
license
stringclasses
7 values
public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(PropertyBasedStateRepositoryBenchmark.class.getSimpleName()) .forks(2) .build(); new Runner(opt).run(); }
Basic benchmark of the performance of the PropertyBasedStateRepository @author Ryan Gardner @date 5/26/16
main
java
togglz/togglz
benchmarks/src/main/java/org/togglz/benchmark/PropertyBasedStateRepositoryBenchmark.java
https://github.com/togglz/togglz/blob/master/benchmarks/src/main/java/org/togglz/benchmark/PropertyBasedStateRepositoryBenchmark.java
Apache-2.0
@Setup(Level.Trial) public void setupFeatureManager() { FeatureManager featureManager = new FeatureManagerBuilder() .featureEnums(ScriptEngineActivationStrategyFeatures.class) .stateRepository(new InMemoryStateRepository()) .userProvider(new NoOpUserProvider()...
Benchmark the performance of the ScriptEngine-based activation strategy in terms of speed and memory footprint @author Ryan Gardner @date 5/13/16
setupFeatureManager
java
togglz/togglz
benchmarks/src/main/java/org/togglz/benchmark/ScriptEngineActivationStrategyBenchmark.java
https://github.com/togglz/togglz/blob/master/benchmarks/src/main/java/org/togglz/benchmark/ScriptEngineActivationStrategyBenchmark.java
Apache-2.0
@Benchmark public int scriptEngineThatAlwaysReturnsTrue() { return (manager.isActive(ScriptEngineActivationStrategyFeatures.ALWAYS_TRUE_SCRIPT_ENGINE_ACTIVATION_STRATEGY)) ? 0 : 1; }
Benchmark the performance of the ScriptEngine-based activation strategy in terms of speed and memory footprint @author Ryan Gardner @date 5/13/16
scriptEngineThatAlwaysReturnsTrue
java
togglz/togglz
benchmarks/src/main/java/org/togglz/benchmark/ScriptEngineActivationStrategyBenchmark.java
https://github.com/togglz/togglz/blob/master/benchmarks/src/main/java/org/togglz/benchmark/ScriptEngineActivationStrategyBenchmark.java
Apache-2.0
@Benchmark public int scriptEngineDoingDynamicThings() { return (manager.isActive(ScriptEngineActivationStrategyFeatures.DYNAMIC_SCRIPT_ENGINE_STRATEGY)) ? 0 : 1; }
Benchmark the performance of the ScriptEngine-based activation strategy in terms of speed and memory footprint @author Ryan Gardner @date 5/13/16
scriptEngineDoingDynamicThings
java
togglz/togglz
benchmarks/src/main/java/org/togglz/benchmark/ScriptEngineActivationStrategyBenchmark.java
https://github.com/togglz/togglz/blob/master/benchmarks/src/main/java/org/togglz/benchmark/ScriptEngineActivationStrategyBenchmark.java
Apache-2.0
@Benchmark public int disabledFeatureWithNoScriptEngineInvolved() { return (manager.isActive(ScriptEngineActivationStrategyFeatures.DISABLED_FEATURE)) ? 0 : 1; }
Benchmark the performance of the ScriptEngine-based activation strategy in terms of speed and memory footprint @author Ryan Gardner @date 5/13/16
disabledFeatureWithNoScriptEngineInvolved
java
togglz/togglz
benchmarks/src/main/java/org/togglz/benchmark/ScriptEngineActivationStrategyBenchmark.java
https://github.com/togglz/togglz/blob/master/benchmarks/src/main/java/org/togglz/benchmark/ScriptEngineActivationStrategyBenchmark.java
Apache-2.0
public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(ScriptEngineActivationStrategyBenchmark.class.getSimpleName()) .addProfiler(GCProfiler.class) .build(); new Runner(opt).run(); }
Benchmark the performance of the ScriptEngine-based activation strategy in terms of speed and memory footprint @author Ryan Gardner @date 5/13/16
main
java
togglz/togglz
benchmarks/src/main/java/org/togglz/benchmark/ScriptEngineActivationStrategyBenchmark.java
https://github.com/togglz/togglz/blob/master/benchmarks/src/main/java/org/togglz/benchmark/ScriptEngineActivationStrategyBenchmark.java
Apache-2.0
@Setup(Level.Trial) public void setupFeatureManager() { FeatureManager featureManager = new FeatureManagerBuilder() .featureEnums(OverheadFeature.class) .stateRepository(new InMemoryStateRepository()) .userProvider(new NoOpUserProvider()) .buil...
Compare the overhead of togglz with an in-memory state repository vs a simple boolean flag
setupFeatureManager
java
togglz/togglz
benchmarks/src/main/java/org/togglz/benchmark/TogglzOverheadBenchmark.java
https://github.com/togglz/togglz/blob/master/benchmarks/src/main/java/org/togglz/benchmark/TogglzOverheadBenchmark.java
Apache-2.0
@Setup(Level.Iteration) public void toggleEnabledState() { enabled = !enabled; manager.setFeatureState(new FeatureState(OverheadFeature.FEATURE, enabled)); }
Compare the overhead of togglz with an in-memory state repository vs a simple boolean flag
toggleEnabledState
java
togglz/togglz
benchmarks/src/main/java/org/togglz/benchmark/TogglzOverheadBenchmark.java
https://github.com/togglz/togglz/blob/master/benchmarks/src/main/java/org/togglz/benchmark/TogglzOverheadBenchmark.java
Apache-2.0
@Benchmark public int aSimpleBooleanIfStatement() { return (enabled) ? 1 : 0; }
Compare the overhead of togglz with an in-memory state repository vs a simple boolean flag
aSimpleBooleanIfStatement
java
togglz/togglz
benchmarks/src/main/java/org/togglz/benchmark/TogglzOverheadBenchmark.java
https://github.com/togglz/togglz/blob/master/benchmarks/src/main/java/org/togglz/benchmark/TogglzOverheadBenchmark.java
Apache-2.0
@Benchmark public int featureManagerStateLookup() { return (manager.isActive(OverheadFeature.FEATURE)) ? 1 : 0; }
Compare the overhead of togglz with an in-memory state repository vs a simple boolean flag
featureManagerStateLookup
java
togglz/togglz
benchmarks/src/main/java/org/togglz/benchmark/TogglzOverheadBenchmark.java
https://github.com/togglz/togglz/blob/master/benchmarks/src/main/java/org/togglz/benchmark/TogglzOverheadBenchmark.java
Apache-2.0
@Benchmark public int isActiveMethodOnEnum() { return (OverheadFeature.FEATURE.isActive()) ? 1 : 0; }
Compare the overhead of togglz with an in-memory state repository vs a simple boolean flag
isActiveMethodOnEnum
java
togglz/togglz
benchmarks/src/main/java/org/togglz/benchmark/TogglzOverheadBenchmark.java
https://github.com/togglz/togglz/blob/master/benchmarks/src/main/java/org/togglz/benchmark/TogglzOverheadBenchmark.java
Apache-2.0
public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(TogglzOverheadBenchmark.class.getSimpleName()) .forks(1) .build(); new Runner(opt).run(); }
Compare the overhead of togglz with an in-memory state repository vs a simple boolean flag
main
java
togglz/togglz
benchmarks/src/main/java/org/togglz/benchmark/TogglzOverheadBenchmark.java
https://github.com/togglz/togglz/blob/master/benchmarks/src/main/java/org/togglz/benchmark/TogglzOverheadBenchmark.java
Apache-2.0
public void removeFeatureState(Feature feature) { databaseClient.readWriteTransaction().run((tx) -> { dao.delete(feature.name(), tx); return null; }); }
<p> This repository implementation can be used to store the feature state in <a href="https://https://cloud.google.com/spanner/docs/">Google Cloud Spanner</> </p> <p> {@link SpannerStateRepository} stores the feature state in the FeatureToggle table. </p> @author cbuschka+togglz@gmail.com
removeFeatureState
java
togglz/togglz
cloud-spanner/src/main/java/org/togglz/googlecloudspanner/repository/SpannerStateRepository.java
https://github.com/togglz/togglz/blob/master/cloud-spanner/src/main/java/org/togglz/googlecloudspanner/repository/SpannerStateRepository.java
Apache-2.0
public boolean existsFeatureState(Feature feature) { try (ReadOnlyTransaction tx = databaseClient.readOnlyTransaction();) { return dao.select(feature, tx).isPresent(); } }
<p> This repository implementation can be used to store the feature state in <a href="https://https://cloud.google.com/spanner/docs/">Google Cloud Spanner</> </p> <p> {@link SpannerStateRepository} stores the feature state in the FeatureToggle table. </p> @author cbuschka+togglz@gmail.com
existsFeatureState
java
togglz/togglz
cloud-spanner/src/main/java/org/togglz/googlecloudspanner/repository/SpannerStateRepository.java
https://github.com/togglz/togglz/blob/master/cloud-spanner/src/main/java/org/togglz/googlecloudspanner/repository/SpannerStateRepository.java
Apache-2.0
@Override public FeatureState getFeatureState(Feature feature) { try (ReadOnlyTransaction tx = databaseClient.readOnlyTransaction()) { return dao.select(feature, tx).orElse(null); } }
<p> This repository implementation can be used to store the feature state in <a href="https://https://cloud.google.com/spanner/docs/">Google Cloud Spanner</> </p> <p> {@link SpannerStateRepository} stores the feature state in the FeatureToggle table. </p> @author cbuschka+togglz@gmail.com
getFeatureState
java
togglz/togglz
cloud-spanner/src/main/java/org/togglz/googlecloudspanner/repository/SpannerStateRepository.java
https://github.com/togglz/togglz/blob/master/cloud-spanner/src/main/java/org/togglz/googlecloudspanner/repository/SpannerStateRepository.java
Apache-2.0
@Override public void setFeatureState(FeatureState featureState) { databaseClient.readWriteTransaction().run((tx) -> { dao.upsert(featureState, tx); return null; }); }
<p> This repository implementation can be used to store the feature state in <a href="https://https://cloud.google.com/spanner/docs/">Google Cloud Spanner</> </p> <p> {@link SpannerStateRepository} stores the feature state in the FeatureToggle table. </p> @author cbuschka+togglz@gmail.com
setFeatureState
java
togglz/togglz
cloud-spanner/src/main/java/org/togglz/googlecloudspanner/repository/SpannerStateRepository.java
https://github.com/togglz/togglz/blob/master/cloud-spanner/src/main/java/org/togglz/googlecloudspanner/repository/SpannerStateRepository.java
Apache-2.0
public static Builder builder() { return new Builder(); }
Creates a new builder for creating a {@link GoogleCloudStorageStateRepository}. @return a {@link Builder}
builder
java
togglz/togglz
cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
https://github.com/togglz/togglz/blob/master/cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
Apache-2.0
@Override public FeatureState getFeatureState(final Feature feature) { Blob blob; try { blob = storageClient.get(BlobId.of(bucketName, prefix + feature.name())); } catch (StorageException e) { throw new GoogleCloudStorageStateRepositoryException("Failed to get the blo...
Creates a new builder for creating a {@link GoogleCloudStorageStateRepository}. @return a {@link Builder}
getFeatureState
java
togglz/togglz
cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
https://github.com/togglz/togglz/blob/master/cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
Apache-2.0
@Override public void setFeatureState(final FeatureState featureState) { try { FeatureStateStorageWrapper storageWrapper = FeatureStateStorageWrapper.wrapperForFeatureState(featureState); String json = objectMapper.writeValueAsString(storageWrapper); BlobInfo blobInfo = ...
Creates a new builder for creating a {@link GoogleCloudStorageStateRepository}. @return a {@link Builder}
setFeatureState
java
togglz/togglz
cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
https://github.com/togglz/togglz/blob/master/cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
Apache-2.0
public Builder storageClient(final Storage storageClient) { this.storageClient = storageClient; return this; }
Specifies the cloud storage client. @param storageClient the client instance to use for connecting to google cloud storage. @return a {@link Builder} with current settings.
storageClient
java
togglz/togglz
cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
https://github.com/togglz/togglz/blob/master/cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
Apache-2.0
public Builder bucketName(final String bucketName) { this.bucketName = bucketName; return this; }
Specifies the name of the bucket. @param bucketName Name of the bucket @return a {@link Builder} with current settings.
bucketName
java
togglz/togglz
cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
https://github.com/togglz/togglz/blob/master/cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
Apache-2.0
public Builder prefix(final String prefix) { this.prefix = prefix == null ? "" : prefix; return this; }
Optional prefix to prepend on to each key. @param prefix The prefix to use. @return a {@link Builder} with current settings.
prefix
java
togglz/togglz
cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
https://github.com/togglz/togglz/blob/master/cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
Apache-2.0
public GoogleCloudStorageStateRepository build() { return new GoogleCloudStorageStateRepository(this); }
Creates a new {@link GoogleCloudStorageStateRepository} using the current settings.
build
java
togglz/togglz
cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
https://github.com/togglz/togglz/blob/master/cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
Apache-2.0
default boolean isActive() { return FeatureContext.getFeatureManager().isActive(this); }
Checks whether the feature is active for the current user. @return <code>true</code> if the feature is active, <code>false</code> otherwise
isActive
java
togglz/togglz
core/src/main/java/org/togglz/core/Feature.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/Feature.java
Apache-2.0
public static String getNameWithVersion() { String version = getVersion(); return version != null ? "Togglz " + version : "Togglz"; }
Returns <code>Togglz</code> followed by the version if available
getNameWithVersion
java
togglz/togglz
core/src/main/java/org/togglz/core/Togglz.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/Togglz.java
Apache-2.0
public static String getVersion() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { classLoader = Togglz.class.getClassLoader(); } URL url = classLoader.getResource("META-INF/maven/org.togglz/togglz-core/pom.properties"); ...
The version of Togglz or <code>null</code> if it cannot be identified
getVersion
java
togglz/togglz
core/src/main/java/org/togglz/core/Togglz.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/Togglz.java
Apache-2.0
protected String getPropertyName(FeatureState featureState, String parameterName) { String propertyName = featureState.getParameter(parameterName); if (Strings.isNotBlank(propertyName)) { return propertyName; } return DEFAULT_PROPERTY_PREFIX + featureState.getFeature().name(...
<p> Returns the name of the property on which to base the activation of the feature. </p> <p> This method will first attempt to use the value of the parameter with the name provided. If that does not return a valid property name (i.e. non-blank), then a property name will be constructed using a common prefix ("{@value ...
getPropertyName
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/AbstractPropertyDrivenActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/AbstractPropertyDrivenActivationStrategy.java
Apache-2.0
@Override public final boolean isActive(FeatureState featureState, FeatureUser user) { String propertyName = getPropertyName(featureState, getPropertyNameParam()); String propertyValue = getPropertyValue(featureState, user, propertyName); return isActive(featureState, user, propertyName, pr...
<p> Returns the value of the property with the specified {@code name} on which to base the activation of the feature. </p> @param featureState the {@link FeatureState} which represents the current configuration of the feature @param user the {@link FeatureUser user} for which to decide whether the feature is a...
isActive
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/AbstractPropertyDrivenActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/AbstractPropertyDrivenActivationStrategy.java
Apache-2.0
protected String getPropertyNameParam() { return PARAM_NAME; }
<p> Returns the value of the property with the specified {@code name} on which to base the activation of the feature. </p> @param featureState the {@link FeatureState} which represents the current configuration of the feature @param user the {@link FeatureUser user} for which to decide whether the feature is a...
getPropertyNameParam
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/AbstractPropertyDrivenActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/AbstractPropertyDrivenActivationStrategy.java
Apache-2.0
protected boolean isActive(FeatureState featureState, FeatureUser user, String propertyName, String propertyValue) { String expectedValue = featureState.getParameter(PARAM_PROPERTY_VALUE); if(expectedValue == null) { expectedValue = DEFAULT_STATE_VALUE; } return Strings.isNot...
<p> This method is called by {@link #isActive(FeatureState, FeatureUser)} with the property name and value to make the decision as to whether the feature is active. </p> <p> By default, this method will convert {@code propertyValue} into a boolean using {@link Strings#toBoolean(String)} but implementations are free to ...
isActive
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/AbstractPropertyDrivenActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/AbstractPropertyDrivenActivationStrategy.java
Apache-2.0
@Override public Parameter[] getParameters() { return new Parameter[] { ParameterBuilder.create(PARAM_NAME) .optional() .label("Property Name") .description("The name of the property to be used to determine whether the feature is enabled."), ...
<p> This method is called by {@link #isActive(FeatureState, FeatureUser)} with the property name and value to make the decision as to whether the feature is active. </p> <p> By default, this method will convert {@code propertyValue} into a boolean using {@link Strings#toBoolean(String)} but implementations are free to ...
getParameters
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/AbstractPropertyDrivenActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/AbstractPropertyDrivenActivationStrategy.java
Apache-2.0
@Override public final boolean isActive(FeatureState featureState, FeatureUser user) { List<Token> tokens = tokenize(featureState, getTokenParameterName(), getTokenParameterTransformer()); return isActive(featureState, user, tokens); }
<p> An abstract activation strategy that is designed to support cases where a specific parameter contains comma-separated tokens that can be negated by prefixing the value with the NOT operator ({@code !}). </p> <p> {@code AbstractTokenizedActivationStrategy} makes no real assumptions on how implementations will use th...
isActive
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
Apache-2.0
protected List<Token> tokenize(FeatureState featureState, String parameterName, TokenTransformer transformer) { List<String> values = Strings.splitAndTrim(featureState.getParameter(parameterName), "[\\s,]+"); List<Token> tokens = new ArrayList<>(values.size()); for (String value : values) { ...
<p> Looks up and tokenizes the value of the parameter with the given name on the feature. </p> <p> If {@code transformer} is not {@literal null}, it will be asked to transform each individual token value. </p> @param featureState the {@link FeatureState} which represents the current configuration of the feature @p...
tokenize
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
Apache-2.0
public TokenTransformer getTokenParameterTransformer() { return null; }
<p> Returns the transformer to be used to transform the value of each {@link Token}. </p> <p> By default, this method returns {@literal null}, meaning that the token values are used as-provided. </p> @return The {@link TokenTransformer} to be used to transform token values or {@literal null} to use the original values...
getTokenParameterTransformer
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
Apache-2.0
public boolean isNegated() { return negated; }
<p> Returns whether or not this {@link Token} is negated. </p> @return {@literal true} if this token is negated; otherwise {@literal false}.
isNegated
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
Apache-2.0
public String getValue() { return value; }
<p> Returns the value for this {@link Token}. </p> @return The value.
getValue
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
Apache-2.0
@Override public List<ActivationStrategy> getActivationStrategies() { return Collections.unmodifiableList(this.strategies); }
Implementation of {@link ActivationStrategyProvider} that loads the strategies using the JDK {@link ServiceLoader}. @author Jesse Kershaw
getActivationStrategies
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/DefaultActivationStrategyProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/DefaultActivationStrategyProvider.java
Apache-2.0
@Override public String getId() { return ID; }
Activation strategy that enables features for a given percentage of users. This strategy is typically used to implement gradual rollouts. The implementation is based on a hashcode created from the name of the acting user which is calculated by {@link #calculateHashCode(FeatureUser, Feature)}.
getId
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/GradualActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/GradualActivationStrategy.java
Apache-2.0
@Override public String getName() { return "Gradual rollout"; }
Activation strategy that enables features for a given percentage of users. This strategy is typically used to implement gradual rollouts. The implementation is based on a hashcode created from the name of the acting user which is calculated by {@link #calculateHashCode(FeatureUser, Feature)}.
getName
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/GradualActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/GradualActivationStrategy.java
Apache-2.0
@Override public boolean isActive(FeatureState state, FeatureUser user) { if (user != null && Strings.isNotBlank(user.getName())) { String percentageAsString = state.getParameter(PARAM_PERCENTAGE); try { int percentage = Integer.parseInt(percentageAsString); ...
Activation strategy that enables features for a given percentage of users. This strategy is typically used to implement gradual rollouts. The implementation is based on a hashcode created from the name of the acting user which is calculated by {@link #calculateHashCode(FeatureUser, Feature)}.
isActive
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/GradualActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/GradualActivationStrategy.java
Apache-2.0
protected int calculateHashCode(FeatureUser user, Feature feature) { Validate.notNull(user, "user is required"); return (user.getName().toLowerCase(Locale.ENGLISH).trim() + ":" + (feature != null ? feature.name() : "")).hashCode(); }
Activation strategy that enables features for a given percentage of users. This strategy is typically used to implement gradual rollouts. The implementation is based on a hashcode created from the name of the acting user which is calculated by {@link #calculateHashCode(FeatureUser, Feature)}.
calculateHashCode
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/GradualActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/GradualActivationStrategy.java
Apache-2.0
@Override public Parameter[] getParameters() { return new Parameter[] { ParameterBuilder .create(PARAM_PERCENTAGE) .label("Percentage") .matching("\\d{1,3}") .description( "Percentage of u...
Activation strategy that enables features for a given percentage of users. This strategy is typically used to implement gradual rollouts. The implementation is based on a hashcode created from the name of the acting user which is calculated by {@link #calculateHashCode(FeatureUser, Feature)}.
getParameters
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/GradualActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/GradualActivationStrategy.java
Apache-2.0
public static ParameterBuilder create(String name) { return new ParameterBuilder(name); }
Creates a new builder for a parameter with the given name. The name is used to store and retrieve the parameter from the {@link FeatureState}. @see FeatureState#getParameter(String) @see FeatureState#setParameter(String, String)
create
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
Apache-2.0
public ParameterBuilder label(String name) { Validate.notNull(name, "name is required"); this.label = name; return this; }
A custom human readable label for the parameter. If no custom label is set, the builder will use the name of the parameter as a label.
label
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
Apache-2.0
public ParameterBuilder matching(String regex) { Validate.notNull(regex, "regex is required"); this.pattern = Pattern.compile(regex); return this; }
Sets a regular expression that must match for parameter values to be considered as valid.
matching
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
Apache-2.0
public ParameterBuilder optional() { this.optional = true; return this; }
Configures the parameter to be optional.
optional
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
Apache-2.0
public ParameterBuilder largeText() { this.largeText = true; return this; }
Specifies that the parameter typically has large texts as a value
largeText
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
Apache-2.0
public ParameterBuilder description(String description) { this.description = description; return this; }
Sets an optional description for the parameter displayed in the admin console.
description
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
Apache-2.0
@Override public String getName() { return name; }
Sets an optional description for the parameter displayed in the admin console.
getName
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
Apache-2.0
@Override public String getLabel() { return label; }
Sets an optional description for the parameter displayed in the admin console.
getLabel
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
Apache-2.0
@Override public boolean isValid(String value) { if (pattern != null) { return pattern.matcher(value).matches(); } return true; }
Sets an optional description for the parameter displayed in the admin console.
isValid
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
Apache-2.0
@Override public boolean isOptional() { return optional; }
Sets an optional description for the parameter displayed in the admin console.
isOptional
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
Apache-2.0
@Override public boolean isLargeText() { return largeText; }
Sets an optional description for the parameter displayed in the admin console.
isLargeText
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
Apache-2.0
@Override public String getDescription() { return description; }
Sets an optional description for the parameter displayed in the admin console.
getDescription
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
Apache-2.0
@Override public String getId() { return ID; }
Activation strategy that allows to activate features only for certain server IPs. @author Eli Abramovitch @author Christian Kaltepoth
getId
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/ServerIpActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ServerIpActivationStrategy.java
Apache-2.0
@Override public String getName() { return "IP address (server)"; }
Activation strategy that allows to activate features only for certain server IPs. @author Eli Abramovitch @author Christian Kaltepoth
getName
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/ServerIpActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ServerIpActivationStrategy.java
Apache-2.0
@Override public boolean isActive(FeatureState featureState, FeatureUser user) { String allowedIpsParam = featureState.getParameter(PARAM_IPS); if (Strings.isNotBlank(allowedIpsParam)) { List<String> allowedIps = Strings.splitAndTrim(allowedIpsParam, "[\\s,]+"); for (Stri...
Activation strategy that allows to activate features only for certain server IPs. @author Eli Abramovitch @author Christian Kaltepoth
isActive
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/ServerIpActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ServerIpActivationStrategy.java
Apache-2.0
@Override public Parameter[] getParameters() { return new Parameter[] { ParameterBuilder.create(PARAM_IPS).label("Server IPs") .description("A comma-separated list of server IPs for which the feature should be active.") }; }
Activation strategy that allows to activate features only for certain server IPs. @author Eli Abramovitch @author Christian Kaltepoth
getParameters
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/ServerIpActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ServerIpActivationStrategy.java
Apache-2.0
@Override public String getId() { return ID; }
ActivationStrategy based on a key value pair system property. To activate, the value of the property must match the string value, not case sensitive. <p> Created by Chris Kelley on 5/26/16.
getId
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/SystemPropertyActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/SystemPropertyActivationStrategy.java
Apache-2.0
@Override public String getName() { return "System Property"; }
ActivationStrategy based on a key value pair system property. To activate, the value of the property must match the string value, not case sensitive. <p> Created by Chris Kelley on 5/26/16.
getName
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/SystemPropertyActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/SystemPropertyActivationStrategy.java
Apache-2.0
@Override protected String getPropertyValue(FeatureState featureState, FeatureUser user, String name) { return System.getProperty(name); }
ActivationStrategy based on a key value pair system property. To activate, the value of the property must match the string value, not case sensitive. <p> Created by Chris Kelley on 5/26/16.
getPropertyValue
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/SystemPropertyActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/SystemPropertyActivationStrategy.java
Apache-2.0
@Override protected String getPropertyNameParam() { return PARAM_PROPERTY_NAME; }
ActivationStrategy based on a key value pair system property. To activate, the value of the property must match the string value, not case sensitive. <p> Created by Chris Kelley on 5/26/16.
getPropertyNameParam
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/SystemPropertyActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/SystemPropertyActivationStrategy.java
Apache-2.0
@Override public Parameter[] getParameters() { return new Parameter[] { ParameterBuilder.create(PARAM_PROPERTY_NAME) .optional() .label("System Property Name") .description...
ActivationStrategy based on a key value pair system property. To activate, the value of the property must match the string value, not case sensitive. <p> Created by Chris Kelley on 5/26/16.
getParameters
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/SystemPropertyActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/SystemPropertyActivationStrategy.java
Apache-2.0
@Override public String getId() { return ID; }
Activation strategy that allows to activate features only for certain users. @author Christian Kaltepoth
getId
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/UsernameActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/UsernameActivationStrategy.java
Apache-2.0
@Override public String getName() { return "Users by name"; }
Activation strategy that allows to activate features only for certain users. @author Christian Kaltepoth
getName
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/UsernameActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/UsernameActivationStrategy.java
Apache-2.0
@Override public boolean isActive(FeatureState state, FeatureUser user) { String usersAsString = state.getParameter(PARAM_USERS); if (Strings.isNotBlank(usersAsString)) { List<String> users = Strings.splitAndTrim(usersAsString, ","); if (user != null && Strings.isNotBlank...
Activation strategy that allows to activate features only for certain users. @author Christian Kaltepoth
isActive
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/UsernameActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/UsernameActivationStrategy.java
Apache-2.0
@Override public Parameter[] getParameters() { return new Parameter[] { ParameterBuilder.create(PARAM_USERS).label("Users").largeText() .description("A list of users for which the feature is active.") }; }
Activation strategy that allows to activate features only for certain users. @author Christian Kaltepoth
getParameters
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/UsernameActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/UsernameActivationStrategy.java
Apache-2.0
@Override public String getId() { return ID; }
ActivationStrategy implementation based on roles of the current user. As far as user has at least one of configured roles then feature will be active. <p/> Please note this activation strategy is not coupled to any particular security framework and will work with any framework as far as current user has "roles" attribu...
getId
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/UserRoleActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/UserRoleActivationStrategy.java
Apache-2.0
@Override public String getName() { return NAME; }
ActivationStrategy implementation based on roles of the current user. As far as user has at least one of configured roles then feature will be active. <p/> Please note this activation strategy is not coupled to any particular security framework and will work with any framework as far as current user has "roles" attribu...
getName
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/UserRoleActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/UserRoleActivationStrategy.java
Apache-2.0
@Override public boolean isActive(FeatureState state, FeatureUser user) { if (user != null) { Collection<String> userRoles = (Collection<String>) user.getAttribute(USER_ATTRIBUTE_ROLES); if (userRoles != null) { String rolesAsString = state.getPar...
ActivationStrategy implementation based on roles of the current user. As far as user has at least one of configured roles then feature will be active. <p/> Please note this activation strategy is not coupled to any particular security framework and will work with any framework as far as current user has "roles" attribu...
isActive
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/UserRoleActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/UserRoleActivationStrategy.java
Apache-2.0
@Override public Parameter[] getParameters() { return new Parameter[] { ParameterBuilder.create(PARAM_ROLES_NAME) .label(PARAM_ROLES_LABEL) .description(PARAM_ROLES_DESC) .largeText() }; }
ActivationStrategy implementation based on roles of the current user. As far as user has at least one of configured roles then feature will be active. <p/> Please note this activation strategy is not coupled to any particular security framework and will work with any framework as far as current user has "roles" attribu...
getParameters
java
togglz/togglz
core/src/main/java/org/togglz/core/activation/UserRoleActivationStrategy.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/UserRoleActivationStrategy.java
Apache-2.0
public FeatureManager createFeatureManager(Object context) { /* * Step 1: Try to find TogglzBootstrap implementation */ TogglzBootstrap togglzBootstrap = lookupBean(TogglzBootstrap.class, context); if (togglzBootstrap != null) { FeatureManager manager = togglzBoot...
Tries to automatically build and configure a {@link FeatureManager} like described above. @param context An optional context object which is provided to the {@link BeanFinder} implementations. This parameter is for example used in web application to supply the ServletContext. @return A newly created {@link Feat...
createFeatureManager
java
togglz/togglz
core/src/main/java/org/togglz/core/bootstrap/FeatureManagerBootstrapper.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/bootstrap/FeatureManagerBootstrapper.java
Apache-2.0
private <T> T lookupBean(Class<T> clazz, Object context) { Set<T> impls = new HashSet<>(); for (BeanFinder beanFinder : ServiceLoader.load(BeanFinder.class)) { Collection<T> result = beanFinder.find(clazz, context); if (result != null) { impls.addAll(result); ...
Tries to automatically build and configure a {@link FeatureManager} like described above. @param context An optional context object which is provided to the {@link BeanFinder} implementations. This parameter is for example used in web application to supply the ServletContext. @return A newly created {@link Feat...
lookupBean
java
togglz/togglz
core/src/main/java/org/togglz/core/bootstrap/FeatureManagerBootstrapper.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/bootstrap/FeatureManagerBootstrapper.java
Apache-2.0
@Override public int priority() { return 60; }
{@link FeatureManagerProvider} that uses the {@link BeanFinder} SPI to lookup the {@link FeatureManager}. This implementation is especially useful if the FeatureManager should be created and managed by Spring or CDI instead of by the Togglz bootstrapping process. @author Christian Kaltepoth
priority
java
togglz/togglz
core/src/main/java/org/togglz/core/context/BeanFinderFeatureManagerProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/BeanFinderFeatureManagerProvider.java
Apache-2.0
@Override public FeatureManager getFeatureManager() { // we _may_ find multiple managers, which will lead to an error Set<FeatureManager> managers = new HashSet<>(); // ask all providers for managed FeatureManager for (BeanFinder beanFinder : ServiceLoader.load(BeanFinder.class)) {...
{@link FeatureManagerProvider} that uses the {@link BeanFinder} SPI to lookup the {@link FeatureManager}. This implementation is especially useful if the FeatureManager should be created and managed by Spring or CDI instead of by the Togglz bootstrapping process. @author Christian Kaltepoth
getFeatureManager
java
togglz/togglz
core/src/main/java/org/togglz/core/context/BeanFinderFeatureManagerProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/BeanFinderFeatureManagerProvider.java
Apache-2.0
@Override public int priority() { return 100; }
This implementation of {@link FeatureManagerProvider} stores one {@link FeatureManager} for each context class loader. @author Christian Kaltepoth
priority
java
togglz/togglz
core/src/main/java/org/togglz/core/context/ContextClassLoaderFeatureManagerProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/ContextClassLoaderFeatureManagerProvider.java
Apache-2.0
@Override public FeatureManager getFeatureManager() { return managerMap.get(contextClassLoader()); }
This implementation of {@link FeatureManagerProvider} stores one {@link FeatureManager} for each context class loader. @author Christian Kaltepoth
getFeatureManager
java
togglz/togglz
core/src/main/java/org/togglz/core/context/ContextClassLoaderFeatureManagerProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/ContextClassLoaderFeatureManagerProvider.java
Apache-2.0
public static void bind(FeatureManager featureManager) { Object old = managerMap.putIfAbsent(contextClassLoader(), featureManager); if (old != null) { throw new IllegalStateException( "There is already a FeatureManager associated with the context ClassLoader of the current th...
Binds the {@link FeatureManager} to the current context class loader .
bind
java
togglz/togglz
core/src/main/java/org/togglz/core/context/ContextClassLoaderFeatureManagerProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/ContextClassLoaderFeatureManagerProvider.java
Apache-2.0
private static ClassLoader contextClassLoader() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { throw new IllegalStateException("Unable to get the context class loader for the current thread!"); } return classLoader; ...
Releases the {@link FeatureManager} associated with the current context class loader.
contextClassLoader
java
togglz/togglz
core/src/main/java/org/togglz/core/context/ContextClassLoaderFeatureManagerProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/ContextClassLoaderFeatureManagerProvider.java
Apache-2.0
public static FeatureManager getFeatureManager() { FeatureManager manager = getFeatureManagerOrNull(); if (manager != null) { return manager; } throw new IllegalStateException("Could not find the FeatureManager. " + "For web applications please verify that the ...
Returns the {@link FeatureManager} for the current application (context class loader). The method uses the {@link FeatureManagerProvider} SPI to find the correct {@link FeatureManager} instance. It will throw a runtime exception if no {@link FeatureManager} can be found. @return The {@link FeatureManager} for the appl...
getFeatureManager
java
togglz/togglz
core/src/main/java/org/togglz/core/context/FeatureContext.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/FeatureContext.java
Apache-2.0
public static FeatureManager getFeatureManagerOrNull() { ClassLoader classLoader = getContextClassLoader(); FeatureManager featureManager = cache.get(classLoader); if (featureManager != null) { return featureManager; } featureManager = findFeatureManagerInClassLoader(...
Returns the {@link FeatureManager} for the current application (context class loader). The method uses the {@link FeatureManagerProvider} SPI to find the correct {@link FeatureManager} instance. If not manager could be found, <code>null</code> is returned. @return The {@link FeatureManager} for the application or <cod...
getFeatureManagerOrNull
java
togglz/togglz
core/src/main/java/org/togglz/core/context/FeatureContext.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/FeatureContext.java
Apache-2.0
private static FeatureManager findFeatureManagerInClassLoader(ClassLoader classLoader) { if (log.isDebugEnabled()) { log.debug("No cached FeatureManager for class loader: " + classLoader); } // build a sorted list of all SPI implementations Iterator<FeatureManagerProvider> p...
Returns the {@link FeatureManager} for the current application (context class loader). The method uses the {@link FeatureManagerProvider} SPI to find the correct {@link FeatureManager} instance. If not manager could be found, <code>null</code> is returned. @return The {@link FeatureManager} for the application or <cod...
findFeatureManagerInClassLoader
java
togglz/togglz
core/src/main/java/org/togglz/core/context/FeatureContext.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/FeatureContext.java
Apache-2.0
private static ClassLoader getContextClassLoader() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { throw new IllegalStateException("Unable to get the context class loader for the current thread!"); } return classLoader; ...
Returns the context classloader of the current thread. Throws a runtime exception if no context classloader is available.
getContextClassLoader
java
togglz/togglz
core/src/main/java/org/togglz/core/context/FeatureContext.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/FeatureContext.java
Apache-2.0
@Override public int priority() { // runs AFTER the WebAppFeatureManagerProvider return 200; }
Implementation of {@link FeatureManagerProvider} that tries to look up a {@link FeatureManager} from JNDI using the name {@code java:/comp/env/FeatureManager}. @author Christian Kaltepoth
priority
java
togglz/togglz
core/src/main/java/org/togglz/core/context/JNDIFeatureManagerProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/JNDIFeatureManagerProvider.java
Apache-2.0
@Override public FeatureManager getFeatureManager() { if (!isDisabled()) { try { InitialContext initialContext = new InitialContext(); return (FeatureManager) initialContext.lookup(JNDI_NAME); } catch (NamingException e) { log.debug...
Implementation of {@link FeatureManagerProvider} that tries to look up a {@link FeatureManager} from JNDI using the name {@code java:/comp/env/FeatureManager}. @author Christian Kaltepoth
getFeatureManager
java
togglz/togglz
core/src/main/java/org/togglz/core/context/JNDIFeatureManagerProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/JNDIFeatureManagerProvider.java
Apache-2.0
private boolean isDisabled() { return "true".equals(System.getProperty("org.togglz.DISABLE_JNDI_LOOKUPS", "")); }
Implementation of {@link FeatureManagerProvider} that tries to look up a {@link FeatureManager} from JNDI using the name {@code java:/comp/env/FeatureManager}. @author Christian Kaltepoth
isDisabled
java
togglz/togglz
core/src/main/java/org/togglz/core/context/JNDIFeatureManagerProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/JNDIFeatureManagerProvider.java
Apache-2.0
@Override public int priority() { return 70; }
Implementation of {@link FeatureManagerProvider} for Java SE applications. To use it, create a {@link FeatureManager} using the {@link FeatureManagerBuilder} and register it using {@link #setFeatureManager(FeatureManager)}. @author Christian Kaltepoth
priority
java
togglz/togglz
core/src/main/java/org/togglz/core/context/StaticFeatureManagerProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/StaticFeatureManagerProvider.java
Apache-2.0
@Override public FeatureManager getFeatureManager() { return staticInstance; }
Implementation of {@link FeatureManagerProvider} for Java SE applications. To use it, create a {@link FeatureManager} using the {@link FeatureManagerBuilder} and register it using {@link #setFeatureManager(FeatureManager)}. @author Christian Kaltepoth
getFeatureManager
java
togglz/togglz
core/src/main/java/org/togglz/core/context/StaticFeatureManagerProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/StaticFeatureManagerProvider.java
Apache-2.0
public static void setFeatureManager(FeatureManager featureManager) { staticInstance = featureManager; }
Sets the {@link FeatureManager} that the provider should return for calls to {@link #getFeatureManager()}.
setFeatureManager
java
togglz/togglz
core/src/main/java/org/togglz/core/context/StaticFeatureManagerProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/StaticFeatureManagerProvider.java
Apache-2.0
public static void bind(FeatureManager featureManager) { if (featureManager != null && threadLocal.get() != null) { throw new IllegalStateException("bind() called for a thread that already has a FeatureManager " + "associated with it. It's likely that the FeatureManager is not co...
Store the supplied {@link FeatureManager} in the thread context. After calling this method all calls of {@link #getFeatureManager()} from the active thread will return this feature manager. Please don't forget to call {@link #release()} before the thread is put back to a thread pool to prevent memory leaks. @param fea...
bind
java
togglz/togglz
core/src/main/java/org/togglz/core/context/ThreadLocalFeatureManagerProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/ThreadLocalFeatureManagerProvider.java
Apache-2.0
@Override public int priority() { return 50; }
Removes the {@link FeatureManager} associated with the current thread from the thread's context. It's required to always call this method before a thread is put back to a thread pool.
priority
java
togglz/togglz
core/src/main/java/org/togglz/core/context/ThreadLocalFeatureManagerProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/ThreadLocalFeatureManagerProvider.java
Apache-2.0
@Override public FeatureManager getFeatureManager() { return threadLocal.get(); }
Removes the {@link FeatureManager} associated with the current thread from the thread's context. It's required to always call this method before a thread is put back to a thread pool.
getFeatureManager
java
togglz/togglz
core/src/main/java/org/togglz/core/context/ThreadLocalFeatureManagerProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/ThreadLocalFeatureManagerProvider.java
Apache-2.0
protected TogglzConfig getConfiguration(Object obj) { if (obj instanceof Reference) { Reference reference = (Reference) obj; Enumeration<RefAddr> addrs = reference.getAll(); while (addrs.hasMoreElements()) { RefAddr refAddr = addrs.nextElement(); ...
This class looks up the {@link TogglzConfig} to use when building the {@link FeatureManager}. @param obj The {@link Object} obtained from {@link #getObjectInstance(Object, Name, Context, Hashtable)}.
getConfiguration
java
togglz/togglz
core/src/main/java/org/togglz/core/jndi/FeatureManagerObjectFactory.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/jndi/FeatureManagerObjectFactory.java
Apache-2.0
protected Object createInstance(String classname) { // get the classloader to use ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { classLoader = this.getClass().getClassLoader(); } // create an instance of the class...
Creates an instance of the supplied class.
createInstance
java
togglz/togglz
core/src/main/java/org/togglz/core/jndi/FeatureManagerObjectFactory.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/jndi/FeatureManagerObjectFactory.java
Apache-2.0
@Override public FeatureState getFeatureState(Feature feature) { return delegate.getFeatureState(feature); }
Creates a logging facade for the supplied {@link StateRepository} using a custom log message. In your custom log message, mark the position of the feature name as {1} and the position for the new feature state which will be replaced by "enabled" or "disabled" as {2}. @param delegate The repository to delegate invocati...
getFeatureState
java
togglz/togglz
core/src/main/java/org/togglz/core/logging/LoggingStateRepository.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/logging/LoggingStateRepository.java
Apache-2.0
@Override public void setFeatureState(FeatureState featureState) { if (customLogMessage != null) { log.info(createCustomLogMessage(featureState)); } else { log.info(createDefaultLogMessage(featureState)); } delegate.setFeatureState(featureState); }
Creates a logging facade for the supplied {@link StateRepository} using a custom log message. In your custom log message, mark the position of the feature name as {1} and the position for the new feature state which will be replaced by "enabled" or "disabled" as {2}. @param delegate The repository to delegate invocati...
setFeatureState
java
togglz/togglz
core/src/main/java/org/togglz/core/logging/LoggingStateRepository.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/logging/LoggingStateRepository.java
Apache-2.0
private String createDefaultLogMessage(FeatureState featureState) { return "Setting Feature \"" + featureState.getFeature().name() + "\" to \"" + getReadableFeatureState(featureState) + "\""; }
Creates a logging facade for the supplied {@link StateRepository} using a custom log message. In your custom log message, mark the position of the feature name as {1} and the position for the new feature state which will be replaced by "enabled" or "disabled" as {2}. @param delegate The repository to delegate invocati...
createDefaultLogMessage
java
togglz/togglz
core/src/main/java/org/togglz/core/logging/LoggingStateRepository.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/logging/LoggingStateRepository.java
Apache-2.0
private String createCustomLogMessage(FeatureState featureState) { String logMsg = customLogMessage; logMsg = logMsg.replace("{1}", featureState.getFeature().name()); logMsg = logMsg.replace("{2}", getReadableFeatureState(featureState)); return logMsg; }
Creates a logging facade for the supplied {@link StateRepository} using a custom log message. In your custom log message, mark the position of the feature name as {1} and the position for the new feature state which will be replaced by "enabled" or "disabled" as {2}. @param delegate The repository to delegate invocati...
createCustomLogMessage
java
togglz/togglz
core/src/main/java/org/togglz/core/logging/LoggingStateRepository.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/logging/LoggingStateRepository.java
Apache-2.0
private String getReadableFeatureState(FeatureState featureState) { return featureState.isEnabled() ? "enabled" : "disabled"; }
Creates a logging facade for the supplied {@link StateRepository} using a custom log message. In your custom log message, mark the position of the feature name as {1} and the position for the new feature state which will be replaced by "enabled" or "disabled" as {2}. @param delegate The repository to delegate invocati...
getReadableFeatureState
java
togglz/togglz
core/src/main/java/org/togglz/core/logging/LoggingStateRepository.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/logging/LoggingStateRepository.java
Apache-2.0
@Override public Set<Feature> getFeatures() { Set<Feature> features = new LinkedHashSet<>(); for (FeatureProvider provider : delegates) { features.addAll(provider.getFeatures()); } return features; }
A feature provider that delegates to one or more other providers. @author Dave Syer
getFeatures
java
togglz/togglz
core/src/main/java/org/togglz/core/manager/CompositeFeatureProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/manager/CompositeFeatureProvider.java
Apache-2.0