sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1635553 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/ sis-...
Date Thu, 30 Oct 2014 17:13:29 GMT
Author: desruisseaux
Date: Thu Oct 30 17:13:28 2014
New Revision: 1635553

URL: http://svn.apache.org/r1635553
Log:
Consolidation of logging messages occuring at XML (un)marshalling time.
This is cleaning work prior the consolidation of ArgumentChecks call in metadata implementations.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectified.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameter.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -22,6 +22,7 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 import org.apache.sis.metadata.AbstractMetadata;
+import org.apache.sis.metadata.iso.ISOMetadata;
 import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.util.resources.Messages;
 import org.apache.sis.util.ArgumentChecks;
@@ -178,7 +179,7 @@ public abstract class LegacyPropertyAdap
     public static void warnIgnoredExtraneous(final Class<?> valueClass,
             final Class<?> callerClass, final String callerMethod)
     {
-        Context.warningOccured(Context.current(), callerClass, callerMethod,
+        Context.warningOccured(Context.current(), ISOMetadata.LOGGER, callerClass, callerMethod,
                 Messages.class, Messages.Keys.IgnoredPropertiesAfterFirst_1, valueClass);
     }
 

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -17,17 +17,12 @@
 package org.apache.sis.internal.metadata;
 
 import java.util.Date;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
 import org.apache.sis.xml.NilReason;
 import org.apache.sis.util.Static;
 import org.apache.sis.util.resources.Errors;
-import org.apache.sis.util.resources.Messages;
 import org.apache.sis.metadata.InvalidMetadataException;
 import org.apache.sis.internal.jaxb.PrimitiveTypeProperties;
 
-import static org.apache.sis.metadata.iso.ISOMetadata.LOGGER;
-
 
 /**
  * Miscellaneous utility methods for metadata.
@@ -112,21 +107,4 @@ public final class MetadataUtilities ext
         }
         return true;
     }
-
-    /**
-     * Convenience method for logging a warning to the {@code ISOMetadata} logger.
-     * The message will be produced using the {@link Messages} resources bundle.
-     *
-     * @param  caller    The public class which is invoking this method.
-     * @param  method    The public method which is invoking this method.
-     * @param  key       The key from the message resource bundle to use for creating a message.
-     * @param  arguments The arguments to be used together with the key for building the
message.
-     */
-    public static void warning(final Class<?> caller, final String method, final short
key, final Object... arguments) {
-        final LogRecord record = Messages.getResources(null).getLogRecord(Level.WARNING,
key, arguments);
-        record.setSourceClassName(caller.getCanonicalName());
-        record.setSourceMethodName(method);
-        record.setLoggerName(LOGGER.getName());
-        LOGGER.log(record);
-    }
 }

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -232,7 +232,7 @@ public class DefaultContact extends ISOM
                 }
             }
             if (ignored != null) {
-                Context.warningOccured(Context.current(), DefaultContact.class, "getPhone",
+                Context.warningOccured(Context.current(), LOGGER, DefaultContact.class, "getPhone",
                         Messages.class, Messages.Keys.IgnoredPropertyAssociatedTo_1, ignored.toString());
             }
         }

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -112,7 +112,6 @@ public class DefaultRepresentativeFracti
     public DefaultRepresentativeFraction(final RepresentativeFraction object) throws IllegalArgumentException
{
         if (object != null) {
             denominator = object.getDenominator();
-            ArgumentChecks.ensurePositive("object", denominator);
         }
     }
 

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -23,8 +23,8 @@ import javax.xml.bind.annotation.adapter
 import org.opengis.util.InternationalString;
 import org.opengis.metadata.identification.RepresentativeFraction;
 import org.opengis.metadata.identification.Resolution;
+import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.internal.jaxb.gco.GO_Distance;
-import org.apache.sis.internal.metadata.MetadataUtilities;
 import org.apache.sis.metadata.iso.ISOMetadata;
 import org.apache.sis.measure.ValueRange;
 import org.apache.sis.util.resources.Messages;
