This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 12a37a8d0838a7a276838b2fa30c9839a38e366b
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Oct 4 16:51:36 2019 +0100

    Polish. Align with 8.5.x. Improve i18n.
---
 .../tomcat/util/modeler/LocalStrings.properties    | 17 +++++
 .../tomcat/util/modeler/LocalStrings_fr.properties | 18 +++++
 .../tomcat/util/modeler/LocalStrings_ja.properties | 18 +++++
 .../tomcat/util/modeler/LocalStrings_ko.properties | 18 +++++
 .../util/modeler/LocalStrings_zh_CN.properties     | 17 +++++
 .../modules/MbeansDescriptorsDigesterSource.java   | 65 ++----------------
 .../MbeansDescriptorsIntrospectionSource.java      | 79 +++++++---------------
 .../tomcat/util/modeler/modules/ModelerSource.java | 28 +++++---
 8 files changed, 140 insertions(+), 120 deletions(-)

diff --git a/java/org/apache/tomcat/util/modeler/LocalStrings.properties 
b/java/org/apache/tomcat/util/modeler/LocalStrings.properties
new file mode 100644
index 0000000..b3d9b47
--- /dev/null
+++ b/java/org/apache/tomcat/util/modeler/LocalStrings.properties
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+modules.digesterParseError=Error parsing registry data
+modules.readDescriptorsError=Error reading descriptors
diff --git a/java/org/apache/tomcat/util/modeler/LocalStrings_fr.properties 
b/java/org/apache/tomcat/util/modeler/LocalStrings_fr.properties
new file mode 100644
index 0000000..30d80ca
--- /dev/null
+++ b/java/org/apache/tomcat/util/modeler/LocalStrings_fr.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+modules.digesterParseError=Erreur lors de l'analyse des données du registre
+modules.readDescriptorsError=Erreur lors de la lecture des descripteurs
+
diff --git a/java/org/apache/tomcat/util/modeler/LocalStrings_ja.properties 
b/java/org/apache/tomcat/util/modeler/LocalStrings_ja.properties
new file mode 100644
index 0000000..21c9711
--- /dev/null
+++ b/java/org/apache/tomcat/util/modeler/LocalStrings_ja.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+modules.digesterParseError=レジストリデータの解析エラー
+modules.readDescriptorsError=ディスクリプタ読み取り中のエラー
+
diff --git a/java/org/apache/tomcat/util/modeler/LocalStrings_ko.properties 
b/java/org/apache/tomcat/util/modeler/LocalStrings_ko.properties
new file mode 100644
index 0000000..ffcf3fd
--- /dev/null
+++ b/java/org/apache/tomcat/util/modeler/LocalStrings_ko.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+modules.digesterParseError=레지스트리 데이터를 파싱하는 중 오류 발생
+modules.readDescriptorsError=Descriptor들을 읽는 중 오류 발생
+
diff --git a/java/org/apache/tomcat/util/modeler/LocalStrings_zh_CN.properties 
b/java/org/apache/tomcat/util/modeler/LocalStrings_zh_CN.properties
new file mode 100644
index 0000000..519a3cd
--- /dev/null
+++ b/java/org/apache/tomcat/util/modeler/LocalStrings_zh_CN.properties
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+modules.readDescriptorsError=读取描述文件出错
+
diff --git 
a/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
 
b/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
index 9ed89ee..4d1983b 100644
--- 
a/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
+++ 
b/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
@@ -21,7 +21,6 @@ package org.apache.tomcat.util.modeler.modules;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import javax.management.ObjectName;
@@ -38,9 +37,9 @@ public class MbeansDescriptorsDigesterSource extends 
ModelerSource
             LogFactory.getLog(MbeansDescriptorsDigesterSource.class);
     private static final Object dLock = new Object();
 
-    Registry registry;
+    private Registry registry;
     String type;
