axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r777976 - in /webservices/axis2/trunk/java/modules: java2wsdl/src/org/apache/ws/java2wsdl/ kernel/src/org/apache/axis2/deployment/util/ kernel/src/org/apache/axis2/description/ kernel/src/org/apache/axis2/util/
Date Sat, 23 May 2009 17:49:48 GMT
Author: veithen
Date: Sat May 23 17:49:48 2009
New Revision: 777976

URL: http://svn.apache.org/viewvc?rev=777976&view=rev
Log:
AXIS2-4346: java.net.URL should not be used to represent endpoint URIs. Use String instead.

Modified:
    webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/ClientUtils.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java

Modified: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java?rev=777976&r1=777975&r2=777976&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java
Sat May 23 17:49:48 2009
@@ -411,13 +411,11 @@
 
 	private void setServiceEPR(AxisService axisService, String urlString)
 			throws Exception {
-		URL url = new URL(urlString);
-		Utils.addSoap11Endpoint(axisService, url);
-		Utils.addSoap12Endpoint(axisService, url);
+		Utils.addSoap11Endpoint(axisService, urlString);
+		Utils.addSoap12Endpoint(axisService, urlString);
 		
-		String protocol = url.getProtocol();
-		if ("http".equals(protocol)) {
-			Utils.addHttpEndpoint(axisService, url);
+		if ("http".equals(org.apache.axis2.util.Utils.getURIScheme(urlString))) {
+			Utils.addHttpEndpoint(axisService, urlString);
 		}
 	}
 

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java?rev=777976&r1=777975&r2=777976&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
Sat May 23 17:49:48 2009
@@ -1170,20 +1170,30 @@
         }
     }
 
