Author: darran.lofthouse(a)jboss.com
Date: 2007-04-11 17:16:27 -0400 (Wed, 11 Apr 2007)
New Revision: 2809
Added:
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/tools/HolderWriter.java
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/Person.java
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/PersonHolder.java
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/PhoneBook_PortType.java
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/jaxrpc-mapping.xml
Removed:
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/OUT_unlisted/
Modified:
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLUtils.java
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/tools/WSDLToJava.java
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/tools/XSDToJava.java
branches/dlofthouse/JBWS-429/jbossws-tests/src/java/org/jboss/test/ws/tools/jbws429/JBWS429TestCase.java
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/PhoneBook.wsdl
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/wstools-config.xml
Log:
Implementation of Holder generation and doc/lit test case.
Modified:
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLUtils.java
===================================================================
---
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLUtils.java 2007-04-11
19:19:43 UTC (rev 2808)
+++
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLUtils.java 2007-04-11
21:16:27 UTC (rev 2809)
@@ -1,24 +1,24 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
package org.jboss.ws.metadata.wsdl;
import java.io.File;
@@ -92,10 +92,10 @@
private final Map primitiveMap = new HashMap();
- private final static Map<String,Class> schemaBasicTypes = new
HashMap<String,Class>();
+ private final static Map<String, Class> schemaBasicTypes = new
HashMap<String, Class>();
- private final static Map<Class,Class> holderTypes = new
HashMap<Class,Class>();
- private final static Map<Class,Class> reverseHolderTypes = new
HashMap<Class,Class>();
+ private final static Map<Class, Class> holderTypes = new HashMap<Class,
Class>();
+ private final static Map<Class, Class> reverseHolderTypes = new
HashMap<Class, Class>();
// Skip these methods when generating wsdl operations
private List<String> ignoredMethods;
@@ -119,55 +119,54 @@
static
{
- holderTypes.put(BigDecimal.class,BigDecimalHolder.class);
- holderTypes.put(BigInteger.class,BigIntegerHolder.class);
- holderTypes.put(boolean.class,BooleanHolder.class);
- holderTypes.put(Boolean.class,BooleanWrapperHolder.class);
- holderTypes.put(byte.class,ByteHolder.class);
- holderTypes.put(Byte.class,ByteWrapperHolder.class);
- holderTypes.put(Byte[].class,ByteArrayHolder.class);
- holderTypes.put(Calendar.class,CalendarHolder.class);
- holderTypes.put(double.class,DoubleHolder.class);
- holderTypes.put(Double.class,DoubleWrapperHolder.class);
+ holderTypes.put(BigDecimal.class, BigDecimalHolder.class);
+ holderTypes.put(BigInteger.class, BigIntegerHolder.class);
+ holderTypes.put(boolean.class, BooleanHolder.class);
+ holderTypes.put(Boolean.class, BooleanWrapperHolder.class);
+ holderTypes.put(byte.class, ByteHolder.class);
+ holderTypes.put(Byte.class, ByteWrapperHolder.class);
+ holderTypes.put(Byte[].class, ByteArrayHolder.class);
+ holderTypes.put(Calendar.class, CalendarHolder.class);
+ holderTypes.put(double.class, DoubleHolder.class);
+ holderTypes.put(Double.class, DoubleWrapperHolder.class);
holderTypes.put(float.class, FloatHolder.class);
holderTypes.put(Float.class, FloatWrapperHolder.class);
- holderTypes.put(int.class,IntHolder.class);
- holderTypes.put(Integer.class,IntegerWrapperHolder.class);
- holderTypes.put(long.class,LongHolder.class);
- holderTypes.put(Long.class,LongWrapperHolder.class);
- holderTypes.put(Object.class,ObjectHolder.class);
- holderTypes.put(QName.class,QNameHolder.class);
- holderTypes.put(short.class,ShortHolder.class);
- holderTypes.put(Short.class,ShortWrapperHolder.class);
- holderTypes.put(String.class,StringHolder.class);
+ holderTypes.put(int.class, IntHolder.class);
+ holderTypes.put(Integer.class, IntegerWrapperHolder.class);
+ holderTypes.put(long.class, LongHolder.class);
+ holderTypes.put(Long.class, LongWrapperHolder.class);
+ holderTypes.put(Object.class, ObjectHolder.class);
+ holderTypes.put(QName.class, QNameHolder.class);
+ holderTypes.put(short.class, ShortHolder.class);
+ holderTypes.put(Short.class, ShortWrapperHolder.class);
+ holderTypes.put(String.class, StringHolder.class);
}
static
{
- reverseHolderTypes.put(BigDecimalHolder.class , BigDecimal.class);
- reverseHolderTypes.put(BigIntegerHolder.class , BigInteger.class);
- reverseHolderTypes.put(BooleanHolder.class , boolean.class);
+ reverseHolderTypes.put(BigDecimalHolder.class, BigDecimal.class);
+ reverseHolderTypes.put(BigIntegerHolder.class, BigInteger.class);
+ reverseHolderTypes.put(BooleanHolder.class, boolean.class);
reverseHolderTypes.put(BooleanWrapperHolder.class, Boolean.class);
reverseHolderTypes.put(ByteArrayHolder.class, Byte[].class);
reverseHolderTypes.put(ByteHolder.class, byte.class);
- reverseHolderTypes.put(ByteWrapperHolder.class,Byte.class );
- reverseHolderTypes.put(CalendarHolder.class,Calendar.class);
- reverseHolderTypes.put(DoubleHolder.class,double.class );
- reverseHolderTypes.put(DoubleWrapperHolder.class,Double.class);
- reverseHolderTypes.put(FloatHolder.class,float.class);
+ reverseHolderTypes.put(ByteWrapperHolder.class, Byte.class);
+ reverseHolderTypes.put(CalendarHolder.class, Calendar.class);
+ reverseHolderTypes.put(DoubleHolder.class, double.class);
+ reverseHolderTypes.put(DoubleWrapperHolder.class, Double.class);
+ reverseHolderTypes.put(FloatHolder.class, float.class);
reverseHolderTypes.put(FloatWrapperHolder.class, Float.class);
- reverseHolderTypes.put(IntHolder.class,int.class );
- reverseHolderTypes.put(IntegerWrapperHolder.class,Integer.class );
+ reverseHolderTypes.put(IntHolder.class, int.class);
+ reverseHolderTypes.put(IntegerWrapperHolder.class, Integer.class);
reverseHolderTypes.put(LongHolder.class, long.class);
- reverseHolderTypes.put(LongWrapperHolder.class,Long.class);
- reverseHolderTypes.put(ObjectHolder.class,Object.class);
- reverseHolderTypes.put(QNameHolder.class,QName.class);
- reverseHolderTypes.put(ShortHolder.class,short.class);
- reverseHolderTypes.put(ShortWrapperHolder.class,Short.class);
- reverseHolderTypes.put(StringHolder.class,String.class);
+ reverseHolderTypes.put(LongWrapperHolder.class, Long.class);
+ reverseHolderTypes.put(ObjectHolder.class, Object.class);
+ reverseHolderTypes.put(QNameHolder.class, QName.class);
+ reverseHolderTypes.put(ShortHolder.class, short.class);
+ reverseHolderTypes.put(ShortWrapperHolder.class, Short.class);
+ reverseHolderTypes.put(StringHolder.class, String.class);
}
-
/**
* Singleton - Only way to get an instance
* @return
@@ -220,8 +219,7 @@
//Check baseType is xsd:anyType
if (baseType != null)
{
- if (baseType.getNamespace() == Constants.NS_SCHEMA_XSD &&
- baseType.getName().equals("anyType"))
+ if (baseType.getNamespace() == Constants.NS_SCHEMA_XSD &&
baseType.getName().equals("anyType"))
bool = true; //Ignore this baseType
}
if (XSComplexTypeDefinition.CONTENTTYPE_SIMPLE == t.getContentType())
@@ -233,7 +231,6 @@
}
-
/**
* Check if the class is a Java standard class
* @param cls
@@ -241,13 +238,14 @@
*/
public boolean checkIgnoreClass(Class cls)
{
- if(cls == null)
+ if (cls == null)
throw new IllegalArgumentException("Illegal null argument:cls");
//if (cls.isArray()) cls = cls.getComponentType();
if (!cls.isArray())
{
String pkgname = cls.getPackage() != null ? cls.getPackage().getName() : null;
- if (pkgname != null && pkgname.startsWith("java")) return
true;
+ if (pkgname != null && pkgname.startsWith("java"))
+ return true;
if (ParameterWrapping.WrapperType.class.isAssignableFrom(cls))
return true;
@@ -256,7 +254,6 @@
return false;
}
-
/** Check if this method should be ignored
*/
public boolean checkIgnoreMethod(Method method)
@@ -287,7 +284,6 @@
return ignoreMethod;
}
-
/**
* Chop "PortType" at the end of the String
* @param name
@@ -296,7 +292,8 @@
public String chopPortType(String name)
{
int index = name.lastIndexOf("PortType");
- if (index > 0) return name.substring(0, index);
+ if (index > 0)
+ return name.substring(0, index);
return name;
}
@@ -310,7 +307,8 @@
public String chop(String name, String chopstr)
{
int index = name.lastIndexOf(chopstr);
- if (index > 0) return name.substring(0, index);
+ if (index > 0)
+ return name.substring(0, index);
return name;
}
@@ -321,9 +319,9 @@
*/
public File createPackage(String path, String packageName)
{
- if(packageName == null )
+ if (packageName == null)
throw new IllegalArgumentException("Illegal Null Argument:
packageName");
- if(path == null)
+ if (path == null)
throw new IllegalArgumentException("Illegal Null Argument: path");
String pac = packageName.replace('.', '/');
File dir = new File(path + "/" + pac);
@@ -338,23 +336,22 @@
* @return
* @throws IOException Problem creating the file
*/
- public File createPhysicalFile(File loc, String fname)
- throws IOException
+ public File createPhysicalFile(File loc, String fname) throws IOException
{
- if(loc == null )
+ if (loc == null)
throw new IllegalArgumentException("Illegal Null Argument: loc");
- if(fname == null)
+ if (fname == null)
throw new IllegalArgumentException("Illegal Null Argument: fname");
- File sei = new File(loc.getAbsolutePath() + "/" + fname +
".java");
- //Delete the sei if already exists
- if (sei.exists()) sei.delete();
- boolean boolCreate = sei.createNewFile();
+ File javaFile = new File(loc.getAbsolutePath() + "/" + fname +
".java");
+ //Delete the javaFile if already exists
+ if (javaFile.exists())
+ javaFile.delete();
+ boolean boolCreate = javaFile.createNewFile();
if (!boolCreate)
- throw new WSException("SEI " + fname + ".java cannot be
created");
- return sei;
+ throw new WSException(fname + ".java cannot be created");
+ return javaFile;
}
-
/**
* Create the basic template of a class
* @param pkgname Package Name
@@ -363,10 +360,7 @@
* @param importList Strings representing imports
* @return
*/
- public StringBuilder createClassBasicStructure(String pkgname,
- String fname,
- XSTypeDefinition type,
- List importList, String baseName)
+ public StringBuilder createClassBasicStructure(String pkgname, String fname,
XSTypeDefinition type, List importList, String baseName)
{
StringBuilder buf = new StringBuilder();
writeJbossHeader(buf);
@@ -393,8 +387,7 @@
//Check baseType is xsd:anyType
if (baseType != null)
{
- if (baseType.getNamespace() == Constants.NS_SCHEMA_XSD &&
- baseType.getName().equals("anyType"))
+ if (baseType.getNamespace() == Constants.NS_SCHEMA_XSD &&
baseType.getName().equals("anyType"))
baseType = null; //Ignore this baseType
}
if (XSComplexTypeDefinition.CONTENTTYPE_SIMPLE == t.getContentType())
@@ -404,9 +397,9 @@
}
buf.append("public class " + fname);
- if(baseName == null && baseType != null)
+ if (baseName == null && baseType != null)
baseName = baseType.getName();
- if(baseName != null)
+ if (baseName != null)
buf.append(" extends " + baseName);
buf.append(newline);
buf.append("{");
@@ -421,7 +414,7 @@
* @param name Field name to check
* @return true - if public field exists, false-otherwise
*/
- public boolean doesPublicFieldExist( Class javaType, String name)
+ public boolean doesPublicFieldExist(Class javaType, String name)
{
Field fld = null;
try
@@ -442,7 +435,6 @@
return false;
}
-
/**
* Ensure that the first alphabet is uppercase
* @param fname
@@ -470,10 +462,11 @@
*/
public int getArrayDimension(Class arr)
{
- if(arr == null || arr.isArray() == false)
+ if (arr == null || arr.isArray() == false)
throw new IllegalArgumentException("Illegal null or array arg:arr");
int counter = 0;
- while(arr.isArray()) {
+ while (arr.isArray())
+ {
counter += 1;
arr = arr.getComponentType();
}
@@ -499,14 +492,12 @@
*/
public Class getJavaTypeForHolder(Class cls)
{
- if(Holder.class.isAssignableFrom(cls))
+ if (Holder.class.isAssignableFrom(cls))
return HolderUtils.getValueType(cls);
- else
- return cls;
+ else return cls;
//return reverseHolderTypes.get(cls);
}
-
/**
* An input of "HelloObjArray" is converted into arrayOfHelloObj
* Applied in the input part for WSDL 1.1 Messages
@@ -536,7 +527,8 @@
public static String getJustClassName(Class cls)
{
- if (cls == null) return null;
+ if (cls == null)
+ return null;
if (cls.isArray())
{
Class c = cls.getComponentType();
@@ -557,8 +549,7 @@
int index = classname.lastIndexOf(".");
if (index < 0)
index = 0;
- else
- index = index + 1;
+ else index = index + 1;
return classname.substring(index);
}
@@ -619,7 +610,8 @@
*/
public Class getJavaType(QName xmlType)
{
- if (xmlType == null) return null;
+ if (xmlType == null)
+ return null;
String localPart = xmlType.getLocalPart();
return (Class)schemaBasicTypes.get(localPart);
}
@@ -634,14 +626,13 @@
if (str == null || str.length() == 0)
throw new IllegalArgumentException("String passed to WSDLUtils.getMixedCase
is null");
- if (str.length() == 1) return str.toUpperCase();
+ if (str.length() == 1)
+ return str.toUpperCase();
char[] charr = str.toCharArray();
charr[0] = Character.toUpperCase(charr[0]);
return new String(charr);
}
-
-
/**
* Given a QName, provide a string that is prefix:localpart
* @param qn
@@ -654,7 +645,8 @@
StringBuilder sb = new StringBuilder();
String prefix = qn.getPrefix();
String localpart = qn.getLocalPart();
- if (prefix == null || prefix == "") prefix = Constants.PREFIX_TNS;
+ if (prefix == null || prefix == "")
+ prefix = Constants.PREFIX_TNS;
sb.append(prefix + ":");
sb.append(localpart);
@@ -666,23 +658,22 @@
* @param formattedStr string that is prefix:localpart
* @return QName
*/
- public QName getQName( String formattedStr)
+ public QName getQName(String formattedStr)
{
QName qn = null;
int ind = formattedStr.lastIndexOf(":");
- if(ind < 0)
+ if (ind < 0)
throw new IllegalArgumentException("Formatted String is not of format
prefix:localpart");
- String prefix = formattedStr.substring(0,ind);
+ String prefix = formattedStr.substring(0, ind);
String nsuri = null;
- if(Constants.PREFIX_XSD.equals(prefix)) nsuri = Constants.NS_SCHEMA_XSD;
- if(nsuri == null)
- qn = new QName( formattedStr.substring(ind+1) );
- else
- qn = new QName( nsuri,formattedStr.substring(ind+1),prefix);
+ if (Constants.PREFIX_XSD.equals(prefix))
+ nsuri = Constants.NS_SCHEMA_XSD;
+ if (nsuri == null)
+ qn = new QName(formattedStr.substring(ind + 1));
+ else qn = new QName(nsuri, formattedStr.substring(ind + 1), prefix);
return qn;
}
-
/**
* Return the primitive for a wrapper equivalent (Integer -> int)
* @param str
@@ -721,19 +712,20 @@
StringBuilder sb = new StringBuilder("http://");
//Generate tokens with '.' as delimiter
- StringTokenizer st = new StringTokenizer(packageName,".");
+ StringTokenizer st = new StringTokenizer(packageName, ".");
//Have a LIFO queue for the tokens
Stack<String> stk = new Stack<String>();
- while(st != null && st.hasMoreTokens())
+ while (st != null && st.hasMoreTokens())
{
stk.push(st.nextToken());
}
String next;
- while(!stk.isEmpty() && (next=stk.pop())!=null)
+ while (!stk.isEmpty() && (next = stk.pop()) != null)
{
- if(sb.toString().equals("http://") == false)
sb.append(".");
+ if (sb.toString().equals("http://") == false)
+ sb.append(".");
sb.append(next);
}
@@ -754,26 +746,25 @@
WSDLInterface wi = wsdl.getInterfaces()[0];
WSDLInterfaceOperation wio = wi.getOperations()[0];
String style = wio.getStyle();
- if(style == null || style.equals(Constants.URI_STYLE_RPC) ||
"rpc".equalsIgnoreCase(style))
+ if (style == null || style.equals(Constants.URI_STYLE_RPC) ||
"rpc".equalsIgnoreCase(style))
return Constants.RPC_LITERAL;
- else
- return Constants.DOCUMENT_LITERAL;
+ else return Constants.DOCUMENT_LITERAL;
}
public static JBossXSModel getSchemaModel(WSDLTypes types)
{
if (types instanceof XSModelTypes)
- return ((XSModelTypes) types).getSchemaModel();
+ return ((XSModelTypes)types).getSchemaModel();
throw new WSException("WSDLTypes is not an XSModelTypes");
}
public static void addSchemaModel(WSDLTypes types, String namespace, JBossXSModel
model)
{
- if (! (types instanceof XSModelTypes))
+ if (!(types instanceof XSModelTypes))
throw new WSException("WSDLTypes is not an XSModelTypes");
- XSModelTypes modelTypes = (XSModelTypes) types;
+ XSModelTypes modelTypes = (XSModelTypes)types;
modelTypes.addSchemaModel(namespace, model);
}
@@ -785,10 +776,10 @@
*/
public boolean isStandardHolder(Class cls)
{
- if(Holder.class.isAssignableFrom(cls) == false)
- return false; //Not even a holder
+ if (Holder.class.isAssignableFrom(cls) == false)
+ return false; //Not even a holder
//It is a holder. Is it a standard holder?
- if(cls.getPackage().getName().startsWith("javax.xml.rpc"))
+ if (cls.getPackage().getName().startsWith("javax.xml.rpc"))
return true;
return false;
}
@@ -864,8 +855,10 @@
switch (outputs.length)
{
- case 0: return null;
- case 1: return outputs[0];
+ case 0:
+ return null;
+ case 1:
+ return outputs[0];
}
throw new WSException("Only Request-Only and Request-Response MEPs are
allowed");
@@ -879,8 +872,10 @@
switch (inputs.length)
{
- case 0: return null;
- case 1: return inputs[0];
+ case 0:
+ return null;
+ case 1:
+ return inputs[0];
}
throw new WSException("Only Request-Only and Request-Response MEPs are
allowed");
Added:
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/tools/HolderWriter.java
===================================================================
---
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/tools/HolderWriter.java
(rev 0)
+++
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/tools/HolderWriter.java 2007-04-11
21:16:27 UTC (rev 2809)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.tools;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.HashMap;
+
+import javax.xml.rpc.holders.Holder;
+
+import org.jboss.ws.WSException;
+import org.jboss.ws.metadata.wsdl.WSDLUtils;
+
+/**
+ * Utility class to write JAX-RPC holders.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 11 Apr 2007
+ */
+public class HolderWriter
+{
+
+ private static final WSDLUtils utils = WSDLUtils.getInstance();
+
+ private static final String newline = "\n";
+
+ /**
+ * HashMap of the holders already generated so they do not need to be
+ * generated again.
+ */
+ private HashMap<String, String> createdHolders = new HashMap<String,
String>();
+
+ String getOrCreateHolder(final String type, final File pkgLoc)
+ {
+
+ String fullHolderName = createdHolders.get(type);
+ if (fullHolderName == null)
+ {
+ StringBuilder buf = new StringBuilder();
+ fullHolderName = writeHolder(type, buf);
+
+ createdHolders.put(type, fullHolderName);
+
+ String holderName =
fullHolderName.substring(fullHolderName.lastIndexOf('.') + 1);
+
+ try
+ {
+ File sei = utils.createPhysicalFile(pkgLoc, holderName);
+ FileWriter writer = new FileWriter(sei);
+ writer.write(buf.toString());
+ writer.flush();
+ writer.close();
+ }
+ catch (IOException e)
+ {
+ throw new WSException("Unable to create JAX-RPC holder.", e);
+ }
+ }
+
+ return fullHolderName;
+ }
+
+ private String writeHolder(final String type, final StringBuilder buf)
+ {
+ String pkg = type.substring(0, type.lastIndexOf('.'));
+ String typeName = type.substring(type.lastIndexOf('.') + 1);
+ String holderName = typeName + "Holder";
+
+ utils.writeJbossHeader(buf);
+ buf.append(newline);
+ buf.append("package
").append(pkg).append(";").append(newline);
+
+ buf.append(newline);
+ buf.append("public class ").append(holderName).append(" implements
").append(Holder.class.getName());
+ buf.append(newline).append("{").append(newline);
+
+ // Add the public member variable.
+ buf.append(newline);
+ buf.append(" public ").append(type).append(" value;");
+ buf.append(newline);
+
+ // Add the default constructor.
+ buf.append(newline);
+ buf.append(" ").append("public
").append(holderName).append("()").append(newline);
+ buf.append(" {").append(newline);
+ buf.append(" this.value = new
").append(type).append("();").append(newline);
+ buf.append(" }").append(newline);
+
+ // Add the second constructor.
+ buf.append(newline);
+ buf.append(" ").append("public
").append(holderName).append("(final ").append(type).append("
value)").append(newline);
+ buf.append(" {").append(newline);
+ buf.append(" this.value = value;").append(newline);
+ buf.append(" }").append(newline);
+ buf.append(newline);
+
+ buf.append("}").append(newline);
+ return pkg + "." + holderName;
+ }
+
+}
Property changes on:
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/tools/HolderWriter.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/tools/WSDLToJava.java
===================================================================
---
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/tools/WSDLToJava.java 2007-04-11
19:19:43 UTC (rev 2808)
+++
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/tools/WSDLToJava.java 2007-04-11
21:16:27 UTC (rev 2809)
@@ -80,7 +80,6 @@
{
private String newline = "\n";
- //protected LiteralTypeMapping typeMapping = new LiteralTypeMapping();
protected LiteralTypeMapping typeMapping = null;
protected WSDLDefinitions wsdl = null;
@@ -90,14 +89,12 @@
*/
protected WSDLUtils utils = WSDLUtils.getInstance();
- //protected XSDToJavaIntf xsdJava = new XSDToJava();
-
//Feature Set
protected boolean annotate = false;
protected Map<String, String> namespacePackageMap = null;
- //private String wsdlStyle = Constants.RPC_LITERAL;
+ protected HolderWriter holderWriter = new HolderWriter();
private String seiPkgName = "";
@@ -378,12 +375,12 @@
boolean holder = false;
if (input != null && input.getElement() != null)
{
- QName xmlName = input.getElement();
+ QName xmlName = input.getElement();
holder = output != null && xmlName.equals(output.getElement());
-
+
appendParameters(paramBuffer, input, output, xmlName.getLocalPart());
}
-
+
if (!holder && output != null && output.getElement() != null)
{
QName xmlName = output.getElement();
@@ -569,8 +566,15 @@
if (className.charAt(0) == '>')
className = className.substring(1);
className = utils.firstLetterUpperCase(className);
- buf.append(seiPkgName + "." + className + arraySuffix);
+ className = seiPkgName + "." + className + arraySuffix;
+ if (holder)
+ {
+ className = holderWriter.getOrCreateHolder(className,
getLocationForJavaGeneration());
+ }
+
+ buf.append(className);
+
if (xt instanceof XSComplexTypeDefinition)
generateJavaSource((XSComplexTypeDefinition)xt, xsmodel, containingElement);
}
Modified:
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/tools/XSDToJava.java
===================================================================
---
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/tools/XSDToJava.java 2007-04-11
19:19:43 UTC (rev 2808)
+++
branches/dlofthouse/JBWS-429/jbossws-core/src/java/org/jboss/ws/tools/XSDToJava.java 2007-04-11
21:16:27 UTC (rev 2809)
@@ -134,7 +134,7 @@
String nsuri = elmtype.getNamespace();
String tname = elmtype.getName();
if (tname != null) continue; //Consider only anon complex types
- //xsdJava.createJavaFile(ctype, dirloc, packageName, xsmodel, elmname);
+
createJavaFile(ctype, dirloc, packageName, xsmodel, elmname);
}
}
@@ -159,7 +159,6 @@
throw new IllegalArgumentException(str);
checkXSDTypeToJava();
xsdJava.createJavaFile(type,outerElementName, loc,pkgname,schema, false);
- //createJavaFile(type, schema);
}
private void checkXSDTypeToJava()
Modified:
branches/dlofthouse/JBWS-429/jbossws-tests/src/java/org/jboss/test/ws/tools/jbws429/JBWS429TestCase.java
===================================================================
---
branches/dlofthouse/JBWS-429/jbossws-tests/src/java/org/jboss/test/ws/tools/jbws429/JBWS429TestCase.java 2007-04-11
19:19:43 UTC (rev 2808)
+++
branches/dlofthouse/JBWS-429/jbossws-tests/src/java/org/jboss/test/ws/tools/jbws429/JBWS429TestCase.java 2007-04-11
21:16:27 UTC (rev 2809)
@@ -21,7 +21,12 @@
*/
package org.jboss.test.ws.tools.jbws429;
+import java.io.File;
+import java.io.FilenameFilter;
+
import org.jboss.test.ws.tools.WSToolsTest;
+import org.jboss.test.ws.tools.fixture.JBossSourceComparator;
+import org.jboss.test.ws.tools.validation.JaxrpcMappingValidator;
import org.jboss.ws.tools.WSTools;
/**
@@ -36,14 +41,13 @@
{
/**
- * Test WSDL to Java with the output message containing 2
- * parts, the parts are not listed in the paramaterOrder
- * attribute so both should be parameters to the method on the
- * SEI using holders and the return type should be void.
+ * Test WSDL to Java with the a document/literal endpoint
+ * where the message part is the same for both the input
+ * and output message.
*/
public void testGenerateOutUnlisted() throws Exception
{
- generateScenario("OUT_unlisted");
+ generateScenario("doclit_inout");
}
protected void generateScenario(final String scenario) throws Exception
@@ -52,5 +56,53 @@
String toolsDir = "tools/jbws429/" + scenario;
String[] args = new String[] { "-dest", toolsDir, "-config",
resourceDir + "/wstools-config.xml" };
new WSTools().generate(args);
+ File resourceDirFile = new File(resourceDir);
+ String[] expectedFiles = resourceDirFile.list(new FilenameFilter() {
+ public boolean accept(File dir, String name)
+ {
+ return name.endsWith(".java");
+ }
+ });
+
+ for (int i = 0; i < expectedFiles.length; i++)
+ {
+ String currentFile = expectedFiles[i];
+
+ try
+ {
+ compareSource(resourceDir + "/" + currentFile, toolsDir +
"/org/jboss/test/ws/jbws429/" + currentFile);
+ }
+ catch (Exception e)
+ {
+ throw new Exception("Validation of '" + currentFile +
"' failed.", e);
+ }
+ }
+
+ File packageDir = new File(toolsDir + "/org/jboss/test/ws/jbws429");
+ String[] generatedFiles = packageDir.list();
+ for (int i = 0; i < generatedFiles.length; i++)
+ {
+ String currentFile = generatedFiles[i];
+
+ boolean matched = "PhoneBookService.java".equals(currentFile);
+
+ for (int j = 0; j < expectedFiles.length && (matched == false); j++)
+ matched = currentFile.equals(expectedFiles[j]);
+
+ assertTrue("File '" + currentFile + "' was not expected
to be generated", matched);
+ }
+
+ JaxrpcMappingValidator mappingValidator = new JaxrpcMappingValidator();
+ mappingValidator.validate(resourceDir + "/jaxrpc-mapping.xml", toolsDir +
"/jaxrpc-mapping.xml");
}
+
+ private static void compareSource(final String expectedName, final String
generatedName) throws Exception
+ {
+ File expected = new File(expectedName);
+ File generated = new File(generatedName);
+
+ JBossSourceComparator sc = new JBossSourceComparator(expected, generated);
+ sc.validate();
+ sc.validateImports();
+ }
}
Copied:
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout (from
rev 2808,
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/OUT_unlisted)
Added:
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/Person.java
===================================================================
---
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/Person.java
(rev 0)
+++
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/Person.java 2007-04-11
21:16:27 UTC (rev 2809)
@@ -0,0 +1,34 @@
+/*
+ * JBossWS WS-Tools Generated Source
+ *
+ * Generation Date: Wed Apr 11 23:01:45 CEST 2007
+ *
+ * This generated source code represents a derivative work of the input to
+ * the generator that produced it. Consult the input for the copyright and
+ * terms of use that apply to this source code.
+ */
+
+package org.jboss.test.ws.jbws429;
+
+
+public class Person
+{
+
+protected java.lang.String firstName;
+
+protected java.lang.String surname;
+public Person(){}
+
+public Person(java.lang.String firstName, java.lang.String surname){
+this.firstName=firstName;
+this.surname=surname;
+}
+public java.lang.String getFirstName() { return firstName ;}
+
+public void setFirstName(java.lang.String firstName){ this.firstName=firstName; }
+
+public java.lang.String getSurname() { return surname ;}
+
+public void setSurname(java.lang.String surname){ this.surname=surname; }
+
+}
Property changes on:
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/Person.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/PersonHolder.java
===================================================================
---
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/PersonHolder.java
(rev 0)
+++
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/PersonHolder.java 2007-04-11
21:16:27 UTC (rev 2809)
@@ -0,0 +1,28 @@
+/*
+ * JBossWS WS-Tools Generated Source
+ *
+ * Generation Date: Wed Apr 11 23:01:45 CEST 2007
+ *
+ * This generated source code represents a derivative work of the input to
+ * the generator that produced it. Consult the input for the copyright and
+ * terms of use that apply to this source code.
+ */
+
+package org.jboss.test.ws.jbws429;
+
+public class PersonHolder implements javax.xml.rpc.holders.Holder
+{
+
+ public org.jboss.test.ws.jbws429.Person value;
+
+ public PersonHolder()
+ {
+ this.value = new org.jboss.test.ws.jbws429.Person();
+ }
+
+ public PersonHolder(final org.jboss.test.ws.jbws429.Person value)
+ {
+ this.value = value;
+ }
+
+}
Property changes on:
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/PersonHolder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/PhoneBook.wsdl
===================================================================
---
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/OUT_unlisted/PhoneBook.wsdl 2007-04-11
19:19:43 UTC (rev 2808)
+++
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/PhoneBook.wsdl 2007-04-11
21:16:27 UTC (rev 2809)
@@ -1,42 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions name='PhoneBook'
targetNamespace='http://test.jboss.org/ws/jbws429'
xmlns='http://schemas.xmlsoap.org/wsdl/'
xmlns:ns1='http://test.jboss.org/ws/jbws429/types'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:tns='http://test.jboss.org/ws/jbws429'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
- <types>
- <schema
targetNamespace='http://test.jboss.org/ws/jbws429/types'
xmlns='http://www.w3.org/2001/XMLSchema'
xmlns:soap11-enc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:tns='http://test.jboss.org/ws/jbws429/types'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
+ <types>
+ <schema
targetNamespace='http://test.jboss.org/ws/jbws429/types'
xmlns='http://www.w3.org/2001/XMLSchema'
xmlns:soap11-enc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:tns='http://test.jboss.org/ws/jbws429/types'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
+
<complexType name='Person'>
<sequence>
<element name='firstName' nillable='true'
type='string'/>
- <element name='surname' nillable='true'
type='string'/>
+ <element name='surname' nillable='true'
type='string'/>
</sequence>
- </complexType>
-
- <complexType name='TelephoneNumber'>
- <sequence>
- <element name='areaCode' nillable='true'
type='string'/>
- <element name='number' nillable='true'
type='string'/>
- </sequence>
- </complexType>
-
- <complexType name='Account'>
- <sequence>
- <element name='accountNo' nillable='false'
type='string'/>
- </sequence>
- </complexType>
-
- <element name='lookup' type='tns:Person' />
- <element name='lookupResponse' type='tns:TelephoneNumber'/>
- <element name='account' type='tns:Account'/>
+ </complexType>
+
+ <element name='lookup' type='tns:Person'/>
</schema>
</types>
-
+
<message name='PhoneBook_lookup'>
- <part element='ns1:lookup' name='parameters'/>
+ <part element='ns1:lookup' name='lookup'/>
</message>
<message name='PhoneBook_lookupResponse'>
- <part element='ns1:lookupResponse' name='result'/>
- <part element='ns1:account' name='account'/>
+ <part element='ns1:lookup' name='lookup'/>
</message>
-
+
<portType name='PhoneBook'>
<operation name='lookup'>
<input message='tns:PhoneBook_lookup'/>
Added:
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/PhoneBook_PortType.java
===================================================================
---
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/PhoneBook_PortType.java
(rev 0)
+++
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/PhoneBook_PortType.java 2007-04-11
21:16:27 UTC (rev 2809)
@@ -0,0 +1,15 @@
+/*
+ * JBossWS WS-Tools Generated Source
+ *
+ * Generation Date: Wed Apr 11 23:01:45 CEST 2007
+ *
+ * This generated source code represents a derivative work of the input to
+ * the generator that produced it. Consult the input for the copyright and
+ * terms of use that apply to this source code.
+ */
+package org.jboss.test.ws.jbws429;
+public interface PhoneBook_PortType extends java.rmi.Remote
+{
+
+ public void lookup(org.jboss.test.ws.jbws429.PersonHolder lookup) throws
java.rmi.RemoteException;
+}
Property changes on:
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/PhoneBook_PortType.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/jaxrpc-mapping.xml
===================================================================
---
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/jaxrpc-mapping.xml
(rev 0)
+++
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/jaxrpc-mapping.xml 2007-04-11
21:16:27 UTC (rev 2809)
@@ -0,0 +1,49 @@
+<?xml version='1.0' encoding='UTF-8'?><java-wsdl-mapping
version='1.1'
xmlns='http://java.sun.com/xml/ns/j2ee'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://java.sun.com/xml/ns/j2ee
http://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd'>
+ <package-mapping
xmlns='http://java.sun.com/xml/ns/j2ee'>
+ <package-type
xmlns='http://java.sun.com/xml/ns/j2ee'>org.jboss.test.ws.jbws...
+ <namespaceURI
xmlns='http://java.sun.com/xml/ns/j2ee'>http://test.jboss.org/...
+ </package-mapping>
+ <package-mapping
xmlns='http://java.sun.com/xml/ns/j2ee'>
+ <package-type
xmlns='http://java.sun.com/xml/ns/j2ee'>org.jboss.test.ws.jbws...
+ <namespaceURI
xmlns='http://java.sun.com/xml/ns/j2ee'>http://test.jboss.org/...
+ </package-mapping>
+ <java-xml-type-mapping
xmlns='http://java.sun.com/xml/ns/j2ee'>
+ <java-type
xmlns='http://java.sun.com/xml/ns/j2ee'>org.jboss.test.ws.jbws...
+ <root-type-qname
xmlns:typeNS='http://test.jboss.org/ws/jbws429/types'
xmlns='http://java.sun.com/xml/ns/j2ee'>typeNS:Person</root...
+ <qname-scope
xmlns='http://java.sun.com/xml/ns/j2ee'>complexType</qname-...
+ <variable-mapping
xmlns='http://java.sun.com/xml/ns/j2ee'>
+ <java-variable-name
xmlns='http://java.sun.com/xml/ns/j2ee'>firstName</java-var...
+ <xml-element-name
xmlns='http://java.sun.com/xml/ns/j2ee'>firstName</xml-elem...
+ </variable-mapping>
+ <variable-mapping
xmlns='http://java.sun.com/xml/ns/j2ee'>
+ <java-variable-name
xmlns='http://java.sun.com/xml/ns/j2ee'>surname</java-varia...
+ <xml-element-name
xmlns='http://java.sun.com/xml/ns/j2ee'>surname</xml-elemen...
+ </variable-mapping>
+ </java-xml-type-mapping>
+ <service-interface-mapping
xmlns='http://java.sun.com/xml/ns/j2ee'>
+ <service-interface
xmlns='http://java.sun.com/xml/ns/j2ee'>org.jboss.test.ws.jbws...
+ <wsdl-service-name
xmlns:serviceNS='http://test.jboss.org/ws/jbws429'
xmlns='http://java.sun.com/xml/ns/j2ee'>serviceNS:PhoneBook<...
+ <port-mapping
xmlns='http://java.sun.com/xml/ns/j2ee'>
+ <port-name
xmlns='http://java.sun.com/xml/ns/j2ee'>PhoneBookPort</port...
+ <java-port-name
xmlns='http://java.sun.com/xml/ns/j2ee'>PhoneBookPort</java...
+ </port-mapping>
+ </service-interface-mapping>
+ <service-endpoint-interface-mapping
xmlns='http://java.sun.com/xml/ns/j2ee'>
+ <service-endpoint-interface
xmlns='http://java.sun.com/xml/ns/j2ee'>org.jboss.test.ws.jbws...
+ <wsdl-port-type
xmlns:portTypeNS='http://test.jboss.org/ws/jbws429'
xmlns='http://java.sun.com/xml/ns/j2ee'>portTypeNS:PhoneBook&l...
+ <wsdl-binding
xmlns:bindingNS='http://test.jboss.org/ws/jbws429'
xmlns='http://java.sun.com/xml/ns/j2ee'>bindingNS:PhoneBookBin...
+ <service-endpoint-method-mapping
xmlns='http://java.sun.com/xml/ns/j2ee'>
+ <java-method-name
xmlns='http://java.sun.com/xml/ns/j2ee'>lookup</java-method...
+ <wsdl-operation
xmlns='http://java.sun.com/xml/ns/j2ee'>lookup</wsdl-operat...
+ <method-param-parts-mapping
xmlns='http://java.sun.com/xml/ns/j2ee'>
+ <param-position
xmlns='http://java.sun.com/xml/ns/j2ee'>0</param-position>
+ <param-type
xmlns='http://java.sun.com/xml/ns/j2ee'>org.jboss.test.ws.jbws...
+ <wsdl-message-mapping
xmlns='http://java.sun.com/xml/ns/j2ee'>
+ <wsdl-message
xmlns:wsdlMsgNS='http://test.jboss.org/ws/jbws429'
xmlns='http://java.sun.com/xml/ns/j2ee'>wsdlMsgNS:PhoneBook_lo...
+ <wsdl-message-part-name
xmlns='http://java.sun.com/xml/ns/j2ee'>lookup</wsdl-messag...
+ <parameter-mode
xmlns='http://java.sun.com/xml/ns/j2ee'>INOUT</parameter-mo...
+ </wsdl-message-mapping>
+ </method-param-parts-mapping>
+ </service-endpoint-method-mapping>
+ </service-endpoint-interface-mapping>
+</java-wsdl-mapping>
\ No newline at end of file
Property changes on:
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/jaxrpc-mapping.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/wstools-config.xml
===================================================================
---
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/OUT_unlisted/wstools-config.xml 2007-04-11
19:19:43 UTC (rev 2808)
+++
branches/dlofthouse/JBWS-429/jbossws-tests/src/resources/tools/jbws429/doclit_inout/wstools-config.xml 2007-04-11
21:16:27 UTC (rev 2809)
@@ -1,5 +1,5 @@
<configuration>
- <wsdl-java location="resources/tools/jbws429/OUT_unlisted/PhoneBook.wsdl"
parameter-style="bare">
+ <wsdl-java location="resources/tools/jbws429/doclit_inout/PhoneBook.wsdl"
parameter-style="bare">
<mapping file="jaxrpc-mapping.xml"/>
</wsdl-java>
</configuration>