-    List<ObjectName> mbeans = new ArrayList<ObjectName>();
+    private final List<ObjectName> mbeans = new ArrayList<ObjectName>();
     protected static volatile Digester digester = null;
 
     protected static Digester createDigester() {
@@ -75,56 +74,6 @@ public class MbeansDescriptorsDigesterSource extends 
ModelerSource
                 "addAttribute",
             "org.apache.tomcat.util.modeler.AttributeInfo");
 
-        /*digester.addObjectCreate
-            ("mbeans-descriptors/mbean/attribute/descriptor/field",
-            "org.apache.tomcat.util.modeler.FieldInfo");
-        digester.addSetProperties
-            ("mbeans-descriptors/mbean/attribute/descriptor/field");
-        digester.addSetNext
-            ("mbeans-descriptors/mbean/attribute/descriptor/field",
-                "addField",
-            "org.apache.tomcat.util.modeler.FieldInfo");
-
-        digester.addObjectCreate
-            ("mbeans-descriptors/mbean/constructor",
-            "org.apache.tomcat.util.modeler.ConstructorInfo");
-        digester.addSetProperties
-            ("mbeans-descriptors/mbean/constructor");
-        digester.addSetNext
-            ("mbeans-descriptors/mbean/constructor",
-                "addConstructor",
-            "org.apache.tomcat.util.modeler.ConstructorInfo");
-
-        digester.addObjectCreate
-            ("mbeans-descriptors/mbean/constructor/descriptor/field",
-            "org.apache.tomcat.util.modeler.FieldInfo");
-        digester.addSetProperties
-            ("mbeans-descriptors/mbean/constructor/descriptor/field");
-        digester.addSetNext
-            ("mbeans-descriptors/mbean/constructor/descriptor/field",
-                "addField",
-            "org.apache.tomcat.util.modeler.FieldInfo");
-
-        digester.addObjectCreate
-            ("mbeans-descriptors/mbean/constructor/parameter",
-            "org.apache.tomcat.util.modeler.ParameterInfo");
-        digester.addSetProperties
-            ("mbeans-descriptors/mbean/constructor/parameter");
-        digester.addSetNext
-            ("mbeans-descriptors/mbean/constructor/parameter",
-                "addParameter",
-            "org.apache.tomcat.util.modeler.ParameterInfo");
-
-        digester.addObjectCreate
-            ("mbeans-descriptors/mbean/descriptor/field",
-            "org.apache.tomcat.util.modeler.FieldInfo");
-        digester.addSetProperties
-            ("mbeans-descriptors/mbean/descriptor/field");
-        digester.addSetNext
-            ("mbeans-descriptors/mbean/descriptor/field",
-                "addField",
-            "org.apache.tomcat.util.modeler.FieldInfo");
-        */
         digester.addObjectCreate
             ("mbeans-descriptors/mbean/notification",
             "org.apache.tomcat.util.modeler.NotificationInfo");
@@ -225,8 +174,7 @@ public class MbeansDescriptorsDigesterSource extends 
ModelerSource
 
         InputStream stream = (InputStream) source;
 
-        ArrayList<ManagedBean> loadedMbeans = new ArrayList<ManagedBean>();
-
+        List<ManagedBean> loadedMbeans = new ArrayList<ManagedBean>();
         synchronized(dLock) {
             if (digester == null) {
                 digester = createDigester();
@@ -238,16 +186,15 @@ public class MbeansDescriptorsDigesterSource extends 
ModelerSource
                 digester.push(loadedMbeans);
                 digester.parse(stream);
             } catch (Exception e) {
-                log.error("Error digesting Registry data", e);
+                log.error(sm.getString("modules.digesterParseError"), e);
                 throw e;
             } finally {
                 digester.reset();
             }
 
         }
-        Iterator<ManagedBean> iter = loadedMbeans.iterator();
-        while (iter.hasNext()) {
-            registry.addManagedBean(iter.next());
+        for (ManagedBean loadedMbean : loadedMbeans) {
+            registry.addManagedBean(loadedMbean);
         }
     }
 }
