[logback-dev] svn commit: r939 - logback/trunk/logback-access/src/main/java/ch/qos/logback/access/filter
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Fri Nov 17 12:27:06 CET 2006
Author: ceki
Date: Fri Nov 17 12:27:06 2006
New Revision: 939
Added:
logback/trunk/logback-access/src/main/java/ch/qos/logback/access/filter/AccessStats.java
logback/trunk/logback-access/src/main/java/ch/qos/logback/access/filter/AccessStatsImpl.java
logback/trunk/logback-access/src/main/java/ch/qos/logback/access/filter/CountingFilter.java
Log:
ongoing work
Added: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/filter/AccessStats.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/filter/AccessStats.java Fri Nov 17 12:27:06 2006
@@ -0,0 +1,18 @@
+package ch.qos.logback.access.filter;
+
+public interface AccessStats {
+
+
+ long getTotal();
+
+ long getDailyTotal();
+ long getDailyAverage();
+
+
+ long getWeeklyTotal();
+ long getWeeklyAverage();
+
+ long getMonthlyTotal();
+ long getMonthlyAverage();
+
+}
Added: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/filter/AccessStatsImpl.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/filter/AccessStatsImpl.java Fri Nov 17 12:27:06 2006
@@ -0,0 +1,45 @@
+package ch.qos.logback.access.filter;
+
+public class AccessStatsImpl implements AccessStats {
+
+ final CountingFilter countingFilter;
+
+ AccessStatsImpl(CountingFilter countingFilter) {
+ this.countingFilter = countingFilter;
+ }
+
+ public long getDailyAverage() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public long getDailyTotal() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public long getMonthlyAverage() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public long getMonthlyTotal() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public long getTotal() {
+ return countingFilter.getTotal();
+ }
+
+ public long getWeeklyAverage() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public long getWeeklyTotal() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+}
Added: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/filter/CountingFilter.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/filter/CountingFilter.java Fri Nov 17 12:27:06 2006
@@ -0,0 +1,61 @@
+ package ch.qos.logback.access.filter;
+
+import java.lang.management.ManagementFactory;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+
+import ch.qos.logback.core.filter.Filter;
+import ch.qos.logback.core.spi.FilterReply;
+
+public class CountingFilter extends Filter {
+
+ long total = 0;
+ final AccessStatsImpl accessStatsImpl;
+
+ CountingFilter() {
+ accessStatsImpl = new AccessStatsImpl(this);
+ }
+
+ @Override
+ public FilterReply decide(Object event) {
+
+ total++;
+
+ return FilterReply.NEUTRAL;
+ }
+
+ public long getTotal() {
+ return total;
+ }
+
+
+
+
+ @Override
+ public void start() {
+ MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+ try {
+ ObjectName on = new ObjectName("totp:Filter=1");
+ StandardMBean mbean = new StandardMBean(accessStatsImpl, AccessStats.class);
+ mbs.registerMBean(mbean, on);
+ super.start();
+ } catch (Exception e) {
+ addError("Failed to create mbean", e);
+ }
+ }
+
+ @Override
+ public void stop() {
+ super.stop();
+ try {
+ MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+ ObjectName on = new ObjectName("totp:Filter=1");
+ mbs.unregisterMBean(on);
+ } catch(Exception e) {
+ addError("Failed to unregister mbean", e);
+ }
+ }
+
+}
More information about the logback-dev
mailing list