[logback-dev] svn commit: r1289 - in logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic: jmx selector

noreply.seb at qos.ch noreply.seb at qos.ch
Mon Jan 29 18:54:42 CET 2007


Author: seb
Date: Mon Jan 29 18:54:41 2007
New Revision: 1289

Modified:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/jmx/Configurator.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/jmx/ConfiguratorMBean.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextSelector.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/DefaultContextSelector.java

Log:
JMX Configurator now displays a list of Status objects
ContextSelector implementations now also work as a registry. One can get a context based on its name, or get the names of all registered contexts.

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/jmx/Configurator.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/jmx/Configurator.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/jmx/Configurator.java	Mon Jan 29 18:54:41 2007
@@ -1,6 +1,8 @@
 package ch.qos.logback.classic.jmx;
 
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 import ch.qos.logback.classic.Level;
@@ -10,6 +12,7 @@
 import ch.qos.logback.classic.util.ContextInitializer;
 import ch.qos.logback.core.joran.spi.JoranException;
 import ch.qos.logback.core.spi.ContextAwareBase;
+import ch.qos.logback.core.status.Status;
 
 /**
  * A class that provides access to logback components via
@@ -119,6 +122,13 @@
     return lc.getLoggerList();
   }
   
-  
+  public List<Status> getStatuses() {
+    List<Status> list = new ArrayList<Status>();
+    Iterator<Status> it = context.getStatusManager().iterator();
+    while(it.hasNext()) {
+      list.add(it.next());
+    }
+    return list;
+  }
 
 }

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/jmx/ConfiguratorMBean.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/jmx/ConfiguratorMBean.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/jmx/ConfiguratorMBean.java	Mon Jan 29 18:54:41 2007
@@ -5,6 +5,7 @@
 
 import ch.qos.logback.classic.Logger;
 import ch.qos.logback.core.joran.spi.JoranException;
+import ch.qos.logback.core.status.Status;
 
 public interface ConfiguratorMBean {
   
@@ -21,4 +22,6 @@
   public String getLoggerEffectiveLevel(String loggerName);
 
   public List<Logger> getLoggerList();
+  
+  public List<Status> getStatuses();
 }

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java	Mon Jan 29 18:54:41 2007
@@ -4,8 +4,10 @@
 import static ch.qos.logback.classic.ClassicGlobal.JNDI_CONTEXT_NAME;
 
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.naming.Context;
@@ -109,6 +111,16 @@
     }
   }
   
+  public List<String> getContextNames() {
+    List<String> list = new ArrayList<String>();
+    list.addAll(contextMap.keySet());
+    return list;
+  }
+  
+  public LoggerContext getLoggerContext(String name) {
+    return contextMap.get(name);
+  }
+  
   /**
    * Returns the number of managed contexts
    * Used for testing purposes

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextSelector.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextSelector.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextSelector.java	Mon Jan 29 18:54:41 2007
@@ -1,5 +1,7 @@
 package ch.qos.logback.classic.selector;
 
+import java.util.List;
+
 import ch.qos.logback.classic.LoggerContext;
 
 /**
@@ -15,8 +17,11 @@
 
   public LoggerContext getLoggerContext();
   
+  public LoggerContext getLoggerContext(String name);
+  
   public LoggerContext getDefaultLoggerContext();
   
   public LoggerContext detachLoggerContext(String loggerContextName);
   
+  public List<String> getContextNames();
 }

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/DefaultContextSelector.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/DefaultContextSelector.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/DefaultContextSelector.java	Mon Jan 29 18:54:41 2007
@@ -1,5 +1,8 @@
 package ch.qos.logback.classic.selector;
 
+import java.util.Arrays;
+import java.util.List;
+
 import ch.qos.logback.classic.LoggerContext;
 
 public class DefaultContextSelector implements ContextSelector {
@@ -21,4 +24,16 @@
   public LoggerContext detachLoggerContext(String loggerContextName) {
     return context;
   }
+  
+  public List<String> getContextNames() {
+    return Arrays.asList(context.getName());
+  }
+  
+  public LoggerContext getLoggerContext(String name) {
+    if (context.getName().equals(name)) {
+      return context;
+    } else {
+      return null;
+    }
+  }
 }



More information about the logback-dev mailing list