axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r394915 - in /webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl: Java2OMBuilder.java Java2WSDLBuilder.java Java2WSDLCodegenEngine.java Java2WSDLUtils.java SchemaGenerator.java
Date Tue, 18 Apr 2006 11:14:43 GMT
Author: deepal
Date: Tue Apr 18 04:14:41 2006
New Revision: 394915

URL: http://svn.apache.org/viewcvs?rev=394915&view=rev
Log:
- applying the patch 
http://issues.apache.org/jira/browse/AXIS2-544

thx for the patch

Added:
    webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLUtils.java
Modified:
    webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2OMBuilder.java
    webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java
    webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLCodegenEngine.java
    webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java

Modified: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2OMBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2OMBuilder.java?rev=394915&r1=394914&r2=394915&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2OMBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2OMBuilder.java
Tue Apr 18 04:14:41 2006
@@ -27,7 +27,6 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
-* @author : Deepal Jayasinghe (deepal@apache.org)
 *
 */
 
@@ -37,6 +36,7 @@
     private XmlSchema schema;
     private String serviceName;
     private String targetNamespace;
+    private String targetNamespacePrefix;
     private OMNamespace ns1;
     private OMNamespace soap;
     private OMNamespace tns;
@@ -50,6 +50,7 @@
                           XmlSchema schema,
                           String serviceName,
                           String targetNamespace,
+                          String targetNamespacePrefix,
                           String style,
                           String use,
                           String locationURL) {
@@ -78,6 +79,12 @@
         } else {
             this.targetNamespace = DEFAULT_TARGET_NAMESPACE;
         }
+        
+        if (targetNamespacePrefix != null && !targetNamespacePrefix.trim().equals(""))
{
+            this.targetNamespacePrefix = targetNamespacePrefix;
+        } else {
+            this.targetNamespacePrefix = TARGETNAMESPACE_PREFIX;
+        }
     }
 
     public OMElement generateOM() throws Exception {
@@ -85,11 +92,17 @@
         wsdl = fac.createOMNamespace(WSDL_NAMESPACE,
                 DEFAULT_WSDL_NAMESPACE_PREFIX);
         OMElement ele = fac.createOMElement("definitions", wsdl);
-        ns1 = ele.declareNamespace(AXIS2_XSD, "ns1");
+        
+        //ns1 = ele.declareNamespace(AXIS2_XSD, "ns1");
+        ns1 = ele.declareNamespace(this.schema.getTargetNamespace(), "ns1");
+        
         ele.declareNamespace(URI_2001_SCHEMA_XSD, DEFAULT_SCHEMA_NAMESPACE_PREFIX);
         soap = ele.declareNamespace(URI_WSDL11_SOAP, SOAP11_PREFIX);
-        tns = ele.declareNamespace(DEFAULT_TARGET_NAMESPACE, TARGETNAMESPACE_PREFIX);
-        ele.addAttribute("targetNamespace", DEFAULT_TARGET_NAMESPACE, null);
+        
+        //tns = ele.declareNamespace(DEFAULT_TARGET_NAMESPACE, TARGETNAMESPACE_PREFIX);
+        tns = ele.declareNamespace(targetNamespace, targetNamespacePrefix);
+        
+        ele.addAttribute("targetNamespace", targetNamespace, null);
         OMElement wsdlTypes = fac.createOMElement("types", wsdl);
         StringWriter writer = new StringWriter();
         schema.write(writer);

Modified: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java?rev=394915&r1=394914&r2=394915&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
Tue Apr 18 04:14:41 2006
@@ -137,8 +137,9 @@
         XmlSchema schema = sg.generateSchema();
         Java2OMBuilder java2OMBuilder = new Java2OMBuilder(sg.getMethods(),
                 schema,
-                serviceName == null ? simpleClassName(className) : serviceName,
-                targetNamespace,
+                serviceName == null ? Java2WSDLUtils.getSimpleClassName(className) : serviceName,
+                targetNamespace == null ? Java2WSDLUtils.namespaceFromPackageName(className).toString():targetNamespace,
+                targetNamespacePrefix,
                 style,
                 use,
                 locationUri);
@@ -146,19 +147,6 @@
         wsdlElemnet.serialize(out);
         out.flush();
         out.close();
-    }
-
-    /**
-     * A method to strip the fully qualified className to a simple classname
-     *
-     * @param qualifiedName
-     */
-    private String simpleClassName(String qualifiedName) {
-        int index = qualifiedName.lastIndexOf(".");
-        if (index > 0) {
-            return qualifiedName.substring(index + 1, qualifiedName.length());
-        }
-        return qualifiedName;
     }
 }
 

Modified: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLCodegenEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLCodegenEngine.java?rev=394915&r1=394914&r2=394915&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLCodegenEngine.java
(original)
+++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLCodegenEngine.java
Tue Apr 18 04:14:41 2006
@@ -59,7 +59,7 @@
         String outputFileName = option == null ? null : option.getOptionValue();
         //derive a file name from the class name if the filename is not specified
         if (outputFileName == null) {
-            outputFileName = getSimpleClassName(className) + WSDL_FILENAME_SUFFIX;
+            outputFileName = Java2WSDLUtils.getSimpleClassName(className) + WSDL_FILENAME_SUFFIX;
         }
 
         //first create a file in the given location