-    public static void addSoap11Endpoint(AxisService axisService, URL url)
-            throws Exception {
-        String protocol = url.getProtocol();
-        protocol = protocol.substring(0, 1).toUpperCase()
-                   + protocol.substring(1, protocol.length()).toLowerCase();
+    private static String getEndpointName(AxisService axisService, String protocol,
+            String soapVersion) {
+        
+        StringBuilder buffer = new StringBuilder();
+        buffer.append(axisService.getName());
+        buffer.append(protocol.substring(0, 1).toUpperCase());
+        buffer.append(protocol.substring(1, protocol.length()).toLowerCase());
+        if (soapVersion != null) {
+            buffer.append(soapVersion);
+        }
+        buffer.append("Endpoint");
+        return buffer.toString();
+    }
 
-        String serviceName = axisService.getName();
-        String soap11EndpointName = serviceName + protocol + "Soap11Endpoint";
+    public static void addSoap11Endpoint(AxisService axisService, String url)
+            throws Exception {
+        String protocol = org.apache.axis2.util.Utils.getURIScheme(url);
+        String soap11EndpointName = getEndpointName(axisService, protocol, "Soap11");
 
         AxisEndpoint httpSoap11Endpoint = new AxisEndpoint();
         httpSoap11Endpoint.setName(soap11EndpointName);
         httpSoap11Endpoint.setParent(axisService);
         httpSoap11Endpoint.setEndpointURL(url.toString());
-        httpSoap11Endpoint.setTransportInDescription(url.getProtocol());
+        httpSoap11Endpoint.setTransportInDescription(protocol);
 
         populateSoap11Endpoint(axisService, httpSoap11Endpoint, null);
         axisService.addEndpoint(httpSoap11Endpoint.getName(),
@@ -1192,38 +1202,31 @@
         axisService.setEndpointName(soap11EndpointName);
     }
 
-    public static void addSoap12Endpoint(AxisService axisService, URL url)
+    public static void addSoap12Endpoint(AxisService axisService, String url)
             throws Exception {
-        String protocol = url.getProtocol();
-        protocol = protocol.substring(0, 1).toUpperCase()
-                   + protocol.substring(1, protocol.length()).toLowerCase();
-
-        String serviceName = axisService.getName();
-        String soap12EndpointName = serviceName + protocol + "Soap12Endpoint";
+        String protocol = org.apache.axis2.util.Utils.getURIScheme(url);
+        String soap12EndpointName = getEndpointName(axisService, protocol, "Soap12");
 
         AxisEndpoint httpSoap12Endpoint = new AxisEndpoint();
         httpSoap12Endpoint.setName(soap12EndpointName);
         httpSoap12Endpoint.setParent(axisService);
         httpSoap12Endpoint.setEndpointURL(url.toString());
-        httpSoap12Endpoint.setTransportInDescription(url.getProtocol());
+        httpSoap12Endpoint.setTransportInDescription(protocol);
 
         populateSoap12Endpoint(axisService, httpSoap12Endpoint, null);
         axisService.addEndpoint(httpSoap12Endpoint.getName(),
                                 httpSoap12Endpoint);
     }
 
-    public static void addHttpEndpoint(AxisService axisService, URL url) {
-        String serviceName = axisService.getName();
-        String protocol = url.getProtocol();
-        protocol = protocol.substring(0, 1).toUpperCase()
-                   + protocol.substring(1, protocol.length()).toLowerCase();
-
-        String httpEndpointName = serviceName + protocol + "Endpoint";
+    public static void addHttpEndpoint(AxisService axisService, String url) {
+        String protocol = org.apache.axis2.util.Utils.getURIScheme(url);
+        String httpEndpointName = getEndpointName(axisService, protocol, null);
+        
         AxisEndpoint httpEndpoint = new AxisEndpoint();
         httpEndpoint.setName(httpEndpointName);
         httpEndpoint.setParent(axisService);
         httpEndpoint.setEndpointURL(url.toString());
-        httpEndpoint.setTransportInDescription(url.getProtocol());
+        httpEndpoint.setTransportInDescription(protocol);
         populateHttpEndpoint(axisService, httpEndpoint, null);
         axisService.addEndpoint(httpEndpoint.getName(), httpEndpoint);
     }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java?rev=777976&r1=777975&r2=777976&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
Sat May 23 17:49:48 2009
@@ -1470,14 +1470,10 @@
 	private String getLocationURI(String[] eprs, String epr) throws AxisFault {
 		String returnIP = null;
 		if (epr != null) {
-			if (epr.indexOf(":") > -1) {
-				String existingProtocol = epr.substring(0, epr.indexOf(":"))
-						.trim();
-				String eprProtocol;
+		    String existingProtocol = org.apache.axis2.util.Utils.getURIScheme(epr);
+			if (existingProtocol != null) {
 				for (int i = 0; i < eprs.length; i++) {
-					eprProtocol = eprs[i].substring(0, eprs[i].indexOf(":"))
-							.trim();
-					if (eprProtocol.equals(existingProtocol)) {
+					if (existingProtocol.equals(org.apache.axis2.util.Utils.getURIScheme(eprs[i]))) {
 						returnIP = eprs[i];
 						break;
 					}

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/ClientUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/ClientUtils.java?rev=777976&r1=777975&r2=777976&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/ClientUtils.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/ClientUtils.java
Sat May 23 17:49:48 2009
@@ -27,6 +27,7 @@
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.ListenerManager;
 import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.util.Utils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -46,8 +47,7 @@
             throws AxisFault {
         String transportURI = (String) msgctx.getProperty(Constants.Configuration.TRANSPORT_URL);
         if (transportURI != null && !"".equals(transportURI)) {
-            int index = transportURI.indexOf(':');
-            String transport = (index > 0) ? transportURI.substring(0, index) : null;
+            String transport = Utils.getURIScheme(transportURI);
             if (transport != null) {
                 TransportOutDescription transportOut = ac.getTransportOut(transport);
                 if (transportOut == null) {
@@ -73,8 +73,7 @@
                 throw new AxisFault(Messages.getMessage("cannotInferTransportNoAddr"));
             }
             String uri = epr.getAddress();
-            int index = uri.indexOf(':');
-            String transport = (index > 0) ? uri.substring(0, index) : null;
+            String transport = Utils.getURIScheme(uri);
             if (transport != null && ac.getTransportOut(transport) != null) {
                 return ac.getTransportOut(transport);
             } else {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java?rev=777976&r1=777975&r2=777976&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java Sat May
23 17:49:48 2009
@@ -553,4 +553,15 @@
     private static boolean isIP(String hostAddress) {
         return hostAddress.split("[.]").length == 4;
     }
+
+    /**
+     * Get the scheme part from a URI (or URL).
+     * 
+     * @param uri the URI
+     * @return the scheme of the URI
+     */
+    public static String getURIScheme(String uri) {
+        int index = uri.indexOf(':');
+        return index > 0 ? uri.substring(0, index) : null;
+    }
 }



Mime
View raw message