@@ -199,8 +199,8 @@ public class DefaultResolution extends I
             if (newValue == null) {
                 return; // Do not erase the other property.
             }
-            MetadataUtilities.warning(DefaultResolution.class, SETTERS[code-1],
-                    Messages.Keys.DiscardedExclusiveProperty_2, NAMES[property-1], NAMES[code-1]);
+            Context.warningOccured(Context.current(), LOGGER, DefaultResolution.class, SETTERS[code-1],
+                    Messages.class, Messages.Keys.DiscardedExclusiveProperty_2, NAMES[property-1],
NAMES[code-1]);
         }
         value = newValue;
         property = code;

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -25,7 +25,7 @@ import org.opengis.metadata.maintenance.
 import org.opengis.metadata.maintenance.ScopeDescription;
 import org.apache.sis.metadata.iso.ISOMetadata;
 import org.apache.sis.internal.metadata.ExcludedSet;
-import org.apache.sis.internal.metadata.MetadataUtilities;
+import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.util.collection.CheckedContainer;
 import org.apache.sis.util.resources.Messages;
 
@@ -248,8 +248,8 @@ public class DefaultScopeDescription ext
      */
     private void warningOnOverwrite(final byte code) {
         if (value != null && property != code) {
-            MetadataUtilities.warning(DefaultScopeDescription.class, SETTERS[code-1],
-                    Messages.Keys.DiscardedExclusiveProperty_2, NAMES[property-1], NAMES[code-1]);
+            Context.warningOccured(Context.current(), LOGGER, DefaultScopeDescription.class,
SETTERS[code-1],
+                    Messages.class, Messages.Keys.DiscardedExclusiveProperty_2, NAMES[property-1],
NAMES[code-1]);
         }
     }
 

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectified.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectified.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectified.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectified.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -27,7 +27,7 @@ import org.opengis.metadata.spatial.Geor
 import org.opengis.metadata.spatial.PixelOrientation;
 import org.opengis.geometry.primitive.Point;
 import org.opengis.util.InternationalString;
-import org.apache.sis.internal.metadata.MetadataUtilities;
+import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.util.resources.Messages;
 import org.apache.sis.xml.Namespaces;
 
