axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Barham (JIRA)" <j...@apache.org>
Subject [jira] Created: (AXIS2-674) Java2WSDLUtils fails to generate WSDL where a class's package could not be found
Date Fri, 05 May 2006 13:36:28 GMT
Java2WSDLUtils fails to generate WSDL where a class's package could not be found
--------------------------------------------------------------------------------

         Key: AXIS2-674
         URL: http://issues.apache.org/jira/browse/AXIS2-674
     Project: Apache Axis 2.0 (Axis2)
        Type: Bug

  Components: deployment  
    Versions: 1.0    
    Reporter: Steve Barham
    Priority: Critical


The Java2WSDL class defines the following method to find the namespace for a class:

 public static StringBuffer namespaceFromClassName(String className , ClassLoader classLoader)
throws Exception
 {
    	return namespaceFromPackageName(Class.forName(className, true, classLoader).getPackage().getName());
 }

Unfortunately, Class.getPackage() may return null when:
1. the package for a class does not exist (ie. a top level class) 
2. where the package has not been loaded. 

Suggestion:
1. Document that classes must reside in a package, or define a default namespace to be assigned
to top level classes
2. Add an alternate mechanism of determining the package of a class (see below)

    public static StringBuffer namespaceFromClassName(String className , ClassLoader classLoader)
throws Exception
    {
        Class clazz = Class.forName(className, true, classLoader);
        Package pkg = clazz.getPackage();
        String name;

        if (pkg != null)
            name = pkg.getName();
        else
            name = packageNameFromClass(clazz.getName());

        return namespaceFromPackageName(name);
    }

    protected static String packageNameFromClass(String name)
    {
        String ret = new String();
        int lastDot = name.lastIndexOf ('.');

        if (lastDot != -1)
             ret = name.substring(lastDot + 1);
        
        return ret;
    }

Rgds

steve

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message