Author: darran.lofthouse(a)jboss.com
Date: 2008-03-27 13:04:14 -0400 (Thu, 27 Mar 2008)
New Revision: 6126
Modified:
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/Configuration.java
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/JavaWriter.java
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/WSDLToJava.java
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/XSDTypeToJava.java
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/config/ToolsSchemaConfigReader.java
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java
stack/native/branches/dlofthouse/JBWS-1278/src/main/resources/schema/jbossws-tool_1_0.xsd
stack/native/branches/dlofthouse/JBWS-1278/src/test/resources/tools/jbws1278/doclit/wstools-config.xml
Log:
Feature implementation.
Modified:
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/Configuration.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/Configuration.java 2008-03-27
17:02:13 UTC (rev 6125)
+++
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/Configuration.java 2008-03-27
17:04:14 UTC (rev 6126)
@@ -140,6 +140,8 @@
public String wsdlLocation;
// Parameter style {"wrapped", "bare"}
public String parameterStyle = "wrapped";
+ // Should generated types be Serializable?
+ public boolean serializableTypes;
// Is a jaxrpc-mapping file needed?
public boolean mappingFileNeeded;
// Name of the jaxrpc-mapping file
Modified:
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/JavaWriter.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/JavaWriter.java 2008-03-27
17:02:13 UTC (rev 6125)
+++
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/JavaWriter.java 2008-03-27
17:04:14 UTC (rev 6126)
@@ -192,7 +192,7 @@
* @throws IOException
*/
public void createJavaFile(File location, String filename, String packageName,
List<VAR> vars, List<String> importList, String baseTypeName,
- boolean isExceptionType, Map<String, List> typeNameToBaseVARList) throws
IOException
+ boolean isExceptionType, boolean isSerializable, Map<String, List>
typeNameToBaseVARList) throws IOException
{
File newLoc = null;
if (needToCreatePackageStructure(location, packageName))
@@ -217,6 +217,8 @@
buffer.append(newline).append("public class
").append(classname).append(newline);
if (baseTypeName != null && baseTypeName.length() > 0)
buffer.append(" extends ").append(baseTypeName);
+ if (isSerializable)
+ buffer.append(" implements java.io.Serializable");
buffer.append("{").append(newline);
createVariables(buffer, vars, isExceptionType);
createCTR(buffer, classname, vars, isExceptionType, typeNameToBaseVARList);
Modified:
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/WSDLToJava.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/WSDLToJava.java 2008-03-27
17:02:13 UTC (rev 6125)
+++
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/WSDLToJava.java 2008-03-27
17:04:14 UTC (rev 6126)
@@ -96,6 +96,7 @@
protected boolean annotate = false;
protected Map<String, String> namespacePackageMap = null;
+ protected boolean generateSerializableTypes = false;
protected HolderWriter holderWriter = new HolderWriter();
@@ -207,6 +208,16 @@
namespacePackageMap.put(pkg, map.get(pkg));
}
}
+
+ public boolean isGenerateSerializableTypes()
+ {
+ return generateSerializableTypes;
+ }
+
+ public void setGenerateSerializableTypes(boolean generateSerializableTypes)
+ {
+ this.generateSerializableTypes = generateSerializableTypes;
+ }
public void setTypeMapping(LiteralTypeMapping tm)
{
@@ -808,7 +819,7 @@
private void generateJavaSource(XSComplexTypeDefinition xt, JBossXSModel xsmodel,
String containingElement, boolean exception) throws IOException
{
- XSDTypeToJava xtj = new XSDTypeToJava(namespacePackageMap);
+ XSDTypeToJava xtj = new XSDTypeToJava(namespacePackageMap,
generateSerializableTypes);
xtj.setTypeMapping(this.typeMapping);
String targetNS = wsdl.getTargetNamespace();
String tgtNS = xt.getNamespace();
Modified:
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/XSDTypeToJava.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/XSDTypeToJava.java 2008-03-27
17:02:13 UTC (rev 6125)
+++
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/XSDTypeToJava.java 2008-03-27
17:04:14 UTC (rev 6126)
@@ -77,6 +77,7 @@
private Set<String> generatedFiles = new HashSet<String>();
protected Map<String, String> namespacePackageMap = null;
+ protected boolean serializableTypes;
/**
* List that is used for exception inheritance case wherein the variables
@@ -85,9 +86,10 @@
*/
private Map<String, List> typeNameToBaseVARList = new HashMap<String,
List>();
- public XSDTypeToJava(Map<String, String> map)
+ public XSDTypeToJava(Map<String, String> map, boolean serializableTypes)
{
this.namespacePackageMap = map;
+ this.serializableTypes = serializableTypes;
}
public void createJavaFile(XSComplexTypeDefinition type, String loc, String pkgname,
XSModel schema) throws IOException
@@ -164,7 +166,8 @@
baseName = getPackageName(baseType.getNamespace()) + "." + baseName;
}
String packageName = getPackageName(type.getNamespace());
- jwriter.createJavaFile(getLocationForJavaGeneration(packageName), fname,
packageName, vars, null, baseName, isExceptionType, typeNameToBaseVARList);
+ jwriter.createJavaFile(getLocationForJavaGeneration(packageName), fname,
packageName, vars, null, baseName, isExceptionType, serializableTypes,
+ typeNameToBaseVARList);
}
public void createJavaFile(XSSimpleTypeDefinition xsSimple, XSModel schema) throws
IOException
Modified:
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/config/ToolsSchemaConfigReader.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/config/ToolsSchemaConfigReader.java 2008-03-27
17:02:13 UTC (rev 6125)
+++
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/config/ToolsSchemaConfigReader.java 2008-03-27
17:04:14 UTC (rev 6126)
@@ -81,6 +81,7 @@
private static final String RETURN_XML_NAME_ATTRIBUTE = "return-xml-name";
private static final String ONEWAY_ATTRIBUTE = "one-way";
private static final String PARAMETER_STYLE_ATTRIBUTE = "parameter-style";
+ private static final String SERIALIZABLE_TYPES_ATTRIBUTE =
"serializable-types";
private static final String STYLE_ATTRIBUTE = "style";
private static final String ENDPOINT_ATTRIBUTE = "endpoint";
private static final String NAME_ATTRIBUTE = "name";
@@ -179,7 +180,10 @@
String paramStyle = attrs.getValue(PARAMETER_STYLE_ATTRIBUTE);
if (paramStyle != null)
wsdl2jc.parameterStyle = paramStyle;
-
+ String serializableTypes = attrs.getValue(SERIALIZABLE_TYPES_ATTRIBUTE);
+ if ("true".equals(serializableTypes) ||
"1".equals(serializableTypes))
+ wsdl2jc.serializableTypes = true;
+
return wsdl2jc;
}
else if (GLOBAL_TAG.equals(localName))
Modified:
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java 2008-03-27
17:02:13 UTC (rev 6125)
+++
stack/native/branches/dlofthouse/JBWS-1278/src/main/java/org/jboss/ws/tools/helpers/ToolsHelper.java 2008-03-27
17:04:14 UTC (rev 6126)
@@ -28,7 +28,6 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -64,9 +63,10 @@
import org.jboss.ws.tools.interfaces.WebservicesXMLCreator;
import org.jboss.ws.tools.mapping.MappingFileGenerator;
import org.jboss.ws.tools.wsdl.WSDLWriter;
+import org.jboss.wsf.common.DOMUtils;
+import org.jboss.wsf.common.DOMWriter;
+import org.jboss.wsf.common.IOUtils;
import org.jboss.wsf.common.JavaUtils;
-import org.jboss.wsf.common.DOMUtils;
-import org.jboss.wsf.common.*;
/**
* Helper class used by the cmd line tool "jbossws"
@@ -225,7 +225,7 @@
}
JavaWriter writer = new JavaWriter();
- writer.createJavaFile(new File(outDir), name + ".java", packageName,
vars, null, null, false, null);
+ writer.createJavaFile(new File(outDir), name + ".java", packageName,
vars, null, null, false, false, null);
JavaXmlTypeMapping type = mappingIndex.get(parameter.getXmlType());
if (type == null)
@@ -262,6 +262,7 @@
WSDLToJava wsdlToJava = new WSDLToJava();
wsdlToJava.setTypeMapping(new LiteralTypeMapping());
+ wsdlToJava.setGenerateSerializableTypes(w2jc.serializableTypes);
WSDLDefinitions wsdl = null;
try
Modified:
stack/native/branches/dlofthouse/JBWS-1278/src/main/resources/schema/jbossws-tool_1_0.xsd
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1278/src/main/resources/schema/jbossws-tool_1_0.xsd 2008-03-27
17:02:13 UTC (rev 6125)
+++
stack/native/branches/dlofthouse/JBWS-1278/src/main/resources/schema/jbossws-tool_1_0.xsd 2008-03-27
17:04:14 UTC (rev 6126)
@@ -247,6 +247,11 @@
</xs:restriction>
</xs:simpleType>
</xs:attribute>
+ <xs:attribute name="serializable-types" type="xs:boolean"
use="optional">
+ <xs:annotation>
+ <xs:documentation>Should generated types implement java.io.Serializable,
default to false.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
<xs:complexType name="parameterType">
<xs:attribute name="type" use="required">
Modified:
stack/native/branches/dlofthouse/JBWS-1278/src/test/resources/tools/jbws1278/doclit/wstools-config.xml
===================================================================
---
stack/native/branches/dlofthouse/JBWS-1278/src/test/resources/tools/jbws1278/doclit/wstools-config.xml 2008-03-27
17:02:13 UTC (rev 6125)
+++
stack/native/branches/dlofthouse/JBWS-1278/src/test/resources/tools/jbws1278/doclit/wstools-config.xml 2008-03-27
17:04:14 UTC (rev 6126)
@@ -1,6 +1,7 @@
<configuration>
<wsdl-java location="resources/tools/jbws1278/doclit/PhoneBook.wsdl"
- parameter-style="bare">
+ parameter-style="bare"
+ serializable-types="true">
<mapping file="jaxrpc-mapping.xml"/>
</wsdl-java>
</configuration>