[jboss-svn-commits] JBoss Common SVN: r2440 - common-logging-spi/branches/2_0/src/main/java/org/jboss/logging.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jul 9 17:41:08 EDT 2007


Author: jason.greene at jboss.com
Date: 2007-07-09 17:41:08 -0400 (Mon, 09 Jul 2007)
New Revision: 2440

Added:
   common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/MDC.java
   common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/MDCProvider.java
   common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/MDCSupport.java
   common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NDC.java
   common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NDCProvider.java
   common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NDCSupport.java
   common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NullMDCProvider.java
   common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NullNDCProvider.java
Log:
Merge 2437 - JBCOMMON-28


Copied: common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/MDC.java (from rev 2437, common-logging-spi/trunk/src/main/java/org/jboss/logging/MDC.java)
===================================================================
--- common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/MDC.java	                        (rev 0)
+++ common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/MDC.java	2007-07-09 21:41:08 UTC (rev 2440)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.logging;
+
+import java.util.Map;
+
+/**
+ * A "Map Diagnostic Context" abstraction.
+ *
+ * @author Jason T. Greene
+ */
+public class MDC
+{
+   private final static MDCProvider mdc;
+
+   static
+   {
+      MDCProvider m = null;
+      if (NDCSupport.class.isAssignableFrom(Logger.pluginClass))
+      {
+
+         try
+         {
+            m = ((MDCSupport) Logger.pluginClass.newInstance()).getMDCProvider();
+         }
+         catch (Throwable t)
+         {
+            // Eat
+         }
+      }
+
+      if (m == null)
+         m = new NullMDCProvider();
+
+      mdc = m;
+   }
+
+   public static void put(String key, Object val)
+   {
+      mdc.put(key, val);
+   }
+
+   public static Object get(String key)
+   {
+      return mdc.get(key);
+   }
+
+   public static void remove(String key)
+   {
+      mdc.remove(key);
+   }
+
+   public static Map<String, Object> getMap()
+   {
+      return mdc.getMap();
+   }
+}

Copied: common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/MDCProvider.java (from rev 2437, common-logging-spi/trunk/src/main/java/org/jboss/logging/MDCProvider.java)
===================================================================
--- common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/MDCProvider.java	                        (rev 0)
+++ common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/MDCProvider.java	2007-07-09 21:41:08 UTC (rev 2440)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.logging;
+
+import java.util.Map;
+
+/**
+ * MDC SPI for the backend logging implementation.
+ *
+ * @author Jason T. Greene
+ */
+public interface MDCProvider
+{
+   public void put(String key, Object value);
+
+   public Object get(String key);
+
+   public void remove(String key);
+
+   public Map<String, Object> getMap();
+}

Copied: common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/MDCSupport.java (from rev 2437, common-logging-spi/trunk/src/main/java/org/jboss/logging/MDCSupport.java)
===================================================================
--- common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/MDCSupport.java	                        (rev 0)
+++ common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/MDCSupport.java	2007-07-09 21:41:08 UTC (rev 2440)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.logging;
+
+/**
+ * Indicates that a Logger plugin supports MDC.
+ *
+ * @author Jason T. Greene
+ */
+public interface MDCSupport
+{
+   public MDCProvider getMDCProvider();
+}

Copied: common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NDC.java (from rev 2437, common-logging-spi/trunk/src/main/java/org/jboss/logging/NDC.java)
===================================================================
--- common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NDC.java	                        (rev 0)
+++ common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NDC.java	2007-07-09 21:41:08 UTC (rev 2440)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.logging;
+
+
+/**
+ * A "Nested Diagnostic Context" abstraction.
+ *
+ * @author Jason T. Greene
+ */
+public class NDC
+{
+   private final static NDCProvider ndc;
+
+   static
+   {
+      NDCProvider n = null;
+      if (NDCSupport.class.isAssignableFrom(Logger.pluginClass))
+      {
+
+         try
+         {
+            n = ((NDCSupport) Logger.pluginClass.newInstance()).getNDCProvider();
+         }
+         catch (Throwable t)
+         {
+            // Eat
+         }
+      }
+
+      if (n == null)
+         n = new NullNDCProvider();
+
+      ndc = n;
+   }
+
+   public static void clear()
+   {
+      ndc.clear();
+   }
+
+   public static String get()
+   {
+      return ndc.get();
+   }
+
+   public static int getDepth()
+   {
+      return ndc.getDepth();
+   }
+
+   public static String pop()
+   {
+      return ndc.pop();
+   }
+
+   public static String peek()
+   {
+      return ndc.peek();
+   }
+
+   public static void push(String message)
+   {
+      ndc.push(message);
+   }
+
+   public static void setMaxDepth(int maxDepth)
+   {
+      ndc.setMaxDepth(maxDepth);
+   }
+}

