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

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


The following commit(s) were added to refs/heads/10.1.x by this push:
     new d3bc4dabdb More URL -> URI refactoring
d3bc4dabdb is described below

commit d3bc4dabdbb58068034f950b69ad474bad226efb
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Nov 16 18:50:38 2022 +0000

    More URL -> URI refactoring
---
 .../factory/webservices/ServiceRefFactory.java     | 30 +++++++++-------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/java/org/apache/naming/factory/webservices/ServiceRefFactory.java 
b/java/org/apache/naming/factory/webservices/ServiceRefFactory.java
index 909f3d3c72..d58933c8ce 100644
--- a/java/org/apache/naming/factory/webservices/ServiceRefFactory.java
+++ b/java/org/apache/naming/factory/webservices/ServiceRefFactory.java
@@ -19,7 +19,7 @@ package org.apache.naming.factory.webservices;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
-import java.net.URL;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Enumeration;
@@ -64,8 +64,8 @@ public class ServiceRefFactory implements ObjectFactory {
      * @param obj The reference object describing the webservice
      */
     @Override
-    public Object getObjectInstance(Object obj, Name name, Context nameCtx,
-            Hashtable<?,?> environment) throws Exception {
+    public Object getObjectInstance(Object obj, Name name, Context nameCtx, 
Hashtable<?,?> environment)
+            throws Exception {
 
         if (obj instanceof ServiceRef) {
             ServiceRef ref = (ServiceRef) obj;
@@ -105,8 +105,7 @@ public class ServiceRefFactory implements ObjectFactory {
                     serviceQname = new QName(serviceLocalPart);
                 } else {
                     String serviceNamespace = (String) tmp.getContent();
-                    serviceQname = new QName(serviceNamespace,
-                            serviceLocalPart);
+                    serviceQname = new QName(serviceNamespace, 
serviceLocalPart);
                 }
             }
             Class<?> serviceInterfaceClass = null;
@@ -114,15 +113,13 @@ public class ServiceRefFactory implements ObjectFactory {
             // Create service object
             if (serviceInterface == null) {
                 if (serviceQname == null) {
-                    throw new NamingException
-                    ("Could not create service-ref instance");
+                    throw new NamingException("Could not create service-ref 
instance");
                 }
                 try {
                     if (wsdlRefAddr == null) {
                         service = factory.createService( serviceQname );
                     } else {
-                        service = factory.createService( new URL(wsdlRefAddr),
-                                serviceQname );
+                        service = factory.createService(new 
URI(wsdlRefAddr).toURL(), serviceQname);
                     }
                 } catch (Exception e) {
                     NamingException ex = new NamingException("Could not create 
service");
@@ -139,19 +136,17 @@ public class ServiceRefFactory implements ObjectFactory {
                     throw ex;
                 }
                 if (serviceInterfaceClass == null) {
-                    throw new NamingException
-                    ("Could not load service Interface");
+                    throw new NamingException("Could not load service 
Interface");
                 }
                 try {
                     if (wsdlRefAddr == null) {
                         if 
(!Service.class.isAssignableFrom(serviceInterfaceClass)) {
                             throw new NamingException("service Interface 
should extend javax.xml.rpc.Service");
                         }
-                        service = factory.loadService( serviceInterfaceClass );
+                        service = factory.loadService(serviceInterfaceClass);
                     } else {
-                        service = factory.loadService( new URL(wsdlRefAddr),
-                                serviceInterfaceClass,
-                                new Properties() );
+                        service = factory.loadService(
+                                new URI(wsdlRefAddr).toURL(), 
serviceInterfaceClass, new Properties());
                     }
                 } catch (Exception e) {
                     NamingException ex = new NamingException("Could not create 
service");
@@ -160,8 +155,7 @@ public class ServiceRefFactory implements ObjectFactory {
                 }
             }
             if (service == null) {
-                throw new NamingException
-                ("Cannot create service object");
+                throw new NamingException("Cannot create service object");
             }
             serviceQname = service.getServiceName();
             serviceInterfaceClass = service.getClass();
@@ -170,7 +164,7 @@ public class ServiceRefFactory implements ObjectFactory {
                     WSDLFactory wsdlfactory = WSDLFactory.newInstance();
                     WSDLReader reader = wsdlfactory.newWSDLReader();
                     reader.setFeature("javax.wsdl.importDocuments", true);
-                    Definition def = reader.readWSDL((new 
URL(wsdlRefAddr)).toExternalForm());
+                    Definition def = reader.readWSDL(new 
URI(wsdlRefAddr).toURL().toExternalForm());
 
                     javax.wsdl.Service wsdlservice = 
def.getService(serviceQname);
                     @SuppressWarnings("unchecked") // Can't change the API


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

Reply via email to