From a72cec5f107a59dfe8ec9a308157289097aa53af Mon Sep 17 00:00:00 2001 From: eugenp Date: Sun, 11 Aug 2013 13:37:48 +0300 Subject: [PATCH] cleanup work after metrics no longer needed in custom project --- spring-security-mvc-custom/README.md | 1 - spring-security-mvc-custom/pom.xml | 12 +++--- .../monitoring/MetricRegistrySingleton.java | 25 ----------- .../web/SessionListenerWithMetrics.java | 43 ------------------- .../src/main/webapp/WEB-INF/web.xml | 3 -- spring-security-mvc-session/README.md | 2 - 6 files changed, 6 insertions(+), 80 deletions(-) delete mode 100644 spring-security-mvc-custom/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java delete mode 100644 spring-security-mvc-custom/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java diff --git a/spring-security-mvc-custom/README.md b/spring-security-mvc-custom/README.md index 53bdac770c..17f32e4a2f 100644 --- a/spring-security-mvc-custom/README.md +++ b/spring-security-mvc-custom/README.md @@ -6,7 +6,6 @@ ### Relevant Articles: - [Spring Security Remember Me](http://www.baeldung.com/spring-security-remember-me) - [Redirect to different pages after Login with Spring Security](http://www.baeldung.com/spring_redirect_after_login) -- [HttpSessionListener Example – Monitoring](http://www.baeldung.com/httpsessionlistener_with_metrics) ### Build the Project diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 7d7588cd19..8678b91ec8 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -93,12 +93,12 @@ - - - com.codahale.metrics - metrics-core - 3.0.1 - + + + + + + diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java b/spring-security-mvc-custom/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java deleted file mode 100644 index ed253305ed..0000000000 --- a/spring-security-mvc-custom/src/main/java/org/baeldung/monitoring/MetricRegistrySingleton.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.baeldung.monitoring; - -import java.util.concurrent.TimeUnit; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.codahale.metrics.MetricRegistry; -import com.codahale.metrics.Slf4jReporter; - -public final class MetricRegistrySingleton { - - public static final MetricRegistry metrics = new MetricRegistry(); - - static { - Logger logger = LoggerFactory.getLogger("org.baeldung.monitoring"); - final Slf4jReporter reporter = Slf4jReporter.forRegistry(metrics).outputTo(logger).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build(); - reporter.start(5, TimeUnit.MINUTES); - } - - private MetricRegistrySingleton() { - throw new AssertionError(); - } - -} diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java b/spring-security-mvc-custom/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java deleted file mode 100644 index 46bf2708f7..0000000000 --- a/spring-security-mvc-custom/src/main/java/org/baeldung/web/SessionListenerWithMetrics.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.baeldung.web; - -import java.util.concurrent.atomic.AtomicInteger; - -import javax.servlet.http.HttpSessionEvent; -import javax.servlet.http.HttpSessionListener; - -import org.baeldung.monitoring.MetricRegistrySingleton; - -import com.codahale.metrics.Counter; - -public class SessionListenerWithMetrics implements HttpSessionListener { - - private final AtomicInteger activeSessions; - - private final Counter counterOfActiveSessions; - - public SessionListenerWithMetrics() { - super(); - - activeSessions = new AtomicInteger(); - counterOfActiveSessions = MetricRegistrySingleton.metrics.counter("web.sessions.active.count"); - } - - // API - - public final int getTotalActiveSession() { - return activeSessions.get(); - } - - @Override - public final void sessionCreated(final HttpSessionEvent event) { - activeSessions.incrementAndGet(); - counterOfActiveSessions.inc(); - } - - @Override - public final void sessionDestroyed(final HttpSessionEvent event) { - activeSessions.decrementAndGet(); - counterOfActiveSessions.dec(); - } - -} \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml b/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml index bf691dc491..ff61eb229b 100644 --- a/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-mvc-custom/src/main/webapp/WEB-INF/web.xml @@ -9,9 +9,6 @@ 1 - - org.baeldung.web.SessionListenerWithMetrics - diff --git a/spring-security-mvc-session/README.md b/spring-security-mvc-session/README.md index 53bdac770c..840a1e0a3b 100644 --- a/spring-security-mvc-session/README.md +++ b/spring-security-mvc-session/README.md @@ -4,8 +4,6 @@ ### Relevant Articles: -- [Spring Security Remember Me](http://www.baeldung.com/spring-security-remember-me) -- [Redirect to different pages after Login with Spring Security](http://www.baeldung.com/spring_redirect_after_login) - [HttpSessionListener Example – Monitoring](http://www.baeldung.com/httpsessionlistener_with_metrics)