diff --git 
a/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
 
b/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
index ba90d47..f45aba8 100644
--- 
a/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
+++ 
b/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
@@ -41,9 +41,9 @@ public class MbeansDescriptorsIntrospectionSource extends 
ModelerSource
 {
     private static final Log log = 
LogFactory.getLog(MbeansDescriptorsIntrospectionSource.class);
 
-    Registry registry;
-    String type;
-    List<ObjectName> mbeans = new ArrayList<ObjectName>();
+    private Registry registry;
+    private String type;
+    private final List<ObjectName> mbeans = new ArrayList<ObjectName>();
 
     public void setRegistry(Registry reg) {
         this.registry=reg;
@@ -57,9 +57,10 @@ public class MbeansDescriptorsIntrospectionSource extends 
ModelerSource
         this.location=loc;
     }
 
-    /** Used if a single component is loaded
+    /**
+     * Used if a single component is loaded
      *
-     * @param type
+     * @param type The type
      */
     public void setType( String type ) {
        this.type=type;
@@ -90,7 +91,7 @@ public class MbeansDescriptorsIntrospectionSource extends 
ModelerSource
             registry.addManagedBean(managed);
 
         } catch( Exception ex ) {
-            log.error( "Error reading descriptors ", ex);
+            log.error(sm.getString("modules.readDescriptorsError"), ex);
         }
     }
 
@@ -98,18 +99,13 @@ public class MbeansDescriptorsIntrospectionSource extends 
ModelerSource
 
     // ------------ Implementation for non-declared introspection classes
 
-    static Hashtable<String,String> specialMethods =
-        new Hashtable<String,String>();
+    private static final Hashtable<String,String> specialMethods = new 
Hashtable<String,String>();
     static {
         specialMethods.put( "preDeregister", "");
         specialMethods.put( "postDeregister", "");
     }
 
-    private static String strArray[]=new String[0];
-    private static ObjectName objNameArray[]=new ObjectName[0];
-    // createMBean == registerClass + registerMBean
-
-    private static Class<?>[] supportedTypes  = new Class[] {
+    private static final Class<?>[] supportedTypes  = new Class[] {
         Boolean.class,
         Boolean.TYPE,
         Byte.class,
@@ -127,11 +123,11 @@ public class MbeansDescriptorsIntrospectionSource extends 
ModelerSource
         Double.class,
         Double.TYPE,
         String.class,
-        strArray.getClass(),
+        String[].class,
         BigDecimal.class,
         BigInteger.class,
         ObjectName.class,
-        objNameArray.getClass(),
+        Object[].class,
         java.io.File.class,
     };
 
@@ -349,49 +345,27 @@ public class MbeansDescriptorsIntrospectionSource extends 
ModelerSource
                     mbean.addAttribute(ai);
             }
 
+            // This map is populated by iterating the methods (which end up as
+            // values in the Map) and obtaining the key from the value. It is
+            // impossible for a key to be associated with a null value.
             for (Entry<String,Method> entry : invokeAttMap.entrySet()) {
                 String name = entry.getKey();
                 Method m = entry.getValue();
-                if(m != null) {
-                    OperationInfo op=new OperationInfo();
-                    op.setName(name);
-                    op.setReturnType(m.getReturnType().getName());
-                    op.setDescription("Introspected operation " + name);
-                    Class<?> parms[] = m.getParameterTypes();
-                    for(int i=0; i<parms.length; i++ ) {
-                        ParameterInfo pi=new ParameterInfo();
-                        pi.setType(parms[i].getName());
-                        pi.setName(("param" + i).intern());
-                        pi.setDescription(("Introspected parameter param" + 
i).intern());
-                        op.addParameter(pi);
-                    }
-                    mbean.addOperation(op);
-                } else {
-                    log.error("Null arg method for [" + name + "]");
-                }
-            }
 
