forked from apache/incubator-kie-kogito-runtimes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inserting feature toggle for spring apis
- Loading branch information
1 parent
f8894b9
commit 17e4a01
Showing
10 changed files
with
114 additions
and
14 deletions.
There are no files selected for viewing
2 changes: 0 additions & 2 deletions
2
api/kogito-api/src/main/java/org/kie/kogito/conf/FeatureToggle.java
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
api/kogito-api/src/main/java/org/kie/kogito/conf/feature/DefaultFeatureToggleManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.kie.kogito.conf.feature; | ||
|
||
/** | ||
* Default implementation of the {@link FeatureToggleManager} based on system properties. | ||
*/ | ||
public class DefaultFeatureToggleManager implements FeatureToggleManager { | ||
|
||
@Override | ||
public boolean isEnabled(String featureKey) { | ||
return Boolean.parseBoolean(System.getProperty(featureKey, Boolean.FALSE.toString())); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
api/kogito-api/src/main/java/org/kie/kogito/conf/feature/FeatureToggle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.kie.kogito.conf.feature; | ||
|
||
/** | ||
* Centralize the features under development or not completed to be released, that could be enabled or disabled during | ||
* runtime or build time. After the features are completed, the toggle could be removed along with the code checking | ||
* this feature. | ||
* Using this class make things easier to track the features in different points of code facilitating the removal of | ||
* them. | ||
*/ | ||
public class FeatureToggle { | ||
|
||
public static final String ENDPOINTS_SPRING_API_ENABLED = "endpoints.spring.api.enabled"; | ||
|
||
private final FeatureToggleManager manager; | ||
|
||
public FeatureToggle() { | ||
this(new DefaultFeatureToggleManager()); | ||
} | ||
|
||
public FeatureToggle(FeatureToggleManager manager) { | ||
this.manager = manager; | ||
} | ||
|
||
public boolean isEnabled(String featureKey){ | ||
return manager.isEnabled(featureKey); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
api/kogito-api/src/main/java/org/kie/kogito/conf/feature/FeatureToggleManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.kie.kogito.conf.feature; | ||
|
||
public interface FeatureToggleManager { | ||
|
||
boolean isEnabled(String featureKey); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters