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 DynamoDBStateRepositoryBuilder withStateStoredInTable(String tableName) {
this.tableName = tableName;
return this;
} | <p>
Builder for a DynamoDBStateRepository.
</p>
<p>
<p>
Usage example:
</p>
<p>
<pre>
DynamoDBStateRepository dynamoDbStateRepository = new DynamoDBStateRepositoryBuilder(dbClient)
.withStateStoredInTable("togglz-state-storage")
.build();
</pre> | withStateStoredInTable | java | togglz/togglz | dynamodb/src/main/java/org/togglz/dynamodb/DynamoDBStateRepository.java | https://github.com/togglz/togglz/blob/master/dynamodb/src/main/java/org/togglz/dynamodb/DynamoDBStateRepository.java | Apache-2.0 |
public DynamoDBStateRepository build() {
if (this.objectMapper == null) {
this.objectMapper = new ObjectMapper();
}
initializeTable();
return new DynamoDBStateRepository(this);
} | <p>
Builder for a DynamoDBStateRepository.
</p>
<p>
<p>
Usage example:
</p>
<p>
<pre>
DynamoDBStateRepository dynamoDbStateRepository = new DynamoDBStateRepositoryBuilder(dbClient)
.withStateStoredInTable("togglz-state-storage")
.build();
</pre> | build | java | togglz/togglz | dynamodb/src/main/java/org/togglz/dynamodb/DynamoDBStateRepository.java | https://github.com/togglz/togglz/blob/master/dynamodb/src/main/java/org/togglz/dynamodb/DynamoDBStateRepository.java | Apache-2.0 |
private void initializeTable() {
DescribeTableRequest request = DescribeTableRequest.builder()
.tableName(this.tableName)
.build();
try {
TableDescription tableDescription = dynamoDbClient.describeTable(request).table();
lo... | <p>
Builder for a DynamoDBStateRepository.
</p>
<p>
<p>
Usage example:
</p>
<p>
<pre>
DynamoDBStateRepository dynamoDbStateRepository = new DynamoDBStateRepositoryBuilder(dbClient)
.withStateStoredInTable("togglz-state-storage")
.build();
</pre> | initializeTable | java | togglz/togglz | dynamodb/src/main/java/org/togglz/dynamodb/DynamoDBStateRepository.java | https://github.com/togglz/togglz/blob/master/dynamodb/src/main/java/org/togglz/dynamodb/DynamoDBStateRepository.java | Apache-2.0 |
private HazelcastInstance createHazelcastInstance() {
if(hazelcastClientConfig==null && hazelcastConfig==null) {
return Hazelcast.newHazelcastInstance();
}
if(hazelcastClientConfig==null) {
return Hazelcast.newHazelcastInstance(hazelcastConfig);
}
return HazelcastClient.newHazelcastClient(hazelcastCli... | <p>
A state repository which stores the feature state in a Hazelcast distributed map.
</p>
<p>
The class provides a builder which can be used to configure the Hazelcast instance and map to be used:
</p>
<pre>
StateRepository repository = HazelcastStateRepository.newBuilder().mapName("my_map")
.config(haze... | createHazelcastInstance | java | togglz/togglz | hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | https://github.com/togglz/togglz/blob/master/hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | Apache-2.0 |
@Override
public FeatureState getFeatureState(final Feature feature) {
final IMap<Feature, FeatureState> map = hazelcastInstance.getMap(mapName);
return map.get(feature);
} | <p>
A state repository which stores the feature state in a Hazelcast distributed map.
</p>
<p>
The class provides a builder which can be used to configure the Hazelcast instance and map to be used:
</p>
<pre>
StateRepository repository = HazelcastStateRepository.newBuilder().mapName("my_map")
.config(haze... | getFeatureState | java | togglz/togglz | hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | https://github.com/togglz/togglz/blob/master/hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | Apache-2.0 |
@Override
public void setFeatureState(final FeatureState featureState) {
final IMap<Feature, FeatureState> map = hazelcastInstance.getMap(mapName);
map.set(featureState.getFeature(), featureState);
} | <p>
A state repository which stores the feature state in a Hazelcast distributed map.
</p>
<p>
The class provides a builder which can be used to configure the Hazelcast instance and map to be used:
</p>
<pre>
StateRepository repository = HazelcastStateRepository.newBuilder().mapName("my_map")
.config(haze... | setFeatureState | java | togglz/togglz | hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | https://github.com/togglz/togglz/blob/master/hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | Apache-2.0 |
public static Builder newBuilder() {
return new Builder();
} | Creates a new builder for creating a {@link HazelcastStateRepository}. | newBuilder | java | togglz/togglz | hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | https://github.com/togglz/togglz/blob/master/hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | Apache-2.0 |
public static Builder newBuilder(String mapName) {
return new Builder(mapName);
} | Creates a new builder for creating a {@link HazelcastStateRepository}.
@param mapName
the Hazelcast map name | newBuilder | java | togglz/togglz | hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | https://github.com/togglz/togglz/blob/master/hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | Apache-2.0 |
public Builder mapName(String mapName) {
this.mapName = mapName;
return this;
} | Sets the Hazelcast map name to use.
@param mapName
the Hazelcast map name to use for feature state store | mapName | java | togglz/togglz | hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | https://github.com/togglz/togglz/blob/master/hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | Apache-2.0 |
public Builder config(Config hazelcastConfig) {
this.hazelcastConfig = hazelcastConfig;
return this;
} | Sets the Hazelcast configuration.
@param hazelcastConfig
the Hazelcast configuration {@link Config} | config | java | togglz/togglz | hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | https://github.com/togglz/togglz/blob/master/hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | Apache-2.0 |
public Builder clientConfig(ClientConfig hazelcastClientConfig) {
this.hazelcastClientConfig = hazelcastClientConfig;
return this;
} | Sets the Hazelcast configuration.
@param hazelcastConfig
the Hazelcast configuration {@link Config} | clientConfig | java | togglz/togglz | hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | https://github.com/togglz/togglz/blob/master/hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | Apache-2.0 |
public Builder hazelcastInstance(HazelcastInstance hazelcastInstance) {
this.hazelcastInstance = hazelcastInstance;
return this;
} | Sets the Hazelcast configuration.
@param hazelcastConfig
the Hazelcast configuration {@link Config} | hazelcastInstance | java | togglz/togglz | hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | https://github.com/togglz/togglz/blob/master/hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | Apache-2.0 |
public HazelcastStateRepository build() {
checkStateOfWhatIsSet();
return new HazelcastStateRepository(this);
} | Creates a new {@link HazelcastStateRepository} using the current
settings. | build | java | togglz/togglz | hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | https://github.com/togglz/togglz/blob/master/hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | Apache-2.0 |
private void checkStateOfWhatIsSet() {
int countOfWhatIsSet = 0;
if(hazelcastClientConfig!=null) {
countOfWhatIsSet++;
}
if(hazelcastConfig!=null) {
countOfWhatIsSet++;
}
if(hazelcastInstance!=null) {
countOfWhatIsSet++;
}
... | Creates a new {@link HazelcastStateRepository} using the current
settings. | checkStateOfWhatIsSet | java | togglz/togglz | hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | https://github.com/togglz/togglz/blob/master/hazelcast/src/main/java/org/togglz/hazelcast/HazelcastStateRepository.java | Apache-2.0 |
public static Builder builder(final Class<? extends Feature> featuresClass) {
return new Builder(featuresClass);
} | <p>
JUnit rule that simplifies the process of controlling features in unit tests.
</p>
<p>
Example usage:
</p>
<pre>
public class TogglzRuleAllEnabledTest {
@Rule
public TogglzRule togglzRule = TogglzRule.allEnabled(MyFeatures.class);
@Test
public void testToggleFeature() {
assertTrue(MyFeature... | builder | java | togglz/togglz | junit/src/main/java/org/togglz/junit/TogglzRule.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit/TogglzRule.java | Apache-2.0 |
public static TogglzRule allEnabled(Class<? extends Feature> featureClass) {
return builder(featureClass).enableAll().build();
} | <p>
JUnit rule that simplifies the process of controlling features in unit tests.
</p>
<p>
Example usage:
</p>
<pre>
public class TogglzRuleAllEnabledTest {
@Rule
public TogglzRule togglzRule = TogglzRule.allEnabled(MyFeatures.class);
@Test
public void testToggleFeature() {
assertTrue(MyFeature... | allEnabled | java | togglz/togglz | junit/src/main/java/org/togglz/junit/TogglzRule.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit/TogglzRule.java | Apache-2.0 |
public static TogglzRule allDisabled(Class<? extends Feature> featureClass) {
return builder(featureClass).disableAll().build();
} | <p>
JUnit rule that simplifies the process of controlling features in unit tests.
</p>
<p>
Example usage:
</p>
<pre>
public class TogglzRuleAllEnabledTest {
@Rule
public TogglzRule togglzRule = TogglzRule.allEnabled(MyFeatures.class);
@Test
public void testToggleFeature() {
assertTrue(MyFeature... | allDisabled | java | togglz/togglz | junit/src/main/java/org/togglz/junit/TogglzRule.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit/TogglzRule.java | Apache-2.0 |
@Override
public Statement apply(final Statement base, final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
try {
if (featureManager != null) {
throw new IllegalSt... | <p>
JUnit rule that simplifies the process of controlling features in unit tests.
</p>
<p>
Example usage:
</p>
<pre>
public class TogglzRuleAllEnabledTest {
@Rule
public TogglzRule togglzRule = TogglzRule.allEnabled(MyFeatures.class);
@Test
public void testToggleFeature() {
assertTrue(MyFeature... | apply | java | togglz/togglz | junit/src/main/java/org/togglz/junit/TogglzRule.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit/TogglzRule.java | Apache-2.0 |
@Override
public void evaluate() throws Throwable {
try {
if (featureManager != null) {
throw new IllegalStateException("Found existing TestFeatureManager");
}
WithFeature withFeature = description.getAnno... | <p>
JUnit rule that simplifies the process of controlling features in unit tests.
</p>
<p>
Example usage:
</p>
<pre>
public class TogglzRuleAllEnabledTest {
@Rule
public TogglzRule togglzRule = TogglzRule.allEnabled(MyFeatures.class);
@Test
public void testToggleFeature() {
assertTrue(MyFeature... | evaluate | java | togglz/togglz | junit/src/main/java/org/togglz/junit/TogglzRule.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit/TogglzRule.java | Apache-2.0 |
public Builder enable(final Feature f) {
variationSetBuilder.enable(f);
return this;
} | <p>
JUnit rule that simplifies the process of controlling features in unit tests.
</p>
<p>
Example usage:
</p>
<pre>
public class TogglzRuleAllEnabledTest {
@Rule
public TogglzRule togglzRule = TogglzRule.allEnabled(MyFeatures.class);
@Test
public void testToggleFeature() {
assertTrue(MyFeature... | enable | java | togglz/togglz | junit/src/main/java/org/togglz/junit/TogglzRule.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit/TogglzRule.java | Apache-2.0 |
public Builder enableAll() {
variationSetBuilder.enableAll();
return this;
} | <p>
JUnit rule that simplifies the process of controlling features in unit tests.
</p>
<p>
Example usage:
</p>
<pre>
public class TogglzRuleAllEnabledTest {
@Rule
public TogglzRule togglzRule = TogglzRule.allEnabled(MyFeatures.class);
@Test
public void testToggleFeature() {
assertTrue(MyFeature... | enableAll | java | togglz/togglz | junit/src/main/java/org/togglz/junit/TogglzRule.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit/TogglzRule.java | Apache-2.0 |
public Builder disable(final Feature f) {
variationSetBuilder.disable(f);
return this;
} | <p>
JUnit rule that simplifies the process of controlling features in unit tests.
</p>
<p>
Example usage:
</p>
<pre>
public class TogglzRuleAllEnabledTest {
@Rule
public TogglzRule togglzRule = TogglzRule.allEnabled(MyFeatures.class);
@Test
public void testToggleFeature() {
assertTrue(MyFeature... | disable | java | togglz/togglz | junit/src/main/java/org/togglz/junit/TogglzRule.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit/TogglzRule.java | Apache-2.0 |
public Builder disableAll() {
variationSetBuilder.disableAll();
return this;
} | <p>
JUnit rule that simplifies the process of controlling features in unit tests.
</p>
<p>
Example usage:
</p>
<pre>
public class TogglzRuleAllEnabledTest {
@Rule
public TogglzRule togglzRule = TogglzRule.allEnabled(MyFeatures.class);
@Test
public void testToggleFeature() {
assertTrue(MyFeature... | disableAll | java | togglz/togglz | junit/src/main/java/org/togglz/junit/TogglzRule.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit/TogglzRule.java | Apache-2.0 |
public Builder vary(final Feature f) {
variationSetBuilder.vary(f);
return this;
} | <p>
JUnit rule that simplifies the process of controlling features in unit tests.
</p>
<p>
Example usage:
</p>
<pre>
public class TogglzRuleAllEnabledTest {
@Rule
public TogglzRule togglzRule = TogglzRule.allEnabled(MyFeatures.class);
@Test
public void testToggleFeature() {
assertTrue(MyFeature... | vary | java | togglz/togglz | junit/src/main/java/org/togglz/junit/TogglzRule.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit/TogglzRule.java | Apache-2.0 |
public TogglzRule build() {
return new TogglzRule(featuresClass, variationSetBuilder.getVariants());
} | <p>
JUnit rule that simplifies the process of controlling features in unit tests.
</p>
<p>
Example usage:
</p>
<pre>
public class TogglzRuleAllEnabledTest {
@Rule
public TogglzRule togglzRule = TogglzRule.allEnabled(MyFeatures.class);
@Test
public void testToggleFeature() {
assertTrue(MyFeature... | build | java | togglz/togglz | junit/src/main/java/org/togglz/junit/TogglzRule.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit/TogglzRule.java | Apache-2.0 |
private VariationSet<? extends Feature> getPermutationFromMethod(TestClass testClass) {
List<FrameworkMethod> methods = testClass.getAnnotatedMethods(Variations.class);
for (FrameworkMethod method : methods) {
int modifiers = method.getMethod().getModifiers();
if (Modifier.isSta... | <p>
This class is custom JUnit runner that allows to run tests against different feature combinations. A usecase for this runner
would be for example to test feature toggles that enable caching behavior. The runner can be configured to run the tests two
times. Once with the flag enabled and once with the flag being dis... | getPermutationFromMethod | java | togglz/togglz | junit/src/main/java/org/togglz/junit/vary/FeatureVariations.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit/vary/FeatureVariations.java | Apache-2.0 |
@Override
protected List<Runner> getChildren() {
return runners;
} | <p>
This class is custom JUnit runner that allows to run tests against different feature combinations. A usecase for this runner
would be for example to test feature toggles that enable caching behavior. The runner can be configured to run the tests two
times. Once with the flag enabled and once with the flag being dis... | getChildren | java | togglz/togglz | junit/src/main/java/org/togglz/junit/vary/FeatureVariations.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit/vary/FeatureVariations.java | Apache-2.0 |
@Override
protected Statement methodInvoker(FrameworkMethod method, Object test) {
final Statement delegate = super.methodInvoker(method, test);
return new Statement() {
@Override
public void evaluate() throws Throwable {
try {
// creat... | Internal class that executes a test for a test class for a single feature variation.
@author Christian Kaltepoth | methodInvoker | java | togglz/togglz | junit/src/main/java/org/togglz/junit/vary/VariationRunner.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit/vary/VariationRunner.java | Apache-2.0 |
@Override
public void evaluate() throws Throwable {
try {
// create blank instance and set initial state
TestFeatureManager featureManager = new TestFeatureManager(featureClass);
for (Feature feature : activeFeatures) {
... | Internal class that executes a test for a test class for a single feature variation.
@author Christian Kaltepoth | evaluate | java | togglz/togglz | junit/src/main/java/org/togglz/junit/vary/VariationRunner.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit/vary/VariationRunner.java | Apache-2.0 |
@Override
TestFeatureManager createTestFeatureManager(ExtensionContext context) {
TestFeatureManager featureManager = null;
Optional<AllEnabled> allEnabled = findAnnotation(context, AllEnabled.class);
Optional<AllDisabled> allDisabled = findAnnotation(context, AllDisabled.class);
if... | <p>
JUnit Extension, which creates a {@link TestFeatureManager} with all features enabled/disabled.
</p>
@see AllEnabled
@see AllDisabled
@author Roland Weisleder | createTestFeatureManager | java | togglz/togglz | junit/src/main/java/org/togglz/junit5/AnnotationBasedTogglzExtension.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit5/AnnotationBasedTogglzExtension.java | Apache-2.0 |
private <T extends Annotation> Optional<T> findAnnotation(ExtensionContext context, Class<T> annotationClass) {
Method testMethod = context.getRequiredTestMethod();
Optional<T> annotation = AnnotationSupport.findAnnotation(testMethod, annotationClass);
if (annotation.isPresent()) {
r... | <p>
JUnit Extension, which creates a {@link TestFeatureManager} with all features enabled/disabled.
</p>
@see AllEnabled
@see AllDisabled
@author Roland Weisleder | findAnnotation | java | togglz/togglz | junit/src/main/java/org/togglz/junit5/AnnotationBasedTogglzExtension.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit5/AnnotationBasedTogglzExtension.java | Apache-2.0 |
@Override
public void beforeEach(ExtensionContext context) {
featureManager = createTestFeatureManager(context);
TestFeatureManagerProvider.setFeatureManager(featureManager);
FeatureContext.clearCache();
} | <p>
JUnit Extension, which sets up a {@link TestFeatureManager} and provides it as parameter to test methods.
</p>
<p>
Implementation classes must provide a fully initialized {@link TestFeatureManager}.
</p>
@see AnnotationBasedTogglzExtension
@see FeatureVariationInvocationContext
@author Roland Weisleder | beforeEach | java | togglz/togglz | junit/src/main/java/org/togglz/junit5/FeatureManagerExtension.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit5/FeatureManagerExtension.java | Apache-2.0 |
@Override
public void afterEach(ExtensionContext context) {
TestFeatureManagerProvider.setFeatureManager(null);
FeatureContext.clearCache();
} | <p>
JUnit Extension, which sets up a {@link TestFeatureManager} and provides it as parameter to test methods.
</p>
<p>
Implementation classes must provide a fully initialized {@link TestFeatureManager}.
</p>
@see AnnotationBasedTogglzExtension
@see FeatureVariationInvocationContext
@author Roland Weisleder | afterEach | java | togglz/togglz | junit/src/main/java/org/togglz/junit5/FeatureManagerExtension.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit5/FeatureManagerExtension.java | Apache-2.0 |
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
return parameterContext.getParameter().getType().isAssignableFrom(TestFeatureManager.class);
} | <p>
JUnit Extension, which sets up a {@link TestFeatureManager} and provides it as parameter to test methods.
</p>
<p>
Implementation classes must provide a fully initialized {@link TestFeatureManager}.
</p>
@see AnnotationBasedTogglzExtension
@see FeatureVariationInvocationContext
@author Roland Weisleder | supportsParameter | java | togglz/togglz | junit/src/main/java/org/togglz/junit5/FeatureManagerExtension.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit5/FeatureManagerExtension.java | Apache-2.0 |
@Override
public TestFeatureManager resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
return featureManager;
} | <p>
JUnit Extension, which sets up a {@link TestFeatureManager} and provides it as parameter to test methods.
</p>
<p>
Implementation classes must provide a fully initialized {@link TestFeatureManager}.
</p>
@see AnnotationBasedTogglzExtension
@see FeatureVariationInvocationContext
@author Roland Weisleder | resolveParameter | java | togglz/togglz | junit/src/main/java/org/togglz/junit5/FeatureManagerExtension.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit5/FeatureManagerExtension.java | Apache-2.0 |
@Override
public List<Extension> getAdditionalExtensions() {
return singletonList(new FeatureVariantExtension());
} | <p>
Represents a single {@link TestTemplateInvocationContext} created by the {@link FeatureVariationTogglzExtension}
which contains a set of enabled features.
</p>
<p>
This invocation contexts adds a {@link FeatureManagerExtension} to the current test.
</p>
<p>
Before executing the test it reports the... | getAdditionalExtensions | java | togglz/togglz | junit/src/main/java/org/togglz/junit5/FeatureVariationInvocationContext.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit5/FeatureVariationInvocationContext.java | Apache-2.0 |
@Override
TestFeatureManager createTestFeatureManager(ExtensionContext context) {
TestFeatureManager featureManager = new TestFeatureManager(featureClass);
featureManager.disableAll();
enabledFeatures.forEach(featureManager::enable);
return featureManager;
... | <p>
Represents a single {@link TestTemplateInvocationContext} created by the {@link FeatureVariationTogglzExtension}
which contains a set of enabled features.
</p>
<p>
This invocation contexts adds a {@link FeatureManagerExtension} to the current test.
</p>
<p>
Before executing the test it reports the... | createTestFeatureManager | java | togglz/togglz | junit/src/main/java/org/togglz/junit5/FeatureVariationInvocationContext.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit5/FeatureVariationInvocationContext.java | Apache-2.0 |
@Override
public void beforeEach(ExtensionContext context) {
String names = enabledFeatures.stream().map(Feature::name).sorted().collect(joining(", ", "[", "]"));
context.publishReportEntry("enabledFeatures", names);
super.beforeEach(context);
} | <p>
Represents a single {@link TestTemplateInvocationContext} created by the {@link FeatureVariationTogglzExtension}
which contains a set of enabled features.
</p>
<p>
This invocation contexts adds a {@link FeatureManagerExtension} to the current test.
</p>
<p>
Before executing the test it reports the... | beforeEach | java | togglz/togglz | junit/src/main/java/org/togglz/junit5/FeatureVariationInvocationContext.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit5/FeatureVariationInvocationContext.java | Apache-2.0 |
@Override
public boolean supportsTestTemplate(ExtensionContext context) {
return true;
} | <p>
JUnit Extension to run {@link org.junit.jupiter.api.TestTemplate TestTemplates} with a variation
of enabled and disabled features.
</p>
@see VaryFeatures
@see VariationSetProvider
@author Roland Weisleder | supportsTestTemplate | java | togglz/togglz | junit/src/main/java/org/togglz/junit5/FeatureVariationTogglzExtension.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit5/FeatureVariationTogglzExtension.java | Apache-2.0 |
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
Optional<VaryFeatures> varyFeatures = context.getElement().flatMap(ae -> findAnnotation(ae, VaryFeatures.class));
if (!varyFeatures.isPresent()) {
return Stream.empty(... | <p>
JUnit Extension to run {@link org.junit.jupiter.api.TestTemplate TestTemplates} with a variation
of enabled and disabled features.
</p>
@see VaryFeatures
@see VariationSetProvider
@author Roland Weisleder | provideTestTemplateInvocationContexts | java | togglz/togglz | junit/src/main/java/org/togglz/junit5/FeatureVariationTogglzExtension.java | https://github.com/togglz/togglz/blob/master/junit/src/main/java/org/togglz/junit5/FeatureVariationTogglzExtension.java | Apache-2.0 |
@Override
public String getId() {
return ID;
} | <p>
An activation strategy based on the values of properties accessible within the MicroProfile Config.
</p>
<p>
It can either be based on a given property name, passed via the "{@value #PARAM_NAME}" parameter, or a property name
derived from the {@link Feature} itself (e.g. "{@value #DEFAULT_PROPERTY_PREFIX}FEATURE_NA... | getId | java | togglz/togglz | microprofile-config/src/main/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategy.java | https://github.com/togglz/togglz/blob/master/microprofile-config/src/main/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategy.java | Apache-2.0 |
@Override
public String getName() {
return "MicroProfile Config Property";
} | <p>
An activation strategy based on the values of properties accessible within the MicroProfile Config.
</p>
<p>
It can either be based on a given property name, passed via the "{@value #PARAM_NAME}" parameter, or a property name
derived from the {@link Feature} itself (e.g. "{@value #DEFAULT_PROPERTY_PREFIX}FEATURE_NA... | getName | java | togglz/togglz | microprofile-config/src/main/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategy.java | https://github.com/togglz/togglz/blob/master/microprofile-config/src/main/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategy.java | Apache-2.0 |
@Override
protected String getPropertyValue(FeatureState featureState, FeatureUser user, String name) {
Config config = ConfigProvider.getConfig();
return config.getOptionalValue(name, String.class).orElse(null);
} | <p>
An activation strategy based on the values of properties accessible within the MicroProfile Config.
</p>
<p>
It can either be based on a given property name, passed via the "{@value #PARAM_NAME}" parameter, or a property name
derived from the {@link Feature} itself (e.g. "{@value #DEFAULT_PROPERTY_PREFIX}FEATURE_NA... | getPropertyValue | java | togglz/togglz | microprofile-config/src/main/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategy.java | https://github.com/togglz/togglz/blob/master/microprofile-config/src/main/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategy.java | Apache-2.0 |
@Override
public Iterable<ConfigSource> getConfigSources(ClassLoader classLoader) {
return singleton(TestConfigSource.INSTANCE);
} | A test config source provider for MicroProfile Config | getConfigSources | java | togglz/togglz | microprofile-config/src/test/java/org/togglz/microprofile/TestConfigSourceProvider.java | https://github.com/togglz/togglz/blob/master/microprofile-config/src/test/java/org/togglz/microprofile/TestConfigSourceProvider.java | Apache-2.0 |
@Override
public Map<String, String> getProperties() {
return properties;
} | A test config source provider for MicroProfile Config | getProperties | java | togglz/togglz | microprofile-config/src/test/java/org/togglz/microprofile/TestConfigSourceProvider.java | https://github.com/togglz/togglz/blob/master/microprofile-config/src/test/java/org/togglz/microprofile/TestConfigSourceProvider.java | Apache-2.0 |
@Override
public String getValue(String name) {
return properties.get(name);
} | A test config source provider for MicroProfile Config | getValue | java | togglz/togglz | microprofile-config/src/test/java/org/togglz/microprofile/TestConfigSourceProvider.java | https://github.com/togglz/togglz/blob/master/microprofile-config/src/test/java/org/togglz/microprofile/TestConfigSourceProvider.java | Apache-2.0 |
@Override
public String getName() {
return "microprofile-config-test-source";
} | A test config source provider for MicroProfile Config | getName | java | togglz/togglz | microprofile-config/src/test/java/org/togglz/microprofile/TestConfigSourceProvider.java | https://github.com/togglz/togglz/blob/master/microprofile-config/src/test/java/org/togglz/microprofile/TestConfigSourceProvider.java | Apache-2.0 |
public void putProperty(String key, String value) {
properties.put(key, value);
} | A test config source provider for MicroProfile Config | putProperty | java | togglz/togglz | microprofile-config/src/test/java/org/togglz/microprofile/TestConfigSourceProvider.java | https://github.com/togglz/togglz/blob/master/microprofile-config/src/test/java/org/togglz/microprofile/TestConfigSourceProvider.java | Apache-2.0 |
@BeforeEach
void setUp() {
strategy = new MicroProfileConfigActivationStrategy();
} | <p>
Tests for the {@link MicroProfileConfigActivationStrategy} class.
</p>
@author John D. Ament, Alasdair Mercer | setUp | java | togglz/togglz | microprofile-config/src/test/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/microprofile-config/src/test/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategyTest.java | Apache-2.0 |
@AfterEach
void tearDown() {
TestConfigSourceProvider.TestConfigSource.INSTANCE.clearProperties();
} | <p>
Tests for the {@link MicroProfileConfigActivationStrategy} class.
</p>
@author John D. Ament, Alasdair Mercer | tearDown | java | togglz/togglz | microprofile-config/src/test/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/microprofile-config/src/test/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategyTest.java | Apache-2.0 |
@Test
void shouldHaveSameActivationStrategyId() {
assertEquals(MicroProfileConfigActivationStrategy.ID, strategy.getId());
} | <p>
Tests for the {@link MicroProfileConfigActivationStrategy} class.
</p>
@author John D. Ament, Alasdair Mercer | shouldHaveSameActivationStrategyId | java | togglz/togglz | microprofile-config/src/test/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/microprofile-config/src/test/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategyTest.java | Apache-2.0 |
@Test
void strategyNameShouldNotBeBlankByDefault() {
assertTrue(Strings.isNotBlank(strategy.getName()));
} | <p>
Tests for the {@link MicroProfileConfigActivationStrategy} class.
</p>
@author John D. Ament, Alasdair Mercer | strategyNameShouldNotBeBlankByDefault | java | togglz/togglz | microprofile-config/src/test/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/microprofile-config/src/test/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategyTest.java | Apache-2.0 |
@ParameterizedTest
@ValueSource(booleans = { true, false })
void isActiveWithNoParam(boolean enabled) {
FeatureState featureState = new FeatureState(TestFeatures.FEATURE_ONE, !enabled);
TestConfigSourceProvider.TestConfigSource.INSTANCE.putProperty("togglz.FEATURE_ONE", String.valueOf(enabled))... | <p>
Tests for the {@link MicroProfileConfigActivationStrategy} class.
</p>
@author John D. Ament, Alasdair Mercer | isActiveWithNoParam | java | togglz/togglz | microprofile-config/src/test/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/microprofile-config/src/test/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategyTest.java | Apache-2.0 |
@ParameterizedTest
@ValueSource(booleans = { true, false })
void isActiveWithParam(boolean enabled) {
String paramValue = "foo";
FeatureState featureState = new FeatureState(TestFeatures.FEATURE_ONE, !enabled);
featureState.setParameter(MicroProfileConfigActivationStrategy.PARAM_NAME, pa... | <p>
Tests for the {@link MicroProfileConfigActivationStrategy} class.
</p>
@author John D. Ament, Alasdair Mercer | isActiveWithParam | java | togglz/togglz | microprofile-config/src/test/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/microprofile-config/src/test/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategyTest.java | Apache-2.0 |
@Test
void getParameters() {
Parameter[] parameters = strategy.getParameters();
assertEquals(2, parameters.length);
Parameter parameter = parameters[0];
assertNotNull(parameter);
assertEquals(AbstractPropertyDrivenActivationStrategy.PARAM_NAME, parameter.getName());
... | <p>
Tests for the {@link MicroProfileConfigActivationStrategy} class.
</p>
@author John D. Ament, Alasdair Mercer | getParameters | java | togglz/togglz | microprofile-config/src/test/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/microprofile-config/src/test/java/org/togglz/microprofile/activation/MicroProfileConfigActivationStrategyTest.java | Apache-2.0 |
@Override
public FeatureState getFeatureState(Feature feature) {
Document result = (Document) togglzCollection().find(queryFor(feature)).first();
if (result != null) {
FeatureState state = new FeatureState(feature);
boolean enabledValue = result.getBoolean(FIELD_ENABLED, ... | <p>
A state repository which stores the feature state in a MongoDB database.
</p>
<p>
The class provides a builder which can be used to configure the repository:
</p>
<pre>
StateRepository repository = MongoStateRepository
.newBuilder(mongoClient, "mydb")
.collection("togglz")
.writeCo... | getFeatureState | java | togglz/togglz | mongodb/src/main/java/org/togglz/mongodb/MongoStateRepository.java | https://github.com/togglz/togglz/blob/master/mongodb/src/main/java/org/togglz/mongodb/MongoStateRepository.java | Apache-2.0 |
@Override
public void setFeatureState(FeatureState featureState) {
Document featureStateDocument = new Document()
.append(FIELD_FEATURE, featureState.getFeature().name())
.append(FIELD_ENABLED, featureState.isEnabled());
if (featureState.getStrategyId() != null) {
... | <p>
A state repository which stores the feature state in a MongoDB database.
</p>
<p>
The class provides a builder which can be used to configure the repository:
</p>
<pre>
StateRepository repository = MongoStateRepository
.newBuilder(mongoClient, "mydb")
.collection("togglz")
.writeCo... | setFeatureState | java | togglz/togglz | mongodb/src/main/java/org/togglz/mongodb/MongoStateRepository.java | https://github.com/togglz/togglz/blob/master/mongodb/src/main/java/org/togglz/mongodb/MongoStateRepository.java | Apache-2.0 |
protected Document queryFor(Feature feature) {
return new Document(FIELD_FEATURE, feature.name());
} | <p>
A state repository which stores the feature state in a MongoDB database.
</p>
<p>
The class provides a builder which can be used to configure the repository:
</p>
<pre>
StateRepository repository = MongoStateRepository
.newBuilder(mongoClient, "mydb")
.collection("togglz")
.writeCo... | queryFor | java | togglz/togglz | mongodb/src/main/java/org/togglz/mongodb/MongoStateRepository.java | https://github.com/togglz/togglz/blob/master/mongodb/src/main/java/org/togglz/mongodb/MongoStateRepository.java | Apache-2.0 |
protected MongoCollection togglzCollection() {
MongoDatabase db = mongoClient.getDatabase(dbname);
return db.getCollection(collection).withWriteConcern(writeConcern);
} | <p>
A state repository which stores the feature state in a MongoDB database.
</p>
<p>
The class provides a builder which can be used to configure the repository:
</p>
<pre>
StateRepository repository = MongoStateRepository
.newBuilder(mongoClient, "mydb")
.collection("togglz")
.writeCo... | togglzCollection | java | togglz/togglz | mongodb/src/main/java/org/togglz/mongodb/MongoStateRepository.java | https://github.com/togglz/togglz/blob/master/mongodb/src/main/java/org/togglz/mongodb/MongoStateRepository.java | Apache-2.0 |
public static Builder newBuilder(MongoClient client, String dbname) {
return new Builder(client, dbname);
} | Creates a new builder for creating a {@link MongoStateRepository}.
@param client the client instance to use for connecting to MongoDB
@param dbname the database name used for storing features state. | newBuilder | java | togglz/togglz | mongodb/src/main/java/org/togglz/mongodb/MongoStateRepository.java | https://github.com/togglz/togglz/blob/master/mongodb/src/main/java/org/togglz/mongodb/MongoStateRepository.java | Apache-2.0 |
public Builder collection(String collection) {
this.collection = collection;
return this;
} | The name of the collection used by the repository to store the feature state. The default is <code>togglz</code>.
@param collection The name of the collection to use | collection | java | togglz/togglz | mongodb/src/main/java/org/togglz/mongodb/MongoStateRepository.java | https://github.com/togglz/togglz/blob/master/mongodb/src/main/java/org/togglz/mongodb/MongoStateRepository.java | Apache-2.0 |
public Builder writeConcern(WriteConcern writeConcern) {
this.writeConcern = writeConcern;
return this;
} | The {@link WriteConcern} used when accessing the database. By default <code>ACKNOWLEDGED</code> will be used.
@param writeConcern The {@link WriteConcern} to use | writeConcern | java | togglz/togglz | mongodb/src/main/java/org/togglz/mongodb/MongoStateRepository.java | https://github.com/togglz/togglz/blob/master/mongodb/src/main/java/org/togglz/mongodb/MongoStateRepository.java | Apache-2.0 |
public MongoStateRepository build() {
return new MongoStateRepository(this);
} | Creates a new {@link MongoStateRepository} using the current settings. | build | java | togglz/togglz | mongodb/src/main/java/org/togglz/mongodb/MongoStateRepository.java | https://github.com/togglz/togglz/blob/master/mongodb/src/main/java/org/togglz/mongodb/MongoStateRepository.java | Apache-2.0 |
@Override
public FeatureState getFeatureState(final Feature feature) {
try (final StatefulConnection<String, String> connection = pool.borrowObject()) {
final RedisHashCommands<String, String> commands = getCommands(connection);
final Map<String, String> redisMap = commands.hgetall(k... | A state repository which stores the feature state in Redis using Lettuce client.
<p>
The class provides a builder which can be used to configure the state repository instance
(e.g. StatefulConnection pool, key prefix).
</p>
<p>
A state repository is able to work in standalone mode (using StatefulRedisConnection) and
cl... | getFeatureState | java | togglz/togglz | redis/src/main/java/org/togglz/redis/RedisLettuceStateRepository.java | https://github.com/togglz/togglz/blob/master/redis/src/main/java/org/togglz/redis/RedisLettuceStateRepository.java | Apache-2.0 |
@Override
public void setFeatureState(final FeatureState featureState) {
try (final StatefulConnection<String, String> connection = pool.borrowObject()) {
final RedisHashCommands<String, String> commands = getCommands(connection);
final String featureKey = keyPrefix + featureState.ge... | A state repository which stores the feature state in Redis using Lettuce client.
<p>
The class provides a builder which can be used to configure the state repository instance
(e.g. StatefulConnection pool, key prefix).
</p>
<p>
A state repository is able to work in standalone mode (using StatefulRedisConnection) and
cl... | setFeatureState | java | togglz/togglz | redis/src/main/java/org/togglz/redis/RedisLettuceStateRepository.java | https://github.com/togglz/togglz/blob/master/redis/src/main/java/org/togglz/redis/RedisLettuceStateRepository.java | Apache-2.0 |
private RedisHashCommands<String, String> getCommands(final StatefulConnection<String, String> connection) {
if (connection instanceof StatefulRedisConnection) {
return ((StatefulRedisConnection) connection).sync();
}
return ((StatefulRedisClusterConnection) connection).sync();
... | A state repository which stores the feature state in Redis using Lettuce client.
<p>
The class provides a builder which can be used to configure the state repository instance
(e.g. StatefulConnection pool, key prefix).
</p>
<p>
A state repository is able to work in standalone mode (using StatefulRedisConnection) and
cl... | getCommands | java | togglz/togglz | redis/src/main/java/org/togglz/redis/RedisLettuceStateRepository.java | https://github.com/togglz/togglz/blob/master/redis/src/main/java/org/togglz/redis/RedisLettuceStateRepository.java | Apache-2.0 |
public Builder lettucePool(final GenericObjectPool<StatefulConnection<String, String>> lettucePool) {
this.lettucePool = lettucePool;
return this;
} | Sets the Lettuce Pool.
@param lettucePool the Lettuce Pool {@link GenericObjectPool} | lettucePool | java | togglz/togglz | redis/src/main/java/org/togglz/redis/RedisLettuceStateRepository.java | https://github.com/togglz/togglz/blob/master/redis/src/main/java/org/togglz/redis/RedisLettuceStateRepository.java | Apache-2.0 |
public Builder keyPrefix(final String keyPrefix) {
this.keyPrefix = keyPrefix;
return this;
} | Sets the Redis key prefix to be used when getting or setting the state of the features.
@param keyPrefix the key prefix to be used in Redis | keyPrefix | java | togglz/togglz | redis/src/main/java/org/togglz/redis/RedisLettuceStateRepository.java | https://github.com/togglz/togglz/blob/master/redis/src/main/java/org/togglz/redis/RedisLettuceStateRepository.java | Apache-2.0 |
public RedisLettuceStateRepository build() {
return new RedisLettuceStateRepository(this);
} | Creates a new {@link RedisLettuceStateRepository} using the current settings. | build | java | togglz/togglz | redis/src/main/java/org/togglz/redis/RedisLettuceStateRepository.java | https://github.com/togglz/togglz/blob/master/redis/src/main/java/org/togglz/redis/RedisLettuceStateRepository.java | Apache-2.0 |
@Override
public FeatureState getFeatureState(final Feature feature) {
try (final Jedis jedis = jedisPool.getResource()) {
final Map<String, String> redisMap = jedis.hgetAll(keyPrefix + feature.name());
if (redisMap == null || redisMap.size() == 0) {
return null;
... | A state repository which stores the feature state in Redis.
<p>
The class provides a builder which can be used to configure the state repository instance
(e.g. Redis hostname, Redis/Jedis configuration, serialization).
</p>
@author Cosmin Rentea | getFeatureState | java | togglz/togglz | redis/src/main/java/org/togglz/redis/RedisStateRepository.java | https://github.com/togglz/togglz/blob/master/redis/src/main/java/org/togglz/redis/RedisStateRepository.java | Apache-2.0 |
@Override
public void setFeatureState(final FeatureState featureState) {
try (final Jedis jedis = jedisPool.getResource()) {
final String featureKey = keyPrefix + featureState.getFeature().name();
jedis.hset(featureKey, ENABLED_FIELD, Boolean.toString(featureState.isEnabled()));
... | A state repository which stores the feature state in Redis.
<p>
The class provides a builder which can be used to configure the state repository instance
(e.g. Redis hostname, Redis/Jedis configuration, serialization).
</p>
@author Cosmin Rentea | setFeatureState | java | togglz/togglz | redis/src/main/java/org/togglz/redis/RedisStateRepository.java | https://github.com/togglz/togglz/blob/master/redis/src/main/java/org/togglz/redis/RedisStateRepository.java | Apache-2.0 |
public Builder jedisPool(final Pool<Jedis> jedisPool) {
this.jedisPool = jedisPool;
return this;
} | Sets the Jedis Pool.
@param jedisPool the Jedis Pool {@link JedisPool} | jedisPool | java | togglz/togglz | redis/src/main/java/org/togglz/redis/RedisStateRepository.java | https://github.com/togglz/togglz/blob/master/redis/src/main/java/org/togglz/redis/RedisStateRepository.java | Apache-2.0 |
public Builder keyPrefix(final String keyPrefix) {
this.keyPrefix = keyPrefix;
return this;
} | Sets the Redis key prefix to be used when getting or setting the state of the features.
@param keyPrefix the key prefix to be used in Redis | keyPrefix | java | togglz/togglz | redis/src/main/java/org/togglz/redis/RedisStateRepository.java | https://github.com/togglz/togglz/blob/master/redis/src/main/java/org/togglz/redis/RedisStateRepository.java | Apache-2.0 |
public RedisStateRepository build() {
return new RedisStateRepository(this);
} | Creates a new {@link RedisStateRepository} using the current settings. | build | java | togglz/togglz | redis/src/main/java/org/togglz/redis/RedisStateRepository.java | https://github.com/togglz/togglz/blob/master/redis/src/main/java/org/togglz/redis/RedisStateRepository.java | Apache-2.0 |
public void begin(HttpServletRequest request, HttpServletResponse response) {
for (RequestListener listener : listeners) {
try {
listener.begin(request, response);
} catch (Exception e) {
log.error("Failed to execute RequestListener", e);
}
... | This class is used by {@link TogglzFilter} to notify {@link RequestListener} implementation about requests. This class tries
to ensure that all listeners will receive the notifies, even if one of the listeners fails with a {@link RuntimeException}.
@author Christian Kaltepoth | begin | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/CompositeRequestListener.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/CompositeRequestListener.java | Apache-2.0 |
public void end(HttpServletRequest request, HttpServletResponse response) {
for (RequestListener listener : listeners) {
try {
listener.end(request, response);
} catch (Exception e) {
log.error("Failed to execute RequestListener", e);
}
... | This class is used by {@link TogglzFilter} to notify {@link RequestListener} implementation about requests. This class tries
to ensure that all listeners will receive the notifies, even if one of the listeners fails with a {@link RuntimeException}.
@author Christian Kaltepoth | end | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/CompositeRequestListener.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/CompositeRequestListener.java | Apache-2.0 |
public void init(FilterConfig filterConfig) {
// build the configuration object
TogglzFilterConfig config = new TogglzFilterConfig(filterConfig.getServletContext());
requestListener = new CompositeRequestListener(Services.getSorted(RequestListener.class));
// did the user specify whet... | This filter is the central component of the Togglz Servlet integration module. It is responsible to bootstrap the
{@link FeatureManager} and register it with {@link ContextClassLoaderFeatureManagerProvider}.
@author Christian Kaltepoth | init | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/TogglzFilter.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/TogglzFilter.java | Apache-2.0 |
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
throws IOException, ServletException {
if (Boolean.TRUE.equals(req.getAttribute(EXECUTED))) {
chain.doFilter(req, resp);
} else {
req.setAttribute(EXECUTED, Boolean.TRUE);
H... | This filter is the central component of the Togglz Servlet integration module. It is responsible to bootstrap the
{@link FeatureManager} and register it with {@link ContextClassLoaderFeatureManagerProvider}.
@author Christian Kaltepoth | doFilter | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/TogglzFilter.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/TogglzFilter.java | Apache-2.0 |
public void destroy() {
// release only if the filter created it
if (bootstrappedFeatureManager != null) {
// notify listeners about the shutdown
for (FeatureManagerListener listener : Services.getSorted(FeatureManagerListener.class)) {
listener.stop(bootstrappe... | This filter is the central component of the Togglz Servlet integration module. It is responsible to bootstrap the
{@link FeatureManager} and register it with {@link ContextClassLoaderFeatureManagerProvider}.
@author Christian Kaltepoth | destroy | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/TogglzFilter.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/TogglzFilter.java | Apache-2.0 |
public Boolean isPerformBootstrap() {
String managerProvided = servletContext.getInitParameter("org.togglz.FEATURE_MANAGER_PROVIDED");
if (managerProvided != null) {
return !toBool(managerProvided);
}
return null;
} | Returns <code>true</code> if the filter should perform the bootstrapping process. Returns <code>null</code> if the user
didn't specify what to do. | isPerformBootstrap | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/TogglzFilterConfig.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/TogglzFilterConfig.java | Apache-2.0 |
private static boolean toBool(String value) {
if (value != null && "true".equalsIgnoreCase(value.trim())) {
return true;
}
if (value != null && "false".equalsIgnoreCase(value.trim())) {
return false;
}
throw new IllegalArgumentException("Not a valid boolea... | Returns <code>true</code> if the filter should perform the bootstrapping process. Returns <code>null</code> if the user
didn't specify what to do. | toBool | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/TogglzFilterConfig.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/TogglzFilterConfig.java | Apache-2.0 |
private void calculate() throws UnknownHostException {
ByteBuffer maskBuffer;
int targetSize;
if (inetAddress.getAddress().length == 4) {
maskBuffer =
ByteBuffer
.allocate(4)
.putInt(-1);
targetSi... | A class that enables to get an IP range from CIDR specification. It supports
both IPv4 and IPv6. | calculate | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/activation/CIDRUtils.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/activation/CIDRUtils.java | Apache-2.0 |
private byte[] toBytes(byte[] array, int targetSize) {
int counter = 0;
List<Byte> newArr = new ArrayList<>();
while (counter < targetSize && (array.length - 1 - counter >= 0)) {
newArr.add(0, array[array.length - 1 - counter]);
counter++;
}
int size = ne... | A class that enables to get an IP range from CIDR specification. It supports
both IPv4 and IPv6. | toBytes | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/activation/CIDRUtils.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/activation/CIDRUtils.java | Apache-2.0 |
public boolean isInRange(InetAddress address) throws UnknownHostException {
BigInteger start = new BigInteger(1, this.startAddress.getAddress());
BigInteger end = new BigInteger(1, this.endAddress.getAddress());
BigInteger target = new BigInteger(1, address.getAddress());
int st = start... | A class that enables to get an IP range from CIDR specification. It supports
both IPv4 and IPv6. | isInRange | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/activation/CIDRUtils.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/activation/CIDRUtils.java | Apache-2.0 |
@Override
public String getId() {
return ID;
} | Activation strategy that will use the IP address of the client to decide if a feature is active or not.
@author Christian Kaltepoth | getId | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | Apache-2.0 |
@Override
public String getName() {
return "IP address (client)";
} | Activation strategy that will use the IP address of the client to decide if a feature is active or not.
@author Christian Kaltepoth | getName | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | Apache-2.0 |
@Override
public boolean isActive(FeatureState featureState, FeatureUser user) {
HttpServletRequest request = HttpServletRequestHolder.get();
if (request != null) {
List<String> parts = Strings.splitAndTrim(featureState.getParameter(PARAM_IPS), "[\\s,]+");
try {
... | Activation strategy that will use the IP address of the client to decide if a feature is active or not.
@author Christian Kaltepoth | isActive | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | Apache-2.0 |
@Override
public Parameter[] getParameters() {
return new Parameter[]{new AddressParameter()};
} | Activation strategy that will use the IP address of the client to decide if a feature is active or not.
@author Christian Kaltepoth | getParameters | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | Apache-2.0 |
@Override
public String getName() {
return PARAM_IPS;
} | Activation strategy that will use the IP address of the client to decide if a feature is active or not.
@author Christian Kaltepoth | getName | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | Apache-2.0 |
@Override
public String getLabel() {
return "Client IPs";
} | Activation strategy that will use the IP address of the client to decide if a feature is active or not.
@author Christian Kaltepoth | getLabel | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | Apache-2.0 |
@Override
public String getDescription() {
return "A comma-separated list of client IPs or address ranges in CIDR notation (e.g. 10.1.2.0/24) for which the feature should be active.";
} | Activation strategy that will use the IP address of the client to decide if a feature is active or not.
@author Christian Kaltepoth | getDescription | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | Apache-2.0 |
@Override
public boolean isOptional() {
return false;
} | Activation strategy that will use the IP address of the client to decide if a feature is active or not.
@author Christian Kaltepoth | isOptional | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | Apache-2.0 |
@Override
public boolean isLargeText() {
return false;
} | Activation strategy that will use the IP address of the client to decide if a feature is active or not.
@author Christian Kaltepoth | isLargeText | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | Apache-2.0 |
@Override
public boolean isValid(String addresses) {
if (Strings.isBlank(addresses)) {
return false;
}
List<String> addressList = Strings.splitAndTrim(addresses, ",");
for (String address : addressList) {
if (address.contains("/")... | Activation strategy that will use the IP address of the client to decide if a feature is active or not.
@author Christian Kaltepoth | isValid | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/activation/ClientIpActivationStrategy.java | Apache-2.0 |
@Override
@SuppressWarnings("unchecked")
public <E> Collection<E> find(Class<E> clazz, Object context) {
if (context instanceof ServletContext servletContext) {
String implClassName = servletContext.getInitParameter(clazz.getName());
if (implClassName != null && implClassName.tri... | This implementation of {@link BeanFinder} allows to register implementations of a given interface by setting a servlet
context parameter. See the following configuration for an example how to register the implementation of {@link TogglzConfig}
so that this class is able to find it.
<pre>
<context-param>
&l... | find | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/spi/ServletContextBeanFinder.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/spi/ServletContextBeanFinder.java | Apache-2.0 |
@SuppressWarnings("unchecked")
static <T> T createInstance(String classname, Class<T> interfaceClazz) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = interfaceClazz.getClassLoader();
}
try {
... | This implementation of {@link BeanFinder} allows to register implementations of a given interface by setting a servlet
context parameter. See the following configuration for an example how to register the implementation of {@link TogglzConfig}
so that this class is able to find it.
<pre>
<context-param>
&l... | createInstance | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/spi/ServletContextBeanFinder.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/spi/ServletContextBeanFinder.java | Apache-2.0 |
@Override
public FeatureUser getCurrentUser() {
HttpServletRequest request = HttpServletRequestHolder.get();
if (request == null) {
throw new IllegalStateException(
"Could not get request from HttpServletRequestHolder. Did you configure the TogglzFilter correctly?");... | This constructor requires you to supply the name of the role that identifies users to be feature admins.
@param featureAdminRole the feature admin role name | getCurrentUser | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/user/ServletUserProvider.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/user/ServletUserProvider.java | Apache-2.0 |
public static void bind(HttpServletRequest request) {
if (request != null && threadLocal.get() != null) {
throw new IllegalStateException("HttpServletRequestHolder.bind() called for a "
+ "thread that already has a request associated with it. It's likely that the request "
... | Associate the request with the current thread. | bind | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/util/HttpServletRequestHolder.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/util/HttpServletRequestHolder.java | Apache-2.0 |
public static HttpServletRequest get() {
return threadLocal.get();
} | Remove the request that is currently associated with the current thread. | get | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/util/HttpServletRequestHolder.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/util/HttpServletRequestHolder.java | Apache-2.0 |
@Override
public int priority() {
return 10;
} | Implementation of {@link RequestListener} that is responsible for binding and releasing the current request for
{@link HttpServletRequestHolder}.
@author Christian Kaltepoth | priority | java | togglz/togglz | servlet/src/main/java/org/togglz/servlet/util/HttpServletRequestHolderListener.java | https://github.com/togglz/togglz/blob/master/servlet/src/main/java/org/togglz/servlet/util/HttpServletRequestHolderListener.java | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.