You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by da...@apache.org on 2007/01/25 19:50:25 UTC

svn commit: r499897 - /webservices/muse/trunk/modules/muse-core/src/org/apache/muse/ws/wsdl/WsdlUtils.java

Author: danj
Date: Thu Jan 25 10:50:25 2007
New Revision: 499897

URL: http://svn.apache.org/viewvc?view=rev&rev=499897
Log:
Removed use of java.util.regex.* so that we can compile against J2ME FP 1.1. Only method that 
used this package is getServiceName(), which is used by wsdl2java.

Modified:
    webservices/muse/trunk/modules/muse-core/src/org/apache/muse/ws/wsdl/WsdlUtils.java

Modified: webservices/muse/trunk/modules/muse-core/src/org/apache/muse/ws/wsdl/WsdlUtils.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-core/src/org/apache/muse/ws/wsdl/WsdlUtils.java?view=diff&rev=499897&r1=499896&r2=499897
==============================================================================
--- webservices/muse/trunk/modules/muse-core/src/org/apache/muse/ws/wsdl/WsdlUtils.java (original)
+++ webservices/muse/trunk/modules/muse-core/src/org/apache/muse/ws/wsdl/WsdlUtils.java Thu Jan 25 10:50:25 2007
@@ -19,8 +19,6 @@
 package org.apache.muse.ws.wsdl;
 
 import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -28,8 +26,6 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import javax.wsdl.Definition;
 import javax.wsdl.Input;
@@ -797,31 +793,36 @@
     public static String getServiceName(Element wsdlDefinition)
     {
         Element address = XmlUtils.findFirstInSubTree(wsdlDefinition, WsdlUtils.ADDRESS_QNAME);
-        if (address != null)
-        {
-            String location = address.getAttribute(WsdlUtils.LOCATION);
-
-            if (location != null && location.length() > 0)
-            {
-                try
-                {
-                    URL url = new URL(location);
-                    Pattern pattern = Pattern.compile(SERVICES + "/([A-Za-z0-9_.]+)");
-                    Matcher matcher = pattern.matcher(url.getPath());
-                    if (matcher.find())
-                    {
-                        String serviceName = matcher.group(1);
-                        if (serviceName.length() > 0)
-                            return serviceName;
-                    }
-                }
-                catch (MalformedURLException e)
-                {
-                    //handled by falling through to bottom
-                }
-            }
-        }
-        return DEFAULT_SERVICE_NAME;
+        
+        if (address == null)
+            return DEFAULT_SERVICE_NAME;
+        
+        String location = address.getAttribute(WsdlUtils.LOCATION);
+        
+        if (location == null)
+            return DEFAULT_SERVICE_NAME;
+        
+        //
+        // see if the 'location' has a URI with /services/ in it
+        //
+        int servicesStart = location.indexOf(SERVICES);
+        
+        //
+        // if not, it's not for a SOAP engine we know about, so 
+        // we go with the default
+        //
+        if (servicesStart < 0)
+            return DEFAULT_SERVICE_NAME;
+        
+        //
+        // otherwise, we take the last token after /services/
+        //
+        int serviceNameStart = servicesStart + SERVICES.length();
+        
+        if (serviceNameStart == location.length())
+            return DEFAULT_SERVICE_NAME;
+        
+        return location.substring(serviceNameStart);
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org