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

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


The following commit(s) were added to refs/heads/8.5.x by this push:
     new 414a39d  Code clean-up.
414a39d is described below

commit 414a39d917afd4e4d9caea7eabaa31f2d374fe20
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Jul 10 09:02:55 2019 +0100

    Code clean-up.
    
    Generally, align with master. Add i18n, enhanced for loops, reduced
    casting, use interfaces rather than concrete types.
---
 .../factory/webservices/LocalStrings.properties    | 16 +++++++++++
 .../factory/webservices/LocalStrings_fr.properties | 16 +++++++++++
 .../factory/webservices/LocalStrings_ja.properties | 16 +++++++++++
 .../naming/factory/webservices/ServiceProxy.java   |  9 ++++--
 .../factory/webservices/ServiceRefFactory.java     | 32 ++++++++++------------
 5 files changed, 68 insertions(+), 21 deletions(-)

diff --git a/java/org/apache/naming/factory/webservices/LocalStrings.properties 
b/java/org/apache/naming/factory/webservices/LocalStrings.properties
new file mode 100644
index 0000000..0c5d17e
--- /dev/null
+++ b/java/org/apache/naming/factory/webservices/LocalStrings.properties
@@ -0,0 +1,16 @@
+# 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.
+
+serviceProxy.portNotFound=Port-component-ref [{0}] not found
diff --git 
a/java/org/apache/naming/factory/webservices/LocalStrings_fr.properties 
b/java/org/apache/naming/factory/webservices/LocalStrings_fr.properties
new file mode 100644
index 0000000..94053ed
--- /dev/null
+++ b/java/org/apache/naming/factory/webservices/LocalStrings_fr.properties
@@ -0,0 +1,16 @@
+# 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.
+
+serviceProxy.portNotFound=Le port-component-ref [{0}] n''a pas été trouvé
diff --git 
a/java/org/apache/naming/factory/webservices/LocalStrings_ja.properties 
b/java/org/apache/naming/factory/webservices/LocalStrings_ja.properties
new file mode 100644
index 0000000..a210092
--- /dev/null
+++ b/java/org/apache/naming/factory/webservices/LocalStrings_ja.properties
@@ -0,0 +1,16 @@
+# 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.
+
+serviceProxy.portNotFound=port-component-ref [{0}] [{0}]が見つかりません
diff --git a/java/org/apache/naming/factory/webservices/ServiceProxy.java 
b/java/org/apache/naming/factory/webservices/ServiceProxy.java
index 5341688..4539c83 100644
--- a/java/org/apache/naming/factory/webservices/ServiceProxy.java
+++ b/java/org/apache/naming/factory/webservices/ServiceProxy.java
@@ -27,6 +27,8 @@ import javax.xml.namespace.QName;
 import javax.xml.rpc.Service;
 import javax.xml.rpc.ServiceException;
 