Copied: common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NDCProvider.java (from rev 2437, common-logging-spi/trunk/src/main/java/org/jboss/logging/NDCProvider.java)
===================================================================
--- common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NDCProvider.java	                        (rev 0)
+++ common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NDCProvider.java	2007-07-09 21:41:08 UTC (rev 2440)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.logging;
+
+
+/**
+ * An NDC SPI for the backend logging implementation.
+ *
+ * @author Jason T. Greene
+ */
+public interface NDCProvider
+{
+   public void clear();
+
+   public String get();
+
+   public int getDepth();
+
+   public String pop();
+
+   public String peek();
+
+   public void push(String message);
+
+   public void setMaxDepth(int maxDepth);
+}
\ No newline at end of file

Copied: common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NDCSupport.java (from rev 2437, common-logging-spi/trunk/src/main/java/org/jboss/logging/NDCSupport.java)
===================================================================
--- common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NDCSupport.java	                        (rev 0)
+++ common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NDCSupport.java	2007-07-09 21:41:08 UTC (rev 2440)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.logging;
+
+/**
+ * Indicates that a logger plugin supports NDC.
+ *
+ * @author Jason T. Greene
+ */
+public interface NDCSupport
+{
+   public NDCProvider getNDCProvider();
+}

Copied: common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NullMDCProvider.java (from rev 2437, common-logging-spi/trunk/src/main/java/org/jboss/logging/NullMDCProvider.java)
===================================================================
--- common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NullMDCProvider.java	                        (rev 0)
+++ common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NullMDCProvider.java	2007-07-09 21:41:08 UTC (rev 2440)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.logging;
+
+import java.util.Map;
+
+/**
+ * An MDC provider which does nothing.
+ *
+ * @author Jason T. Greene
+ */
+public class NullMDCProvider implements MDCProvider
+{
+   public Object get(String key)
+   {
+      return null;
+   }
+
+   public Map<String, Object> getMap()
+   {
+      return null;
+   }
+
+   public void put(String key, Object val)
+   {
+   }
+
+   public void remove(String key)
+   {
+   }
+}
\ No newline at end of file

Copied: common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NullNDCProvider.java (from rev 2437, common-logging-spi/trunk/src/main/java/org/jboss/logging/NullNDCProvider.java)
===================================================================
--- common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NullNDCProvider.java	                        (rev 0)
+++ common-logging-spi/branches/2_0/src/main/java/org/jboss/logging/NullNDCProvider.java	2007-07-09 21:41:08 UTC (rev 2440)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.logging;
+
+import java.util.Stack;
+
+/**
+ * An NDC provider which does nothing.
+ *
+ * @author Jason T. Greene
+ */
+public class NullNDCProvider implements NDCProvider
+{
+   public void clear()
+   {
+   }
+
+   public Stack cloneStack()
+   {
+      return null;
+   }
+
+   public String get()
+   {
+      return null;
+   }
+
+   public int getDepth()
+   {
+      return 0;
+   }
+
+   public void inherit(Stack stack)
+   {
+   }
+
+   public String peek()
+   {
+      return null;
+   }
+
+   public String pop()
+   {
+      return null;
+   }
+
+   public void push(String message)
+   {
+   }
+
+   public void remove()
+   {
+   }
+
+   public void setMaxDepth(int maxDepth)
+   {
+   }
+}




More information about the jboss-svn-commits mailing list