Skip to content

Commit 21295e6

Browse files
committed
modify feature toggle
1 parent 9eef07c commit 21295e6

7 files changed

Lines changed: 12 additions & 56 deletions

File tree

‎spring-security-oauth/pom.xml‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,6 @@
186186
<version>${guava.version}</version>
187187
</dependency>
188188

189-
<dependency>
190-
<groupId>org.togglz</groupId>
191-
<artifactId>togglz-spring</artifactId>
192-
<version>2.1.0.Final</version>
193-
</dependency>
194-
195189
<!-- logging -->
196190

197191
<dependency>

‎spring-security-oauth/src/main/java/org/baeldung/config/FeatureToggleConfig.java‎

Lines changed: 0 additions & 37 deletions
This file was deleted.

‎spring-security-oauth/src/main/java/org/baeldung/config/ServletInitializer.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class ServletInitializer extends AbstractDispatcherServletInitializer {
1313
@Override
1414
protected WebApplicationContext createServletApplicationContext() {
1515
final AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
16-
context.register(PersistenceJPAConfig.class, WebConfig.class, SecurityConfig.class, FeatureToggleConfig.class);
16+
context.register(PersistenceJPAConfig.class, WebConfig.class, SecurityConfig.class);
1717
return context;
1818
}
1919

@@ -30,7 +30,6 @@ protected WebApplicationContext createRootApplicationContext() {
3030
@Override
3131
public void onStartup(ServletContext servletContext) throws ServletException {
3232
super.onStartup(servletContext);
33-
3433
servletContext.addListener(new SessionListener());
3534
registerProxyFilter(servletContext, "oauth2ClientContextFilter");
3635
registerProxyFilter(servletContext, "springSecurityFilterChain");

‎spring-security-oauth/src/main/java/org/baeldung/config/SessionListener.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import javax.servlet.http.HttpSessionEvent;
44
import javax.servlet.http.HttpSessionListener;
55

6+
import org.baeldung.reddit.util.MyFeatures;
67
import org.slf4j.Logger;
78
import org.slf4j.LoggerFactory;
89

@@ -13,6 +14,7 @@ public class SessionListener implements HttpSessionListener {
1314
public void sessionCreated(HttpSessionEvent event) {
1415
logger.info("==== Session is created ====");
1516
event.getSession().setMaxInactiveInterval(30 * 60);
17+
event.getSession().setAttribute("PREDICTION_FEATURE", MyFeatures.PREDICTION_FEATURE);
1618
}
1719

1820
@Override
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
package org.baeldung.reddit.util;
22

3-
import org.togglz.core.Feature;
4-
import org.togglz.core.annotation.EnabledByDefault;
5-
import org.togglz.core.annotation.Label;
6-
import org.togglz.core.context.FeatureContext;
3+
public enum MyFeatures {
74

8-
public enum MyFeatures implements Feature {
5+
PREDICTION_FEATURE(false);
96

10-
@EnabledByDefault
11-
@Label("Prediction feature")
12-
PREDICTION_FEATURE;
7+
private boolean active;
8+
9+
private MyFeatures(boolean active) {
10+
this.active = active;
11+
}
1312

1413
public boolean isActive() {
15-
return FeatureContext.getFeatureManager().isActive(this);
14+
return this.active;
1615
}
1716

1817
}

‎spring-security-oauth/src/main/resources/features.properties‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎spring-security-oauth/src/main/webapp/WEB-INF/jsp/submissionForm.jsp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ border-color: #ddd;
8080
</div>
8181
</form>
8282
<div>
83-
<c:if test="MyFeatures.PREDICTION_FEATURE.isActive()">
83+
<c:if test="${PREDICTION_FEATURE.isActive()}">
8484
<button id="checkbtn" class="btn btn-default disabled" onclick="predicateResponse()">Predicate Response</button>
8585
<span id="prediction"></span>
8686

0 commit comments

Comments
 (0)