Author: david.boeren
Date: 2008-06-27 12:04:15 -0400 (Fri, 27 Jun 2008)
New Revision: 7759
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/WSDLToJava.java
Log:
Restore Magesh's changes that got overwritten.
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/WSDLToJava.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/WSDLToJava.java 2008-06-27
15:14:42 UTC (rev 7758)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/WSDLToJava.java 2008-06-27
16:04:15 UTC (rev 7759)
@@ -205,7 +205,7 @@
if (namespacePackageMap == null)
namespacePackageMap = new HashMap<String, String>();
String pkg = iter.next();
- namespacePackageMap.put(map.get(pkg), pkg);
+ namespacePackageMap.put(pkg, map.get(pkg));
}
}
@@ -326,7 +326,6 @@
JBossXSModel xsmodel = WSDLUtils.getSchemaModel(wsdl.getWsdlTypes());
QName faultXMLName = intfFault.getElement();
QName faultXMLType = intfFault.getXmlType();
-
XSElementDeclaration xe =
xsmodel.getElementDeclaration(faultXMLName.getLocalPart(),
faultXMLName.getNamespaceURI());
XSTypeDefinition xt = xe.getTypeDefinition();
if (!xt.getAnonymous())
@@ -338,7 +337,8 @@
if (cl == null)
{
String faultTypeName = (!xt.getAnonymous()) ? faultXMLType.getLocalPart()
: faultXMLName.getLocalPart();
- buf.append(seiPkgName + "." +
JavaUtils.capitalize(faultTypeName));
+ String packageName = getPackageName(xt.getNamespace());
+ buf.append(packageName + "." +
JavaUtils.capitalize(faultTypeName));
}
else buf.append(cl.getName());
buf.append(",");
@@ -534,7 +534,6 @@
if (unwrappedElement)
{
buf.append(tempBuf);
-
// We need a wrapper class generated
generateJavaSource(wrapper, WSDLUtils.getSchemaModel(wsdl.getWsdlTypes()),
containingElement);
@@ -639,11 +638,12 @@
className = className.substring(1);
className = ToolsUtils.convertInvalidCharacters(className);
className = utils.firstLetterUpperCase(className);
- className = seiPkgName + "." + className + arraySuffix;
+ String packageName = getPackageName(xt.getNamespace());
+ className = packageName + "." + className + arraySuffix;
if (holder)
{
- className = holderWriter.getOrCreateHolder(className,
getLocationForJavaGeneration());
+ className = holderWriter.getOrCreateHolder(className,
getLocationForJavaGeneration(packageName));
}
buf.append(className);
@@ -762,7 +762,8 @@
className = className.substring(1);
className = ToolsUtils.convertInvalidCharacters(className);
className = utils.firstLetterUpperCase(className);
- return seiPkgName + "." + className + arraySuffix;
+ String packageName = getPackageName(xt.getNamespace());
+ return packageName + "." + className + arraySuffix;
}
if (cls.isArray())
@@ -806,9 +807,9 @@
return paramName;
}
- private File getLocationForJavaGeneration()
+ private File getLocationForJavaGeneration(String packageName)
{
- return new File(this.directoryToGenerate + "/" +
seiPkgName.replace(".", "/"));
+ return new File(this.directoryToGenerate + "/" +
packageName.replace('.', '/'));
}
private void generateJavaSource(XSComplexTypeDefinition xt, JBossXSModel xsmodel,
String containingElement) throws IOException
@@ -818,10 +819,16 @@
private void generateJavaSource(XSComplexTypeDefinition xt, JBossXSModel xsmodel,
String containingElement, boolean exception) throws IOException
{
- XSDTypeToJava xtj = new XSDTypeToJava(generateSerializableTypes);
-
+ XSDTypeToJava xtj = new XSDTypeToJava(namespacePackageMap,
generateSerializableTypes);
xtj.setTypeMapping(this.typeMapping);
- xtj.createJavaFile((XSComplexTypeDefinition)xt, containingElement,
getLocationForJavaGeneration(), seiPkgName, xsmodel, exception);
+ String targetNS = wsdl.getTargetNamespace();
+ String tgtNS = xt.getNamespace();
+ String packName = getPackageName(tgtNS);
+ if(!tgtNS.equals(targetNS))
+ {
+ File dir = utils.createPackage(this.directoryToGenerate, packName);
+ }
+ xtj.createJavaFile((XSComplexTypeDefinition)xt, containingElement,
this.directoryToGenerate, packName, xsmodel, exception);
}
public void setParameterStyle(String paramStyle)
@@ -829,4 +836,20 @@
this.parameterStyle = paramStyle;
}
+ private String getPackageName(String targetNamespace)
+ {
+ //Get it from global config
+ if (namespacePackageMap != null)
+ {
+ String pkg = namespacePackageMap.get(targetNamespace);
+ if (pkg != null)
+ {
+ return pkg;
+ }
+ }
+ //return NamespacePackageMapping.getJavaPackageName(targetNamespace);
+ //Default behaviour will always generate all classes in the SEI package only
+ return seiPkgName;
+ }
}
+