You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by to...@apache.org on 2004/10/29 22:25:25 UTC
cvs commit: ws-axis/java/tools/org/apache/axis/tools/ant/wsdl Wsdl2javaAntTask.java
tomj 2004/10/29 13:25:25
Modified: java/src/org/apache/axis/encoding
DefaultSOAP12TypeMappingImpl.java
DefaultSOAPEncodingTypeMappingImpl.java
DefaultTypeMappingImpl.java
java/src/org/apache/axis/wsdl/toJava Emitter.java
java/src/org/apache/axis/i18n resource.properties
java/src/org/apache/axis/wsdl WSDL2Java.java
java/tools/org/apache/axis/tools/ant/wsdl
Wsdl2javaAntTask.java
Log:
Add a -j switch to WSDL2Java along with an API and an enhancement to the
ant task.
This turns on the JAX-RPC 1.1 compatible default type mapping, which generally
avoids the Axis custom types to prefer mapping to standard Java types.
For instance, the XML Schema types Month, Day and Year are mapped to String
and NonPositiveInteger is mapped to BigInteger.
NOTE: I can't seem to verify that the ant task will work with this syntax:
<wsdl2java url="jaxrpc11types.wsdl" jaxrpc11mappings="yes">
Can someone with ant mojo double check that I updated the task correctly?
TODO: Add a test for the new switch. Update the WSDL2Java test
case generator to emit the right code when this switch is on.
Revision Changes Path
1.9 +1 -1 ws-axis/java/src/org/apache/axis/encoding/DefaultSOAP12TypeMappingImpl.java
Index: DefaultSOAP12TypeMappingImpl.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/DefaultSOAP12TypeMappingImpl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DefaultSOAP12TypeMappingImpl.java 4 Jan 2003 01:34:24 -0000 1.8
+++ DefaultSOAP12TypeMappingImpl.java 29 Oct 2004 20:25:25 -0000 1.9
@@ -9,7 +9,7 @@
extends DefaultSOAPEncodingTypeMappingImpl {
public DefaultSOAP12TypeMappingImpl() {
- super();
+ super(false);
}
}
1.5 +9 -4 ws-axis/java/src/org/apache/axis/encoding/DefaultSOAPEncodingTypeMappingImpl.java
Index: DefaultSOAPEncodingTypeMappingImpl.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/DefaultSOAPEncodingTypeMappingImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultSOAPEncodingTypeMappingImpl.java 25 Feb 2004 14:02:35 -0000 1.4
+++ DefaultSOAPEncodingTypeMappingImpl.java 29 Oct 2004 20:25:25 -0000 1.5
@@ -35,19 +35,24 @@
*/
public static TypeMapping create() {
if (tm == null) {
- tm = new DefaultSOAPEncodingTypeMappingImpl();
+ tm = new DefaultSOAPEncodingTypeMappingImpl(false);
}
return tm;
}
- public static TypeMapping createWithDelegate() {
- TypeMapping ret = new DefaultSOAPEncodingTypeMappingImpl();
+ public static TypeMapping createWithDelegate(boolean UseJaxRPC11Mappings) {
+ TypeMapping ret = new DefaultSOAPEncodingTypeMappingImpl(UseJaxRPC11Mappings);
ret.setDelegate(DefaultTypeMappingImpl.getSingleton());
return ret;
}
protected DefaultSOAPEncodingTypeMappingImpl() {
- registerSOAPTypes();
+ this(false);
+ }
+
+ protected DefaultSOAPEncodingTypeMappingImpl(boolean UseJaxRPC11Mappings) {
+ super(UseJaxRPC11Mappings);
+ registerSOAPTypes();
}
/**
1.81 +5 -3 ws-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java
Index: DefaultTypeMappingImpl.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- DefaultTypeMappingImpl.java 11 Oct 2004 18:58:26 -0000 1.80
+++ DefaultTypeMappingImpl.java 29 Oct 2004 20:25:25 -0000 1.81
@@ -79,6 +79,8 @@
static {
try {
+ // We check a system property, but we can use use switches
+ // to control this in WSDL2Java and at runtime.
jaxrpc11Compliance =
System.getProperty("axis.jaxrpc11Compliance", "false")
.equalsIgnoreCase("true");
@@ -91,12 +93,12 @@
*/
public static synchronized TypeMapping getSingleton() {
if (tm == null) {
- tm = new DefaultTypeMappingImpl();
+ tm = new DefaultTypeMappingImpl(false);
}
return tm;
}
- protected DefaultTypeMappingImpl() {
+ protected DefaultTypeMappingImpl(boolean dojaxrpc11) {
super(null);
delegate = null;
@@ -561,7 +563,7 @@
Constants.XSD_SCHEMA)
);
- if (jaxrpc11Compliance) {
+ if (jaxrpc11Compliance || dojaxrpc11) {
// Table 4-1 of the JAXRPC 1.1 spec
myRegisterSimple(Constants.XSD_UNSIGNEDINT, long.class);
myRegisterSimple(Constants.XSD_UNSIGNEDSHORT, int.class);
1.72 +26 -7 ws-axis/java/src/org/apache/axis/wsdl/toJava/Emitter.java
Index: Emitter.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/toJava/Emitter.java,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- Emitter.java 31 Aug 2004 17:03:42 -0000 1.71
+++ Emitter.java 29 Oct 2004 20:25:25 -0000 1.72
@@ -91,6 +91,9 @@
private boolean typeCollisionProtection = true;
+ /** Use JAX-RPC 1.1 type mappings */
+ private boolean useJaxRPC11Mappings = false;
+
/** Field packageName */
private String packageName = null;
@@ -393,6 +396,26 @@
}
/**
+ * Turn on the JAX-RPC 1.1 type mappings, which maps
+ * various XML Schema types to java types (string, BigInteger, Calendar, etc).
+ * <p>
+ * Axis has custom types (in org.apache.axis.types) that are used by
+ * default.
+ */
+ public void setUseJaxRPC11Mappings(boolean b) {
+ useJaxRPC11Mappings = b;
+ }
+
+ /**
+ * Will this emitter use the JAX-RPC 1.1 type mappings for
+ * the types that aren't directly mappable to Java.
+ * @return TRUE if we are using the JAX-RPC 1.1 mappings.
+ */
+ public boolean getsetUseJaxRPC11Mappings() {
+ return useJaxRPC11Mappings;
+ }
+
+ /**
* Sets the <code>WriterFactory Class</code> to use
*
* @param factory the name of the factory <code>Class</code>
@@ -401,8 +424,7 @@
try {
Class clazz = ClassUtils.forName(factory);
- GeneratorFactory genFac = null;
-
+ GeneratorFactory genFac;
try {
Constructor ctor = clazz.getConstructor(new Class[]{
getClass()});
@@ -530,10 +552,7 @@
* @return
*/
public String getJavaVariableName(QName typeQName, QName xmlName, boolean isElement) {
- String javaName = null;
-
-
- javaName = getJavaVariableNameHook(typeQName, xmlName, isElement);
+ String javaName = getJavaVariableNameHook(typeQName, xmlName, isElement);
if (javaName == null) {
String elemName = Utils.getLastLocalPart(xmlName.getLocalPart());
javaName = Utils.xmlNameToJava(elemName);
@@ -730,7 +749,7 @@
baseTypeMapping = new BaseTypeMapping() {
final TypeMapping defaultTM =
- DefaultSOAPEncodingTypeMappingImpl.createWithDelegate();
+ DefaultSOAPEncodingTypeMappingImpl.createWithDelegate(useJaxRPC11Mappings);
public String getBaseName(QName qNameIn) {
1.96 +2 -0 ws-axis/java/src/org/apache/axis/i18n/resource.properties
Index: resource.properties
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/i18n/resource.properties,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -r1.95 -r1.96
--- resource.properties 27 Oct 2004 21:41:01 -0000 1.95
+++ resource.properties 29 Oct 2004 20:25:25 -0000 1.96
@@ -1249,3 +1249,5 @@
cannotFindPartForOperation00=Cannot find part [{0}] for operation [{1}] using MIMEContent type [{2}]
Registrar.cantregister=Unable to initialize commons-modeler Registry.
+
+optionJaxrpc=Maps XML Schema types to Java types instead of the custom Axis types in org.apache.axis.types, according to JAX-RPC 1.1.
1.50 +10 -1 ws-axis/java/src/org/apache/axis/wsdl/WSDL2Java.java
Index: WSDL2Java.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/WSDL2Java.java,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- WSDL2Java.java 10 May 2004 17:25:43 -0000 1.49
+++ WSDL2Java.java 29 Oct 2004 20:25:25 -0000 1.50
@@ -90,6 +90,9 @@
/** Field IMPL_CLASS_OPT */
protected static final int IMPL_CLASS_OPT = 'c';
+ /** Field IMPL_CLASS_OPT */
+ protected static final int JAXRPC11_OPT = 'j';
+
/** Field emitter */
private Emitter emitter;
@@ -173,7 +176,9 @@
new CLOptionDescriptor("implementationClassName",
CLOptionDescriptor.ARGUMENT_REQUIRED,
IMPL_CLASS_OPT,
- Messages.getMessage("implementationClassName"))
+ Messages.getMessage("implementationClassName")),
+ new CLOptionDescriptor("jaxrpc", CLOptionDescriptor.ARGUMENT_DISALLOWED,
+ JAXRPC11_OPT, Messages.getMessage("optionJaxrpc"))
};
/**
@@ -310,6 +315,10 @@
emitter.setImplementationClassName(option.getArgument());
break;
+ case JAXRPC11_OPT:
+ emitter.setUseJaxRPC11Mappings(true);
+ break;
+
default :
super.parseOption(option);
}
1.21 +11 -1 ws-axis/java/tools/org/apache/axis/tools/ant/wsdl/Wsdl2javaAntTask.java
Index: Wsdl2javaAntTask.java
===================================================================
RCS file: /home/cvs/ws-axis/java/tools/org/apache/axis/tools/ant/wsdl/Wsdl2javaAntTask.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- Wsdl2javaAntTask.java 18 Aug 2004 16:30:56 -0000 1.20
+++ Wsdl2javaAntTask.java 29 Oct 2004 20:25:25 -0000 1.21
@@ -86,6 +86,7 @@
private boolean all = false;
private boolean helperGen = false;
private boolean noWrapped = false;
+ private boolean jaxrpc11mappings = false;
private String factory = null;
private HashMap namespaceMap = new HashMap();
private String output = ".";
@@ -177,7 +178,8 @@
log("\tnamespaceMappingFile:" + namespaceMappingFile, logLevel);
log("\tusername:" + username, logLevel);
log("\t:password" + password, logLevel);
- log("\t:noWrapped" + noWrapped, logLevel);
+ log("\t:noWrapped" + noWrapped, logLevel);
+ log("\t:jaxrpc11mappings" + jaxrpc11mappings, logLevel);
log("\t:implementationClassName" + implementationClassName, logLevel);
log("\t:classpath" + classpath, logLevel);
traceNetworkSettings(logLevel);
@@ -231,6 +233,7 @@
emitter.setQuiet(quiet);
emitter.setTypeMappingVersion(typeMappingVersion);
emitter.setNowrap(noWrapped);
+ emitter.setUseJaxRPC11Mappings(jaxrpc11mappings);
if (namespaceMappingFile != null) {
emitter.setNStoPkg(namespaceMappingFile.toString());
}
@@ -513,6 +516,13 @@
*/
public void setNoWrapped(boolean noWrapped) {
this.noWrapped = noWrapped;
+ }
+
+ /**
+ * Set the jaxrpc11mappings flag.
+ */
+ public void setJaxrpc11mappings(boolean b) {
+ this.jaxrpc11mappings = b;
}
/**