Author: darran.lofthouse(a)jboss.com
Date: 2008-08-04 08:28:55 -0400 (Mon, 04 Aug 2008)
New Revision: 8000
Modified:
stack/native/branches/dlofthouse/JBPAPP-904/src/main/java/org/jboss/ws/tools/WSDLToJava.java
stack/native/branches/dlofthouse/JBPAPP-904/src/main/java/org/jboss/ws/tools/XSDToJava.java
stack/native/branches/dlofthouse/JBPAPP-904/src/main/java/org/jboss/ws/tools/XSDTypeToJava.java
stack/native/branches/dlofthouse/JBPAPP-904/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java
Log:
Backported -r 5787
Modified:
stack/native/branches/dlofthouse/JBPAPP-904/src/main/java/org/jboss/ws/tools/WSDLToJava.java
===================================================================
---
stack/native/branches/dlofthouse/JBPAPP-904/src/main/java/org/jboss/ws/tools/WSDLToJava.java 2008-08-04
12:20:57 UTC (rev 7999)
+++
stack/native/branches/dlofthouse/JBPAPP-904/src/main/java/org/jboss/ws/tools/WSDLToJava.java 2008-08-04
12:28:55 UTC (rev 8000)
@@ -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())
@@ -535,7 +534,6 @@
if (unwrappedElement)
{
buf.append(tempBuf);
-
// We need a wrapper class generated
generateJavaSource(wrapper, WSDLUtils.getSchemaModel(wsdl.getWsdlTypes()),
containingElement);
@@ -822,7 +820,7 @@
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);
String targetNS = wsdl.getTargetNamespace();
@@ -832,7 +830,7 @@
{
File dir = utils.createPackage(this.directoryToGenerate, packName);
}
- xtj.createJavaFile((XSComplexTypeDefinition)xt, containingElement,
getLocationForJavaGeneration(packName), packName, xsmodel, exception);
+ xtj.createJavaFile((XSComplexTypeDefinition)xt, containingElement,
this.directoryToGenerate, packName, xsmodel, exception);
}
public void setParameterStyle(String paramStyle)
@@ -851,7 +849,6 @@
return pkg;
}
}
-
//return NamespacePackageMapping.getJavaPackageName(targetNamespace);
//Default behaviour will always generate all classes in the SEI package only
return seiPkgName;
Modified:
stack/native/branches/dlofthouse/JBPAPP-904/src/main/java/org/jboss/ws/tools/XSDToJava.java
===================================================================
---
stack/native/branches/dlofthouse/JBPAPP-904/src/main/java/org/jboss/ws/tools/XSDToJava.java 2008-08-04
12:20:57 UTC (rev 7999)
+++
stack/native/branches/dlofthouse/JBPAPP-904/src/main/java/org/jboss/ws/tools/XSDToJava.java 2008-08-04
12:28:55 UTC (rev 8000)
@@ -55,7 +55,8 @@
/**
* Utility class that converts a XSD Type into a Java class
*/
- protected XSDTypeToJava xsdJava = new XSDTypeToJava(false);
+ protected final XSDTypeToJava xsdJava = new XSDTypeToJava(null, false);
+
/*
* @see org.jboss.ws.tools.interfaces.JavaToXSDIntf#generateSEI(java.lang.String,
java.io.File, java.lang.String, boolean)
@@ -66,9 +67,7 @@
{
XSLoader xsloader = SchemaUtils.getInstance().getXSLoader();
XSModel xsmodel = xsloader.loadURI(schemaFile);
-
- if (createPackageDir) dirloc = utils.createPackage(dirloc.getAbsolutePath(),
packageName);
- generateJavaSource(xsmodel, dirloc, packageName);
+ generateJavaSource(xsmodel, dirloc, packageName, createPackageDir);
}
@@ -79,7 +78,10 @@
boolean createPackageDir)
throws IOException
{
- if (createPackageDir) dirloc = utils.createPackage(dirloc.getAbsolutePath(),
packageName);
+ if (createPackageDir)
+ {
+ utils.createPackage(dirloc.getAbsolutePath(), packageName);
+ }
generateJavaSource(xsmodel, dirloc, packageName);
}
@@ -102,7 +104,7 @@
String nsuri = type.getNamespace();
String tname = type.getName();
if (Constants.NS_SCHEMA_XSD.equals(nsuri) &&
"anyType".equals(tname)) continue;
- xsdJava.createJavaFile(ctype, dirloc, packageName, xsmodel);
+ xsdJava.createJavaFile(ctype, dirloc.getPath(), packageName, xsmodel);
}
else if (type instanceof XSSimpleTypeDefinition)
{
@@ -111,7 +113,7 @@
String nsuri = type.getNamespace();
String tname = type.getName();
if (Constants.NS_SCHEMA_XSD.equals(nsuri) &&
"anyType".equals(tname)) continue;
- xsdJava.createJavaFile(stype, dirloc, packageName, xsmodel);
+ xsdJava.createJavaFile(stype, dirloc.getPath(), packageName, xsmodel);
}
}
@@ -152,7 +154,7 @@
String str = "Method should be used for anon complex types only";
if (type.getName() != null)
throw new IllegalArgumentException(str);
- xsdJava.createJavaFile(type,outerElementName, loc,pkgname,schema, false);
+ xsdJava.createJavaFile(type,outerElementName,loc.getPath(),pkgname,schema, false);
}
}
Modified:
stack/native/branches/dlofthouse/JBPAPP-904/src/main/java/org/jboss/ws/tools/XSDTypeToJava.java
===================================================================
---
stack/native/branches/dlofthouse/JBPAPP-904/src/main/java/org/jboss/ws/tools/XSDTypeToJava.java 2008-08-04
12:20:57 UTC (rev 7999)
+++
stack/native/branches/dlofthouse/JBPAPP-904/src/main/java/org/jboss/ws/tools/XSDTypeToJava.java 2008-08-04
12:28:55 UTC (rev 8000)
@@ -71,13 +71,15 @@
//Additional variables
protected String containingElement = "";
protected String fname = "";
- protected File loc = null;
+ protected String loc = null;
protected String pkgname = "";
private Set<String> generatedFiles = new HashSet<String>();
protected boolean serializableTypes;
+ protected Map<String, String> namespacePackageMap = null;
+
/**
* List that is used for exception inheritance case wherein the variables
* obtained from the base class go into the generated constructor alone and
@@ -85,12 +87,13 @@
*/
private Map<String, List> typeNameToBaseVARList = new HashMap<String,
List>();
- public XSDTypeToJava(boolean serializableTypes)
+ public XSDTypeToJava(Map<String, String> map, boolean serializableTypes)
{
+ this.namespacePackageMap = map;
this.serializableTypes = serializableTypes;
}
- public void createJavaFile(XSComplexTypeDefinition type, File loc, String pkgname,
XSModel schema) throws IOException
+ public void createJavaFile(XSComplexTypeDefinition type, String loc, String pkgname,
XSModel schema) throws IOException
{
if (typeMapping == null)
throw new WSException("TypeMapping has not been set");
@@ -103,7 +106,7 @@
createJavaFile(type, schema, false);
}
- public void createJavaFile(XSComplexTypeDefinition type, String containingElement,
File loc, String pkgname, XSModel schema, boolean isExceptionType)
+ public void createJavaFile(XSComplexTypeDefinition type, String containingElement,
String loc, String pkgname, XSModel schema, boolean isExceptionType)
throws IOException
{
if (typeMapping == null)
@@ -118,7 +121,7 @@
createJavaFile(type, schema, isExceptionType);
}
- public void createJavaFile(XSSimpleTypeDefinition type, File loc, String pkgname,
XSModel schema) throws IOException
+ public void createJavaFile(XSSimpleTypeDefinition type, String loc, String pkgname,
XSModel schema) throws IOException
{
if (typeMapping == null)
throw new WSException("TypeMapping has not been set");
@@ -156,9 +159,16 @@
vars = this.getVARList(type, schema, isExceptionType);
if (baseName == null && isExceptionType)
+ {
baseName = "Exception";
- jwriter.createJavaFile(loc, fname, pkgname, vars, null, baseName, isExceptionType,
serializableTypes, typeNameToBaseVARList);
-
+ }
+ else if (baseName != null)
+ {
+ baseName = getPackageName(baseType.getNamespace()) + "." + baseName;
+ }
+ String packageName = getPackageName(type.getNamespace());
+ jwriter.createJavaFile(getLocationForJavaGeneration(packageName), fname,
packageName, vars, null, baseName, isExceptionType, serializableTypes,
+ typeNameToBaseVARList);
}
public void createJavaFile(XSSimpleTypeDefinition xsSimple, XSModel schema) throws
IOException
@@ -175,7 +185,8 @@
if (slist != null && slist.getLength() > 0)
{
//Enumerated List
- jwriter.createJavaFileForEnumeratedValues(fname, slist, loc, pkgname,
xsSimple);
+ String packageName = getPackageName(xsSimple.getNamespace());
+ jwriter.createJavaFileForEnumeratedValues(fname, slist,
getLocationForJavaGeneration(packageName), packageName, xsSimple);
}
else
{
@@ -272,6 +283,16 @@
this.typeMapping = tm;
}
+ public Map<String, String> getNamespacePackageMap()
+ {
+ return namespacePackageMap;
+ }
+
+ public void setNamespacePackageMap(Map<String, String> map)
+ {
+ this.namespacePackageMap = map;
+ }
+
//PRIVATE METHODS
private void
handleContentTypeElementsWithDerivationRestriction(XSComplexTypeDefinition type, XSModel
schema, List vars, XSParticle xsparticle) throws IOException
@@ -429,7 +450,7 @@
XSSimpleTypeDefinition xstype = att.getTypeDefinition();
QName qn = SchemaUtils.handleSimpleType(xstype);
boolean primitive = obj.getRequired();
- VAR v = createVAR(qn, att.getName(), pkgname, primitive);
+ VAR v = createVAR(qn, att.getName(), getPackageName(xstype.getNamespace()),
primitive);
if (vars == null)
vars = new ArrayList();
vars.add(v);
@@ -569,7 +590,7 @@
{
// it is a composite type
QName qn = new QName(origType.getNamespace(), origType.getName());
- VAR vr = createVAR(qn, elem, (XSComplexTypeDefinition)xstypedef, tname, pkgname,
arrayType);
+ VAR vr = createVAR(qn, elem, (XSComplexTypeDefinition)xstypedef, tname,
getPackageName(origType.getNamespace()), arrayType);
vars.add(vr);
return vars;
}
@@ -608,7 +629,7 @@
this.fname = tempfname;
// Bypass rest of processing
QName anonqn = new QName(anonName);
- VAR vr = createVAR(anonqn, elem, xsc, tname, pkgname, arrayType);
+ VAR vr = createVAR(anonqn, elem, xsc, tname, getPackageName(xsc.getNamespace()),
arrayType);
vars.add(vr);
return vars;
}
@@ -647,7 +668,7 @@
this.fname = temp;
}
- VAR v = createVAR(qn, elem, xstypedef, tname, pkgname, arrayType);
+ VAR v = createVAR(qn, elem, xstypedef, tname,
getPackageName(xstypedef.getNamespace()), arrayType);
vars.add(v);
}
return vars;
@@ -768,4 +789,25 @@
isArrayType = arrayType;
}
}
+
+ private File getLocationForJavaGeneration(String packageName)
+ {
+ File locdir = new File(this.loc);
+ locdir = wsdlUtils.createPackage(locdir.getAbsolutePath(), packageName);
+ return locdir;
+ }
+
+ private String getPackageName(String targetNamespace)
+ {
+ //Get it from global config
+ if (namespacePackageMap != null)
+ {
+ String pkg = namespacePackageMap.get(targetNamespace);
+ if (pkg != null)
+ {
+ return pkg;
+ }
+ }
+ return this.pkgname;
+ }
}
Modified:
stack/native/branches/dlofthouse/JBPAPP-904/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java
===================================================================
---
stack/native/branches/dlofthouse/JBPAPP-904/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java 2008-08-04
12:20:57 UTC (rev 7999)
+++
stack/native/branches/dlofthouse/JBPAPP-904/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java 2008-08-04
12:28:55 UTC (rev 8000)
@@ -950,7 +950,7 @@
String targetNS = wsdlDefinitions.getTargetNamespace();
MethodParamPartsMapping mppm = new MethodParamPartsMapping(semm);
mppm.setParamPosition(paramPosition);
- String javaType = getJavaTypeAsString(xmlName, xmlType, targetNS, array,
primitive);
+ String javaType = getJavaTypeAsString(xmlName, xmlType, xmlType.getNamespaceURI(),
array, primitive);
mppm.setParamType(javaType);
//WSDL Message Mapping