+import org.apache.naming.StringManager;
+
 /**
  * Object proxy for Web Services.
  *
@@ -34,6 +36,8 @@ import javax.xml.rpc.ServiceException;
  */
 public class ServiceProxy implements InvocationHandler {
 
+    private static final StringManager sm = 
StringManager.getManager(ServiceProxy.class);
+
     /**
      * Service object.
      * used for delegation
@@ -103,8 +107,7 @@ public class ServiceProxy implements InvocationHandler {
         String nameString = name.getLocalPart();
         Class<?> serviceendpointClass = (Class<?>) args[1];
 
-        for (@SuppressWarnings("unchecked")
-        Iterator<QName> ports = service.getPorts(); ports.hasNext();) {
+        for (@SuppressWarnings("unchecked") Iterator<QName> ports = 
service.getPorts(); ports.hasNext();) {
             QName portName = ports.next();
             String portnameString = portName.getLocalPart();
             if (portnameString.equals(nameString)) {
@@ -113,7 +116,7 @@ public class ServiceProxy implements InvocationHandler {
         }
 
         // no ports have been found
-        throw new ServiceException("Port-component-ref : " + name + " not 
found");
+        throw new ServiceException(sm.getString("serviceProxy.portNotFound", 
name));
     }
 
     /**
diff --git a/java/org/apache/naming/factory/webservices/ServiceRefFactory.java 
b/java/org/apache/naming/factory/webservices/ServiceRefFactory.java
index 940de82..9f92d43 100644
--- a/java/org/apache/naming/factory/webservices/ServiceRefFactory.java
+++ b/java/org/apache/naming/factory/webservices/ServiceRefFactory.java
@@ -21,6 +21,7 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Iterator;
@@ -32,7 +33,6 @@ import javax.naming.Context;
 import javax.naming.Name;
 import javax.naming.NamingException;
 import javax.naming.RefAddr;
-import javax.naming.Reference;
 import javax.naming.spi.ObjectFactory;
 import javax.wsdl.Definition;
 import javax.wsdl.Port;
@@ -69,7 +69,7 @@ public class ServiceRefFactory implements ObjectFactory {
     throws Exception {
 
         if (obj instanceof ServiceRef) {
-            Reference ref = (Reference) obj;
+            ServiceRef ref = (ServiceRef) obj;
 
             // ClassLoader
             ClassLoader tcl =
@@ -176,7 +176,7 @@ public class ServiceRefFactory implements ObjectFactory {
                     Definition def = reader.readWSDL((new 
URL(wsdlRefAddr)).toExternalForm());
 
                     javax.wsdl.Service wsdlservice = 
def.getService(serviceQname);
-                    @SuppressWarnings("unchecked")
+                    @SuppressWarnings("unchecked") // Can't change the API
                     Map<String,?> ports = wsdlservice.getPorts();
                     Method m = 
serviceInterfaceClass.getMethod("setEndpointAddress",
                             new Class[] { java.lang.String.class,
@@ -222,15 +222,11 @@ public class ServiceRefFactory implements ObjectFactory {
             proxy.setPortComponentRef(portComponentRef);
 
             // Instantiate service with proxy class
-            Class<?>[] interfaces = null;
             Class<?>[] serviceInterfaces = 
serviceInterfaceClass.getInterfaces();
 
-            interfaces = new Class[serviceInterfaces.length + 1];
-            for (int i = 0; i < serviceInterfaces.length; i++) {
-                interfaces[i] = serviceInterfaces[i];
-            }
-
+            Class<?>[] interfaces = Arrays.copyOf(serviceInterfaces, 
serviceInterfaces.length + 1);
             interfaces[interfaces.length - 1] = javax.xml.rpc.Service.class;
+
             Object proxyInstance = null;
             try {
                 proxyInstance = Proxy.newProxyInstance(tcl, interfaces, proxy);
@@ -239,13 +235,13 @@ public class ServiceRefFactory implements ObjectFactory {
             }
 
             // Use handler
-            if (((ServiceRef) ref).getHandlersSize() > 0) {
+            if (ref.getHandlersSize() > 0) {
 
                 HandlerRegistry handlerRegistry = service.getHandlerRegistry();
-                ArrayList<String> soaproles = new ArrayList<>();
+                List<String> soaproles = new ArrayList<>();
 
-                while (((ServiceRef) ref).getHandlersSize() > 0) {
-                    HandlerRef handlerRef = ((ServiceRef) ref).getHandler();
+                while (ref.getHandlersSize() > 0) {
+                    HandlerRef handlerRef = ref.getHandler();
                     HandlerInfo handlerInfo = new HandlerInfo();
 
                     // Loading handler Class
@@ -261,9 +257,9 @@ public class ServiceRefFactory implements ObjectFactory {
 
                     // Load all datas relative to the handler : SOAPHeaders, 
config init element,
                     // portNames to be set on
-                    ArrayList<QName> headers = new ArrayList<>();
+                    List<QName> headers = new ArrayList<>();
                     Hashtable<String,String> config = new Hashtable<>();
-                    ArrayList<String> portNames = new ArrayList<>();
+                    List<String> portNames = new ArrayList<>();
                     for (int i = 0; i < handlerRef.size(); i++)
                         if 
(HandlerRef.HANDLER_LOCALPART.equals(handlerRef.get(i).getType())) {
                             String localpart = "";
@@ -327,7 +323,7 @@ public class ServiceRefFactory implements ObjectFactory {
      */
     private String getSOAPLocation(Port port) {
         String endpoint = null;
-        @SuppressWarnings("unchecked")
+        @SuppressWarnings("unchecked") // Can't change the API
         List<ExtensibilityElement> extensions = 
port.getExtensibilityElements();
         for (ExtensibilityElement ext : extensions) {
             if (ext instanceof SOAPAddress) {
@@ -340,9 +336,9 @@ public class ServiceRefFactory implements ObjectFactory {
 
 
     private void initHandlerChain(QName portName, HandlerRegistry 
handlerRegistry,
-            HandlerInfo handlerInfo, ArrayList<String> soaprolesToAdd) {
+            HandlerInfo handlerInfo, List<String> soaprolesToAdd) {
         HandlerChain handlerChain = (HandlerChain) 
handlerRegistry.getHandlerChain(portName);
-        @SuppressWarnings("unchecked")
+        @SuppressWarnings("unchecked") // Can't change the API
         Iterator<Handler> iter = handlerChain.iterator();
         while (iter.hasNext()) {
             Handler handler = iter.next();


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

Reply via email to