@@ -90,7 +90,7 @@
                 for (int i = 0; i < classPathEntries.length; i++) {
                     String classPathEntry = classPathEntries[i];
                     //this should be a file(or a URL)
-                    if (isURL(classPathEntry)) {
+                    if (Java2WSDLUtils.isURL(classPathEntry)) {
                         urls[i] = new URL(classPathEntry);
                     } else {
                         urls[i] = new File(classPathEntry).toURL();
@@ -130,7 +130,7 @@
 
         option = loadOption(Java2WSDLConstants.SERVICE_NAME_OPTION,
                 Java2WSDLConstants.SERVICE_NAME_OPTION_LONG, optionsMap);
-        java2WsdlBuilder.setServiceName(option == null ? getSimpleClassName(className) :
option.getOptionValue());
+        java2WsdlBuilder.setServiceName(option == null ? Java2WSDLUtils.getSimpleClassName(className)
: option.getOptionValue());
 
         option = loadOption(Java2WSDLConstants.STYLE_OPTION,
                 Java2WSDLConstants.STYLE_OPTION, optionsMap);
@@ -161,17 +161,7 @@
         }
     }
 
-    /**
-     * check the entry for a URL. This is a simple check and need to be improved
-     *
-     * @param entry
-     */
-
-    private boolean isURL(String entry) {
-        return entry.startsWith("http://");
-    }
-
-    /**
+     /**
      * @param shortOption
      * @param longOption
      * @param options
@@ -190,18 +180,5 @@
         }
 
         return option;
-    }
-
-    /**
-     * A method to strip the fully qualified className to a simple classname
-     *
-     * @param qualifiedName
-     */
-    private String getSimpleClassName(String qualifiedName) {
-        int index = qualifiedName.lastIndexOf(".");
-        if (index > 0) {
-            return qualifiedName.substring(index + 1, qualifiedName.length());
-        }
-        return qualifiedName;
     }
 }

Added: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLUtils.java?rev=394915&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLUtils.java
(added)
+++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLUtils.java
Tue Apr 18 04:14:41 2006
@@ -0,0 +1,71 @@
+package org.apache.ws.java2wsdl;
+
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.
+*
+*/
+
+
+public class Java2WSDLUtils
+{
+	public static final String HTTP = "http://";
+	public static final char PACKAGE_CLASS_DELIMITER = '.';
+	public static final String SCHEMA_NAMESPACE_EXTN = "/xsd";
+	/**
+     * check the entry for a URL. This is a simple check and need to be improved
+     *
+     * @param entry
+     */
+
+    public static boolean isURL(String entry) {
+        return entry.startsWith("http://");
+    }
+    
+    /**
+     * A method to strip the fully qualified className to a simple classname
+     *
+     * @param qualifiedName
+     */
+    public static String getSimpleClassName(String qualifiedName) {
+        int index = qualifiedName.lastIndexOf(".");
+        if (index > 0) {
+            return qualifiedName.substring(index + 1, qualifiedName.length());
+        }
+        return qualifiedName;
+    }
+    
+    public static StringBuffer namespaceFromPackageName(String packageName)
+	{
+		StringBuffer strBuf = new StringBuffer(HTTP);
+		int prevIndex = packageName.length();
+		int currentIndex = packageName.lastIndexOf(PACKAGE_CLASS_DELIMITER);
+		while( currentIndex != -1 )
+		{
+			prevIndex = currentIndex;
+			currentIndex = packageName.lastIndexOf(PACKAGE_CLASS_DELIMITER, prevIndex - 1);
+			strBuf.append(packageName.substring(currentIndex + 1, prevIndex));
+			if ( currentIndex != -1 )
+			{
+				strBuf.append(PACKAGE_CLASS_DELIMITER);
+			}
+		}
+		return strBuf;
+	}
+    
+    public static StringBuffer schemaNamespaceFromPackageName(String packageName)
+	{
+		return namespaceFromPackageName(packageName).append(SCHEMA_NAMESPACE_EXTN);
+	}
+}

Modified: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java?rev=394915&r1=394914&r2=394915&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java
(original)
+++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java
Tue Apr 18 04:14:41 2006
@@ -54,7 +54,7 @@
         if (schematargetNamespace != null && !schematargetNamespace.trim().equals(""))
{
             this.schemaTargetNameSpace = schematargetNamespace;
         } else {
-            this.schemaTargetNameSpace = Java2WSDLConstants.AXIS2_XSD;
+            this.schemaTargetNameSpace = Java2WSDLUtils.schemaNamespaceFromPackageName(className).toString();//Java2WSDLConstants.AXIS2_XSD;
         }
         if (schematargetNamespacePrefix != null && !schematargetNamespacePrefix.trim().equals(""))
{
             this.schema_namespace_prefix = schematargetNamespacePrefix;



Mime
View raw message