sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1718926 - in /sis/branches/JDK8: application/sis-console/src/main/java/org/apache/sis/console/ core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/ core/sis-utility/src/main/java/org/apache/sis/internal/system/ core/sis-util...
Date Wed, 09 Dec 2015 17:56:44 GMT
Author: desruisseaux
Date: Wed Dec  9 17:56:44 2015
New Revision: 1718926

URL: http://svn.apache.org/viewvc?rev=1718926&view=rev
Log:
"sis about" command on a distant machine should report to user the warnings, if any.

Modified:
    sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/AboutSC.java
    sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/package-info.java
    sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Rewriter.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/SupervisorMBean.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties

Modified: sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/AboutSC.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/AboutSC.java?rev=1718926&r1=1718925&r2=1718926&view=diff
==============================================================================
--- sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/AboutSC.java
[UTF-8] (original)
+++ sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/AboutSC.java
[UTF-8] Wed Dec  9 17:56:44 2015
@@ -31,6 +31,7 @@ import org.apache.sis.util.resources.Err
 import org.apache.sis.util.resources.Vocabulary;
 import org.apache.sis.internal.system.Supervisor;
 import org.apache.sis.internal.system.SupervisorMBean;
+import org.apache.sis.internal.util.X364;
 
 
 /**
@@ -50,7 +51,7 @@ import org.apache.sis.internal.system.Su
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.7
  * @module
  */
 final class AboutSC extends SubCommand {
@@ -77,19 +78,20 @@ final class AboutSC extends SubCommand {
         if (hasUnexpectedFileCount(0, brief ? 0 : 1)) {
             return Command.INVALID_ARGUMENT_EXIT_CODE;
         }
+        String[] warnings = null;
         final String configuration;
-        if (brief) {
+        if (brief && files.isEmpty()) {
             configuration = Vocabulary.getResources(locale).getString(
                     Vocabulary.Keys.Version_2, "Apache SIS", Version.SIS);
         } else {
+            final EnumSet<About> sections = EnumSet.allOf(About.class);
+            if (!options.containsKey(Option.VERBOSE)) {
+                sections.remove(About.LIBRARIES);
+            }
             if (files.isEmpty()) {
                 /*
                  * Provide information about the local SIS installation.
                  */
-                final EnumSet<About> sections = EnumSet.allOf(About.class);
-                if (!options.containsKey(Option.VERBOSE)) {
-                    sections.remove(About.LIBRARIES);
-                }
                 configuration = About.configuration(sections, locale, timezone).toString();
             } else {
                 /*
@@ -104,7 +106,8 @@ final class AboutSC extends SubCommand {
                     try (JMXConnector jmxc = JMXConnectorFactory.connect(url)) {
                         final MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
                         final SupervisorMBean bean = JMX.newMBeanProxy(mbsc, new ObjectName(Supervisor.NAME),
SupervisorMBean.class);
-                        configuration = bean.configuration().toString();
+                        configuration = bean.configuration(sections, locale, timezone).toString();
+                        warnings = bean.warnings(locale);
                     }
                 } catch (IOException e) {
                     error(Errors.format(Errors.Keys.CanNotConnectTo_1, path), e);
@@ -113,6 +116,28 @@ final class AboutSC extends SubCommand {
             }
         }
         out.println(configuration);
+        if (warnings != null) {
+            out.println();
+            if (colors) {
+                out.print(X364.BACKGROUND_RED.sequence());
+                out.print(X364.BOLD.sequence());
+                out.print(' ');
+            }
+            out.print(Vocabulary.getResources(locale).getLabel(Vocabulary.Keys.Warnings));
+            if (colors) {
+                out.print(' ');
+                out.println(X364.RESET.sequence());
+                out.print(X364.FOREGROUND_RED.sequence());
+            } else {
+                out.println();
+            }
+            for (final String warning : warnings) {
+                out.println(warning);
+            }
+            if (colors) {
+                out.print(X364.FOREGROUND_DEFAULT.sequence());
+            }
+        }
         out.flush();
         return 0;
     }

Modified: sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/package-info.java?rev=1718926&r1=1718925&r2=1718926&view=diff
==============================================================================
--- sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/package-info.java
[UTF-8] Wed Dec  9 17:56:44 2015
@@ -36,7 +36,7 @@
  * {@code about} sub-command shall be invoked as below:
  *
  * {@preformat shell
- *   java org.apache.sis.console.Command about localhost:9999
+ *   java org.apache.sis.console.Command about localhost:1099
  * }
  *
  * The {@code com.sun.management.jmxremote.local.only} property is recommended if the remote
JVM is an other
@@ -47,7 +47,7 @@
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.7
  * @module
  */
 package org.apache.sis.console;

Modified: sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Rewriter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Rewriter.java?rev=1718926&r1=1718925&r2=1718926&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Rewriter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Rewriter.java
[UTF-8] Wed Dec  9 17:56:44 2015
@@ -205,6 +205,9 @@ process:    while (i < stopAt) {
                      * At this point, we are right after a Java identifier. If the character
is a dot
                      * followed immediately by another Java identifier, allow line break
before the dot.
                      * We may need to skip the "()" in method names.
+                     *
+                     * NOTE: this code does not handle the <code><a.../a>.<a.../a></code>
case.
+                     *       We may revisit this issue when porting the doclet to JDK 9.
                      */
                     if (c == '(') c = content.codePointAt(++i);
                     if (c == ')') c = content.codePointAt(++i);

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java?rev=1718926&r1=1718925&r2=1718926&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java
[UTF-8] Wed Dec  9 17:56:44 2015
@@ -37,7 +37,6 @@ import javax.management.InstanceAlreadyE
 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;
@@ -52,10 +51,10 @@ import org.apache.sis.util.collection.Tr
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.7
  * @module
  */
-public final class Supervisor extends StandardMBean implements SupervisorMBean, Localized
{
+public final class Supervisor extends StandardMBean implements SupervisorMBean {
     /**
      * Whatever JMX agent is enabled. Setting this variable to {@code false} allows the
      * Java compiler to omit any dependency to this {@code Supervisor} class.
@@ -82,13 +81,13 @@ public final class Supervisor extends St
      * and the MBean will not be registered. This method does not propagate the exception
      * because the MBean is not a mandatory part of SIS library.</p>
      */
-    static synchronized void register() {
+    public static synchronized void register() {
         if (name == null) {
             name = ObjectName.WILDCARD; // In case of failure.
             final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
             try {
                 final ObjectName n = new ObjectName(NAME);
-                server.registerMBean(new Supervisor(null, null), n);
+                server.registerMBean(new Supervisor(), n);
                 name = n; // Store only on success.
             } catch (InstanceAlreadyExistsException e) {
                 final LogRecord record = Messages.getResources(null)
@@ -119,34 +118,12 @@ public final class Supervisor extends St
     }
 
     /**
-     * The locale for producing the messages, or {@code null} for the default.
-     */
-    private final Locale locale;
-
-    /**
-     * The timezone for formatting the dates, or {@code null} for the default.
-     */
-    private final TimeZone timezone;
-
-    /**
-     * Creates a new {@code Supervisor} which will report messages in the given locale.
+     * Creates a new {@code Supervisor}.
      *
-     * @param  locale The locale to use for reporting messages, or {@code null} for the default.
-     * @param  timezone The timezone for formatting the dates, or {@code null} for the default.
      * @throws NotCompliantMBeanException Should never happen.
      */
-    public Supervisor(final Locale locale, final TimeZone timezone) throws NotCompliantMBeanException
{
+    public Supervisor() throws NotCompliantMBeanException {
         super(SupervisorMBean.class);
-        this.locale   = locale;
-        this.timezone = timezone;
-    }
-
-    /**
-     * Returns the supervisor locale, or {@code null} for the default locale.
-     */
-    @Override
-    public Locale getLocale() {
-        return locale;
     }
 
     /**
@@ -210,7 +187,7 @@ public final class Supervisor extends St
      */
     private String getDescription(final String resourceKey) {
         return ResourceBundle.getBundle("org.apache.sis.internal.system.Descriptions",
-                (locale != null) ? locale : Locale.getDefault(Locale.Category.DISPLAY),
+                Locale.getDefault(Locale.Category.DISPLAY),
                 Supervisor.class.getClassLoader()).getString(resourceKey);
     }
 
@@ -222,15 +199,15 @@ public final class Supervisor extends St
      * {@inheritDoc}
      */
     @Override
-    public TreeTable configuration() {
-        return About.configuration(EnumSet.allOf(About.class), locale, timezone);
+    public TreeTable configuration(final EnumSet<About> sections, final Locale locale,
final TimeZone timezone) {
+        return About.configuration(sections, locale, timezone);
     }
 
     /**
      * {@inheritDoc}
      */
     @Override
-    public String[] warnings() {
+    public String[] warnings(final Locale locale) {
         final DaemonThread lastCreatedDaemon;
         synchronized (Threads.class) {
             lastCreatedDaemon = Threads.lastCreatedDaemon;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/SupervisorMBean.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/SupervisorMBean.java?rev=1718926&r1=1718925&r2=1718926&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/SupervisorMBean.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/SupervisorMBean.java
[UTF-8] Wed Dec  9 17:56:44 2015
@@ -16,6 +16,10 @@
  */
 package org.apache.sis.internal.system;
 
+import java.util.EnumSet;
+import java.util.Locale;
+import java.util.TimeZone;
+import org.apache.sis.setup.About;
 import org.apache.sis.util.collection.TreeTable;
 
 
@@ -24,7 +28,7 @@ import org.apache.sis.util.collection.Tr
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.7
  * @module
  */
 public interface SupervisorMBean {
@@ -35,15 +39,19 @@ public interface SupervisorMBean {
      * Apache SIS version, Java version and operation system version; a "Classpath"
      * section containing bootstrap, extension and user classpath, <i>etc</i>.
      *
+     * @param  sections The section for which information are desired.
+     * @param  locale   The locale to use for formatting the texts in the tree, or {@code
null} for the default.
+     * @param  timezone The timezone to use for formatting the dates, or {@code null} for
the default.
      * @return Configuration information, as a tree for grouping some configuration by sections.
      */
-    TreeTable configuration();
+    TreeTable configuration(EnumSet<About> sections, Locale locale, TimeZone timezone);
 
     /**
      * If there is something wrong with the current Apache SIS status,
      * returns descriptions of the problems. Otherwise returns {@code null}.
      *
+     * @param  locale The locale to use for reporting messages, or {@code null} for the default.
      * @return A description of a problems in the library, or {@code null} if none.
      */
-    String[] warnings();
+    String[] warnings(Locale locale);
 }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java?rev=1718926&r1=1718925&r2=1718926&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java
[UTF-8] Wed Dec  9 17:56:44 2015
@@ -120,6 +120,7 @@ public enum X364 {
      * @param code  The X.364 numerical code.
      * @param color The color name, or {@code null} if none.
      */
+    @SuppressWarnings("ThisEscapedInObjectConstruction")
     private X364(final byte code, final String color) {
         this.code  = code;
         this.color = color;
@@ -132,6 +133,7 @@ public enum X364 {
      *
      * @param foreground The X.364 code for a foreground color.
      */
+    @SuppressWarnings("ThisEscapedInObjectConstruction")
     private X364(final X364 foreground) {
         this((byte) (foreground.code + 10), foreground.color);
         this.foreground = foreground;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java?rev=1718926&r1=1718925&r2=1718926&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
[UTF-8] Wed Dec  9 17:56:44 2015
@@ -106,6 +106,7 @@ public class IndexedResourceBundle exten
      *
      * @see #ensureLoaded(String)
      */
+    @SuppressWarnings("VolatileArrayField")     // Okay because we set this field only after
the array has been fully constructed.
     private volatile String[] values;
 
     /**
@@ -453,15 +454,22 @@ public class IndexedResourceBundle exten
     }
 
     /**
-     * Gets a string for the given key and appends ": " to it.
-     * This method is typically used for creating labels.
+     * Gets a string for the given key and appends ":" to it.
+     * A space may or may not be added before ":", depending on the locale.
+     * No space is added after the string; it is up to the caller to add such space if needed.
      *
      * @param  key The key for the desired string.
      * @return The string for the given key.
      * @throws MissingResourceException If no object for the given key can be found.
      */
     public final String getLabel(final short key) throws MissingResourceException {
-        return getString(key) + ": ";
+        String label = getString(key);
+        if (Locale.FRENCH.getLanguage().equals(getLocale().getLanguage())) {
+            label += "\u00A0:";
+        } else {
+            label += ':';
+        }
+        return label;
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1718926&r1=1718925&r2=1718926&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] Wed Dec  9 17:56:44 2015
@@ -501,6 +501,11 @@ public final class Vocabulary extends In
         public static final short Vertical = 68;
 
         /**
+         * Warnings
+         */
+        public static final short Warnings = 90;
+
+        /**
          * World
          */
         public static final short World = 64;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1718926&r1=1718925&r2=1718926&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] Wed Dec  9 17:56:44 2015
@@ -103,4 +103,5 @@ Variables               = Variables
 Version_2               = {0} version {1}
 Versions                = Versions
 Vertical                = Vertical
+Warnings                = Warnings
 World                   = World

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties?rev=1718926&r1=1718925&r2=1718926&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] Wed Dec  9 17:56:44 2015
@@ -110,4 +110,5 @@ Variables               = Variables
 Version_2               = {0} version {1}
 Versions                = Versions
 Vertical                = Vertical
+Warnings                = Avertissements
 World                   = Monde



Mime
View raw message