sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1528381 - in /sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis: internal/system/Supervisor.java util/logging/Logging.java util/resources/Messages.java util/resources/Messages.properties util/resources/Messages_fr.properties
Date Wed, 02 Oct 2013 09:01:49 GMT
Author: desruisseaux
Date: Wed Oct  2 09:01:48 2013
New Revision: 1528381

URL: http://svn.apache.org/r1528381
Log:
Reduce the logging level from "warning" to "config" when the Supervisor MBean is already registered.

Modified:
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java?rev=1528381&r1=1528380&r2=1528381&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java
[UTF-8] Wed Oct  2 09:01:48 2013
@@ -21,7 +21,8 @@ import java.util.List;
 import java.util.Locale;
 import java.util.TimeZone;
 import java.util.ResourceBundle;
-import java.util.logging.Logger;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
 import javax.management.ObjectName;
 import javax.management.StandardMBean;
 import javax.management.MBeanServer;
@@ -32,12 +33,14 @@ import javax.management.MBeanParameterIn
 import javax.management.MBeanConstructorInfo;
 import javax.management.JMException;
 import javax.management.NotCompliantMBeanException;
+import javax.management.InstanceAlreadyExistsException;
 import java.lang.management.ManagementFactory;
 
 import org.apache.sis.setup.About;
 import org.apache.sis.util.Localized;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.resources.Messages;
 import org.apache.sis.util.collection.TreeTable;
 
 
@@ -87,8 +90,13 @@ public final class Supervisor extends St
                 final ObjectName n = new ObjectName(NAME);
                 server.registerMBean(new Supervisor(null, null), n);
                 name = n; // Store only on success.
+            } catch (InstanceAlreadyExistsException e) {
+                final LogRecord record = Messages.getResources(null)
+                        .getLogRecord(Level.CONFIG, Messages.Keys.AlreadyRegistered_2, "MBean",
NAME);
+                record.setLoggerName("org.apache.sis");
+                Logging.log(Supervisor.class, "register", record);
             } catch (SecurityException | JMException e) {
-                Logging.unexpectedException(Logger.getLogger("org.apache.sis"), Supervisor.class,
"register", e);
+                Logging.unexpectedException(Logging.getLogger("org.apache.sis"), Supervisor.class,
"register", e);
             }
         }
     }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java?rev=1528381&r1=1528380&r2=1528381&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
[UTF-8] Wed Oct  2 09:01:48 2013
@@ -47,7 +47,7 @@ import org.apache.sis.util.Classes;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-2.4)
- * @version 0.3
+ * @version 0.4
  * @module
  */
 public final class Logging extends Static {
@@ -178,13 +178,14 @@ public final class Logging extends Stati
      * This convenience method performs the following steps:
      *
      * <ul>
-     *   <li>Get the logger using {@link #getLogger(Class)};</li>
+     *   <li>Unconditionally {@linkplain LogRecord#setSourceClassName(String) set the
source class name}
+     *       to the {@linkplain Class#getCanonicalName() canonical name} of the given class;</li>
+     *   <li>Unconditionally {@linkplain LogRecord#setSourceMethodName(String) set
the source method name}
+     *       to the given value;</li>
+     *   <li>Get the logger for the {@linkplain LogRecord#getLoggerName() logger name}
if specified,
+     *       or using {@link #getLogger(Class)} otherwise;</li>
      *   <li>{@linkplain LogRecord#setLoggerName(String) Set the logger name} of the
given record,
      *       if not already set;</li>
-     *   <li>Unconditionally {@linkplain LogRecord#setSourceClassName(String) set the
source class
-     *       name} to the {@linkplain Class#getCanonicalName() canonical name} of the given
class;</li>
-     *   <li>Unconditionally {@linkplain LogRecord#setSourceMethodName(String) set
the source method
-     *       name} to the given value;</li>
      *   <li>{@linkplain Logger#log(LogRecord) Log} the modified record.</li>
      * </ul>
      *
@@ -195,9 +196,13 @@ public final class Logging extends Stati
     public static void log(final Class<?> classe, final String method, final LogRecord
record) {
         record.setSourceClassName(classe.getCanonicalName());
         record.setSourceMethodName(method);
-        final Logger logger = getLogger(classe);
-        if (record.getLoggerName() == null) {
+        final String loggerName = record.getLoggerName();
+        final Logger logger;
+        if (loggerName == null) {
+            logger = getLogger(classe);
             record.setLoggerName(logger.getName());
+        } else {
+            logger = getLogger(loggerName);
         }
         logger.log(record);
     }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java?rev=1528381&r1=1528380&r2=1528381&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
[UTF-8] Wed Oct  2 09:01:48 2013
@@ -55,6 +55,11 @@ public final class Messages extends Inde
         }
 
         /**
+         * {0} “{1}” is already registered. The second instance will be ignored.
+         */
+        public static final int AlreadyRegistered_2 = 5;
+
+        /**
          * Changed the container capacity from {0} to {1} elements.
          */
         public static final int ChangedContainerCapacity_2 = 0;

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties?rev=1528381&r1=1528380&r2=1528381&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
[ISO-8859-1] Wed Oct  2 09:01:48 2013
@@ -14,6 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+AlreadyRegistered_2             = {0} \u201c{1}\u201d is already registered. The second instance
will be ignored.
 ChangedContainerCapacity_2      = Changed the container capacity from {0} to {1} elements.
 DiscardedExclusiveProperty_2    = Property \u201c{0}\u201d has been discarded in favor of
\u201c{1}\u201d, because those two properties are mutually exclusive.
 PropertyHiddenBy_2              = Property \u201c{0}\u201d is hidden by \u201c{1}\u201d.

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties?rev=1528381&r1=1528380&r2=1528381&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
[ISO-8859-1] Wed Oct  2 09:01:48 2013
@@ -14,6 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+AlreadyRegistered_2             = Le {0} \u201c{1}\u201d est d\u00e9j\u00e0 inscrit dans
le registre. La seconde instance sera ignor\u00e9e.
 ChangedContainerCapacity_2      = Changement de la capacit\u00e9 du conteneur de {0} vers
{1} \u00e9l\u00e9ments.
 DiscardedExclusiveProperty_2    = La propri\u00e9t\u00e9 \u201c{0}\u201d a \u00e9t\u00e9
\u00e9cart\u00e9e en faveur de \u201c{1}\u201d, parce que ces deux propri\u00e9t\u00e9s sont
mutuellement exclusives.
 PropertyHiddenBy_2              = La propri\u00e9t\u00e9 \u201c{0}\u201d est masqu\u00e9e
par \u201c{1}\u201d.



Mime
View raw message