@@ -211,8 +211,8 @@ public class DefaultGeorectified extends
             booleans |= CHECK_POINT_MASK;
         } else {
             if (checkPointDescription != null && (booleans & CHECK_POINT_MASK)
!= 0) {
-                MetadataUtilities.warning(DefaultGeorectified.class, "setCheckPointAvailable",
-                        Messages.Keys.PropertyHiddenBy_2, "checkPointDescription", "checkPointAvailability");
+                Context.warningOccured(Context.current(), LOGGER, DefaultGeorectified.class,
"setCheckPointAvailable",
+                        Messages.class, Messages.Keys.PropertyHiddenBy_2, "checkPointDescription",
"checkPointAvailability");
             }
             booleans &= ~CHECK_POINT_MASK;
         }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameter.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameter.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -131,7 +131,7 @@ public final class SecondDefiningParamet
      */
     public void setInverseFlattening(final Measure measure) {
         if (measure.setUnit(Unit.ONE)) {
-            Context.warningOccured(Context.current(), SecondDefiningParameter.class, "setInverseFlattening",
+            Context.warningOccured(Context.current(), Context.LOGGER, SecondDefiningParameter.class,
"setInverseFlattening",
                     Errors.class, Errors.Keys.IncompatiblePropertyValue_1, "uom");
         }
         this.measure = measure;

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -509,7 +509,7 @@ public class DefaultCoordinateSystemAxis
      * @param value The invalid value.
      */
     private static void outOfRange(final String name, final Double value) {
-        Context.warningOccured(Context.current(), DefaultCoordinateSystemAxis.class, name,
+        Context.warningOccured(Context.current(), Context.LOGGER, DefaultCoordinateSystemAxis.class,
name,
                 Errors.class, Errors.Keys.InconsistentAttribute_2, name, value);
     }
 

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -579,7 +579,7 @@ public class DefaultEllipsoid extends Ab
      */
     private static void warnDuplicated(final String element) {
          // We cheat a bit for the "unmarshal" method name since there is not such method...
-        Context.warningOccured(Context.current(), DefaultEllipsoid.class, "unmarshal",
+        Context.warningOccured(Context.current(), Context.LOGGER, DefaultEllipsoid.class,
"unmarshal",
                 Errors.class, Errors.Keys.DuplicatedElement_1, element);
     }
 

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -20,6 +20,7 @@ import java.util.Map;
 import java.util.Locale;
 import java.util.TimeZone;
 import java.util.logging.Level;
+import java.util.logging.Logger;
 import java.util.logging.LogRecord;
 import org.apache.sis.util.Version;
 import org.apache.sis.util.Exceptions;
@@ -46,7 +47,7 @@ import org.apache.sis.xml.ReferenceResol
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.07)
- * @version 0.4
+ * @version 0.5
  * @module
  */
 public final class Context extends MarshalContext {
@@ -92,6 +93,13 @@ public final class Context extends Marsh
     private static final ThreadLocal<Context> CURRENT = new ThreadLocal<>();
 
     /**
+     * The logger to use for warnings that are specific to XML.
+     *
+     * @see org.apache.sis.metadata.iso.ISOMetadata#LOGGER
+     */
+    public static final Logger LOGGER = Logging.getLogger("org.apache.sis.xml");
+
+    /**
      * Various boolean attributes determines by the above static constants.
      */
     private int bitMasks;
@@ -381,31 +389,59 @@ public final class Context extends Marsh
     }
 
     /**
-     * Sends the given warning to the warning listener if there is one, or logs the warning
otherwise.
-     * In the later case, this method logs to the logger specified by {@link LogRecord#getLoggerName()}
-     * if defined, or to the {@code "org.apache.sis.xml"} logger otherwise.
+     * Sends a warning to the warning listener if there is one, or logs the warning otherwise.
+     * In the later case, this method logs to the given logger.
      *
-     * @param context The current context, or {@code null} if none.
-     * @param warning The warning.
+     * <p>If the given {@code resources} is {@code null}, then this method will build
the log
+     * message from the {@code exception}.</p>
+     *
+     * @param context   The current context, or {@code null} if none.
+     * @param logger    The logger where to send the warning.
+     * @param level     The logging level.
+     * @param classe    The class to declare as the warning source.
+     * @param method    The name of the method to declare as the warning source.
+     * @param exception The exception thrown, or {@code null} if none.
+     * @param resources Either {@code Errors.class}, {@code Messages.class} or {@code null}
for the exception message.
+     * @param key       The resource keys as one of the constants defined in the {@code Keys}
inner class.
+     * @param arguments The arguments to be given to {@code MessageFormat} for formatting
the log message.
+     *
+     * @since 0.5
      */
-    public static void warningOccured(final Context context, final LogRecord warning) {
-        String logger = warning.getLoggerName();
-        if (logger == null) {
-            warning.setLoggerName(logger = "org.apache.sis.xml");
+    public static void warningOccured(final Context context, final Logger logger,
+            final Level level, final Class<?> classe, final String method, final Throwable
exception,
+            final Class<? extends IndexedResourceBundle> resources, final short key,
final Object... arguments)
+    {
+        final Locale locale = (context != null) ? context.getLocale() : null;
+        final LogRecord record;
+        if (resources != null) {
+            final IndexedResourceBundle bundle;
+            if (resources == Errors.class) {
+                bundle = Errors.getResources(locale);
+            } else if (resources == Messages.class) {
+                bundle = Messages.getResources(locale);
+            } else {
+                throw new IllegalArgumentException(String.valueOf(resources));
+            }
+            record = bundle.getLogRecord(level, key, arguments);
+        } else {
+            record = new LogRecord(level, Exceptions.formatChainedMessages(locale, null,
exception));
         }
+        record.setSourceClassName(classe.getCanonicalName());
+        record.setSourceMethodName(method);
+        record.setLoggerName(logger.getName());
         if (context != null) {
             final WarningListener<?> warningListener = context.warningListener;
             if (warningListener != null) {
-                warningListener.warningOccured(null, warning);
+                record.setThrown(exception);
+                warningListener.warningOccured(null, record);
                 return;
             }
         }
         /*
-         * Log the warning without stack-trace, since this method shall be used only for
non-fatal warnings
-         * and we want to avoid polluting the logs.
+         * Log the warning without stack-trace, since this method shall be used
+         * only for non-fatal warnings and we want to avoid polluting the logs.
          */
-        warning.setThrown(null);
-        Logging.getLogger(logger).log(warning);
+        logger.log(record);
     }
 
     /**
@@ -413,28 +449,20 @@ public final class Context extends Marsh
      * resources. The message will be logged at {@link Level#WARNING}.
      *
      * @param context   The current context, or {@code null} if none.
+     * @param logger    The logger where to send the warning.
      * @param classe    The class to declare as the warning source.
      * @param method    The name of the method to declare as the warning source.
      * @param resources Either {@code Errors.class} or {@code Messages.class}.
      * @param key       The resource keys as one of the constants defined in the {@code Keys}
inner class.
      * @param arguments The arguments to be given to {@code MessageFormat} for formatting
the log message.
+     *
+     * @since 0.5
      */
-    public static void warningOccured(final Context context, final Class<?> classe,
final String method,
+    public static void warningOccured(final Context context, final Logger logger,
+            final Class<?> classe, final String method,
             final Class<? extends IndexedResourceBundle> resources, final short key,
final Object... arguments)
     {
-        final Locale locale = context != null ? context.getLocale() : null;
-        final IndexedResourceBundle bundle;
-        if (resources == Errors.class) {
-            bundle = Errors.getResources(locale);
-        } else if (resources == Messages.class) {
-            bundle = Messages.getResources(locale);
-        } else {
-            throw new IllegalArgumentException(String.valueOf(resources));
-        }
-        final LogRecord warning = bundle.getLogRecord(Level.WARNING, key, arguments);
-        warning.setSourceClassName(classe.getCanonicalName());
-        warning.setSourceMethodName(method);
-        warningOccured(context, warning);
+        warningOccured(context, logger, Level.WARNING, classe, method, null, resources, key,
arguments);
     }
 
     /**
@@ -450,12 +478,8 @@ public final class Context extends Marsh
     public static void warningOccured(final Context context, final Class<?> classe,
             final String method, final Exception cause, final boolean warning)
     {
-        final LogRecord record = new LogRecord(warning ? Level.WARNING : Level.FINE,
-                Exceptions.formatChainedMessages(context != null ? context.getLocale() :
null, null, cause));
-        record.setSourceClassName(classe.getCanonicalName());
-        record.setSourceMethodName(method);
-        record.setThrown(cause);
-        warningOccured(context, record);
+        warningOccured(context, LOGGER, warning ? Level.WARNING : Level.FINE, classe, method,
cause,
+                null, (short) 0, (Object[]) null);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -21,7 +21,6 @@ import java.net.URISyntaxException;
 import java.util.UUID;
 import java.io.Serializable;
 import java.util.logging.Level;
-import java.util.logging.LogRecord;
 import org.opengis.metadata.Identifier;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.util.InternationalString;
@@ -152,12 +151,8 @@ public final class SpecializedIdentifier
      * @param cause   The exception that occurred during the parsing process.
      */
     static void parseFailure(final Context context, final String value, final Class<?>
type, final Exception cause) {
-        final Messages resources = Messages.getResources(context != null ? context.getLocale()
: null);
-        final LogRecord record = resources.getLogRecord(Level.WARNING, Messages.Keys.UnparsableValueStoredAsText_2,
type, value);
-        record.setSourceClassName(IdentifierMap.class.getCanonicalName());
-        record.setSourceMethodName("put");
-        record.setThrown(cause);
-        Context.warningOccured(context, record);
+        Context.warningOccured(context, Context.LOGGER, Level.WARNING, IdentifierMap.class,
"put", cause,
+                Messages.class, Messages.Keys.UnparsableValueStoredAsText_2, type, value);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -138,7 +138,7 @@ public class GO_CharacterString {
                 property  = type;
                 noset     = true;
             }
-            Context.warningOccured(Context.current(), getClass(), "setText", Messages.class,
+            Context.warningOccured(Context.current(), Context.LOGGER, getClass(), "setText",
Messages.class,
                     Messages.Keys.DiscardedExclusiveProperty_2, nameOf(discarded), nameOf(property));
             if (noset) {
                 return;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -206,7 +206,7 @@ public final class Measure {
      * @param methodName The name of the method invoking this method.
      */
     public static void missingUOM(final Class<?> caller, final String methodName) {
-        Context.warningOccured(Context.current(), caller, methodName,
+        Context.warningOccured(Context.current(), Context.LOGGER, caller, methodName,
                 Errors.class, Errors.Keys.MandatoryAttribute_2, "uom", "Measure");
     }
 }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -148,7 +148,7 @@ final class ObjectReference {
         if (value != null) {
             final T previous = map.putSpecialized(authority, value);
             if (previous != null && !previous.equals(value)) {
-                Context.warningOccured(context, IdentifierMap.class, "putSpecialized",
+                Context.warningOccured(context, Context.LOGGER, IdentifierMap.class, "putSpecialized",
                         Errors.class, Errors.Keys.InconsistentAttribute_2, authority.getName(),
value);
                 map.putSpecialized(authority, previous);
             }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -148,7 +148,7 @@ public final class Country extends GO_Ch
                     if (++i == code.length() || code.charAt(i) == '_') {
                         code = new StringBuilder().append(code, 0, i).append(c).append(code,
i, length).toString();
                     } else if (!c.equals(CharSequences.token(code, i))) {
-                        Context.warningOccured(context, caller, "unmarshal", Errors.class,
+                        Context.warningOccured(context, Context.LOGGER, caller, "unmarshal",
Errors.class,
                                 Errors.Keys.IncompatiblePropertyValue_1, "country");
                     }
                 }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -116,7 +116,7 @@ public class SC_VerticalCRS extends Prop
      */
     @XmlAnyElement(lax = true)
     public Object getElement() {
-        Context.warningOccured(Context.current(), SC_VerticalCRS.class, "getElement",
+        Context.warningOccured(Context.current(), Context.LOGGER, SC_VerticalCRS.class, "getElement",
                 Errors.class, Errors.Keys.MissingRequiredModule_1, "sis-referencing");
         return null;
     }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -119,8 +119,8 @@ public final class TM_Primitive extends 
                      * TemporalPrimitive as the source class, since it is the closest we
can get
                      * to a public API.
                      */
-                    Context.warningOccured(context, TemporalPrimitive.class, "setTimePeriod",
-                            Errors.class, Errors.Keys.IllegalRange_2, begin, end);
+                    Context.warningOccured(context, Context.LOGGER, TemporalPrimitive.class,
+                            "setTimePeriod", Errors.class, Errors.Keys.IllegalRange_2, begin,
end);
                 } else try {
                     metadata = TemporalUtilities.createPeriod(begin, end);
                     period.copyIdTo(metadata);

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java?rev=1635553&r1=1635552&r2=1635553&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java
[UTF-8] Thu Oct 30 17:13:28 2014
@@ -160,7 +160,7 @@ public final class CheckedArrayList<E> e
         }
         final Context context = Context.current();
         if (context != null) {
-            Context.warningOccured(context, collection.getClass(), "add", Errors.class, key,
arguments);
+            Context.warningOccured(context, Context.LOGGER, collection.getClass(), "add",
Errors.class, key, arguments);
             return null;
         } else {
             return Errors.format(key, arguments);



Mime
View raw message