-            /*Constructor[] constructors = realClass.getConstructors();
-            for(int i=0;i<constructors.length;i++) {
-                ConstructorInfo info = new ConstructorInfo();
-                String className = realClass.getName();
-                int nIndex = -1;
-                if((nIndex = className.lastIndexOf('.'))!=-1) {
-                    className = className.substring(nIndex+1);
-                }
-                info.setName(className);
-                info.setDescription(constructors[i].getName());
-                Class classes[] = constructors[i].getParameterTypes();
-                for(int j=0;j<classes.length;j++) {
-                    ParameterInfo pi = new ParameterInfo();
-                    pi.setType(classes[j].getName());
-                    pi.setName("param" + j);
-                    pi.setDescription("Introspected parameter param" + j);
-                    info.addParameter(pi);
+                OperationInfo op=new OperationInfo();
+                op.setName(name);
+                op.setReturnType(m.getReturnType().getName());
+                op.setDescription("Introspected operation " + name);
+                Class<?> parms[] = m.getParameterTypes();
+                for(int i=0; i<parms.length; i++ ) {
+                    ParameterInfo pi=new ParameterInfo();
+                    pi.setType(parms[i].getName());
+                    pi.setName(("param" + i).intern());
+                    pi.setDescription(("Introspected parameter param" + 
i).intern());
+                    op.addParameter(pi);
                 }
-                mbean.addConstructor(info);
+                mbean.addOperation(op);
             }
-            */
 
             if( log.isDebugEnabled())
                 log.debug("Setting name: " + type );
@@ -424,4 +398,3 @@ public class MbeansDescriptorsIntrospectionSource extends 
ModelerSource
 
 }
 
-// End of class: MbeanDescriptorsIntrospectionSource
diff --git a/java/org/apache/tomcat/util/modeler/modules/ModelerSource.java 
b/java/org/apache/tomcat/util/modeler/modules/ModelerSource.java
index 4a5f00a..4281063 100644
--- a/java/org/apache/tomcat/util/modeler/modules/ModelerSource.java
+++ b/java/org/apache/tomcat/util/modeler/modules/ModelerSource.java
@@ -26,20 +26,23 @@ import java.util.List;
 import javax.management.ObjectName;
 
 import org.apache.tomcat.util.modeler.Registry;
+import org.apache.tomcat.util.res.StringManager;
 
-/** Source for descriptor data. More sources can be added.
- *
+/**
+ * Source for descriptor data. More sources can be added.
  */
 public abstract class ModelerSource {
+    protected static final StringManager sm = 
StringManager.getManager(Registry.class);
     protected Object source;
     @Deprecated
     protected String location;
 
-    /** Load data, returns a list of items.
+    /**
+     * Load data, returns a list of items.
      *
-     * @param registry
-     * @param location
-     * @param type
+     * @param registry The registry
+     * @param location Ignored
+     * @param type The bean registry type
      * @param source Introspected object or some other source
      * @throws Exception
      *
@@ -52,7 +55,8 @@ public abstract class ModelerSource {
         return loadDescriptors(registry, type, source);
     }
 
-    /** Callback from the BaseMBean to notify that an attribute has changed.
+    /**
+     * Callback from the BaseMBean to notify that an attribute has changed.
      * Can be used to implement persistence.
      *
      * @param oname
@@ -67,7 +71,6 @@ public abstract class ModelerSource {
     }
 
     /**
-     *
      * @deprecated Unused - will be removed in Tomcat 8.0.x
      */
     @Deprecated
@@ -97,6 +100,15 @@ public abstract class ModelerSource {
     }
 
 
+    /**
+     * Load data, returns a list of items.
+     *
+     * @param registry The registry
+     * @param type The bean registry type
+     * @param source Introspected object or some other source
+     * @return a list of object names
+     * @throws Exception Error loading descriptors
+     */
     public abstract List<ObjectName> loadDescriptors(Registry registry,
             String type, Object source) throws Exception;
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to