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 gd...@apache.org on 2002/08/15 07:23:19 UTC
cvs commit: xml-axis/java/test/encoding TestSer.java
gdaniels 2002/08/14 22:23:19
Modified: java/src/org/apache/axis Tag: Glen-work AxisProperties.java
java/src/org/apache/axis/description Tag: Glen-work
TypeDesc.java
java/src/org/apache/axis/encoding Tag: Glen-work
DefaultTypeMappingImpl.java
SerializationContext.java
SerializationContextImpl.java TypeMappingImpl.java
java/src/org/apache/axis/encoding/ser Tag: Glen-work
Base64Serializer.java BeanDeserializer.java
BeanSerializer.java CalendarSerializer.java
DateSerializer.java EnumSerializer.java
HexSerializer.java QNameSerializer.java
SimpleSerializer.java
java/src/org/apache/axis/utils Tag: Glen-work
JWSClassLoader.java
java/src/org/apache/axis/wsdl/fromJava Tag: Glen-work
Types.java
java/src/org/apache/axis/wsdl/toJava Tag: Glen-work
JavaBeanHelperWriter.java JavaBeanWriter.java
java/test/encoding Tag: Glen-work TestSer.java
Log:
Working on some serialization changes for attributes and general
cleanup, created a branch to save my work. Not yet ready for prime-
time.
Revision Changes Path
No revision
No revision
1.7.2.1 +6 -9 xml-axis/java/src/org/apache/axis/AxisProperties.java
Index: AxisProperties.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisProperties.java,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- AxisProperties.java 12 Aug 2002 22:23:54 -0000 1.7
+++ AxisProperties.java 15 Aug 2002 05:23:18 -0000 1.7.2.1
@@ -57,11 +57,8 @@
import java.util.Map;
import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Hashtable;
import java.util.Properties;
-import org.apache.axis.utils.JavaUtils;
import org.apache.commons.discovery.ManagedProperties;
@@ -98,15 +95,15 @@
public class AxisProperties {
private static String commonsGroupContext = null;
-
+
public static void setCommonsGroupContext(String groupContext) {
commonsGroupContext = groupContext;
}
-
+
public static String getCommonsGroupContext() {
return commonsGroupContext ;
}
-
+
/**
* Get value for property bound to the current thread context class loader.
*
@@ -178,14 +175,14 @@
ManagedProperties.setProperties(newProperties, isDefault);
}
-
+
public static Enumeration propertyNames() {
return ManagedProperties.propertyNames();
}
-
+
/**
* This is an expensive operation.
- *
+ *
* @return Returns a <code>java.util.Properties</code> instance
* that is equivalent to the current state of the scoped
* properties, in that getProperty() will return the same value.
No revision
No revision
1.17.2.1 +14 -0 xml-axis/java/src/org/apache/axis/description/TypeDesc.java
Index: TypeDesc.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/description/TypeDesc.java,v
retrieving revision 1.17
retrieving revision 1.17.2.1
diff -u -r1.17 -r1.17.2.1
--- TypeDesc.java 8 Jul 2002 14:37:44 -0000 1.17
+++ TypeDesc.java 15 Aug 2002 05:23:18 -0000 1.17.2.1
@@ -138,6 +138,20 @@
private Map propertyMap = null;
/**
+ * Indication if this type has support for xsd:any. If so, this will
+ * be non-null, and point to the appropriate field.
+ */
+ private String anyName = null;
+
+ public String getAnyName() {
+ return anyName;
+ }
+
+ public void setAnyName(String anyName) {
+ this.anyName = anyName;
+ }
+
+ /**
* Obtain the current array of FieldDescs
*/
public FieldDesc[] getFields() {
No revision
No revision
1.44.2.1 +5 -5 xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java
Index: DefaultTypeMappingImpl.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java,v
retrieving revision 1.44
retrieving revision 1.44.2.1
diff -u -r1.44 -r1.44.2.1
--- DefaultTypeMappingImpl.java 13 Aug 2002 15:17:13 -0000 1.44
+++ DefaultTypeMappingImpl.java 15 Aug 2002 05:23:18 -0000 1.44.2.1
@@ -276,11 +276,11 @@
myRegister(Constants.XSD_ANYTYPE, java.lang.Object.class,
null, null, false);
- // This is the special type for the xsd:any element used for
- // extensibility.
- myRegister(Constants.XSD_ANY, java.lang.Object.class,
- new ElementSerializerFactory(),
- new ElementDeserializerFactory(), false);
+// // This is the special type for the xsd:any element used for
+// // extensibility.
+// myRegister(Constants.XSD_ANY, org.w3c.dom.Element.class,
+// new ElementSerializerFactory(),
+// new ElementDeserializerFactory(), false);
// See the SchemaVersion classes for where the registration of
// dateTime (for 2001) and timeInstant (for 1999 & 2000) happen.
1.80.2.1 +2 -1 xml-axis/java/src/org/apache/axis/encoding/SerializationContext.java
Index: SerializationContext.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SerializationContext.java,v
retrieving revision 1.80
retrieving revision 1.80.2.1
diff -u -r1.80 -r1.80.2.1
--- SerializationContext.java 23 Jul 2002 22:11:29 -0000 1.80
+++ SerializationContext.java 15 Aug 2002 05:23:18 -0000 1.80.2.1
@@ -317,7 +317,8 @@
* @param el is a DOM Element
*/
public void writeDOMElement(Element el) throws IOException;
-
+
+ public String getValueAsString(Object value, QName xmlType) throws IOException;
}
1.52.2.1 +41 -16 xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java
Index: SerializationContextImpl.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java,v
retrieving revision 1.52
retrieving revision 1.52.2.1
diff -u -r1.52 -r1.52.2.1
--- SerializationContextImpl.java 8 Aug 2002 16:44:15 -0000 1.52
+++ SerializationContextImpl.java 15 Aug 2002 05:23:18 -0000 1.52.2.1
@@ -1153,21 +1153,25 @@
// xmlType = null;
// }
// }
- // Try getting a serializer for the prefered xmlType
- if (info == null && xmlType != null) {
- info = getSerializer(javaType, xmlType);
+ // if we're looking for xsd:anyType, accept anything...
+ if (Constants.XSD_ANYTYPE.equals(xmlType)) {
+ xmlType = null;
+ shouldSendType = true;
}
+ // Try getting a serializer for the prefered xmlType
+ info = getSerializer(javaType, xmlType);
+
// If a serializer was not found using the preferred xmlType,
// try getting any serializer.
- if (info == null) {
- info = getSerializer(javaType, value);
- // Must send type if it does not match preferred type
- if (xmlType != null) {
- shouldSendType = true;
- }
- xmlType = null;
- }
+// if (info == null) {
+// info = getSerializer(javaType, value);
+// // Must send type if it does not match preferred type
+// if (xmlType != null) {
+// shouldSendType = true;
+// }
+// xmlType = null;
+// }
if ( info != null ) {
@@ -1211,13 +1215,29 @@
SerializerFactory serFactory = null ;
TypeMapping tm = getTypeMapping();
- try {
- if (!javaType.getName().equals("java.lang.Object") &&
- tm.isRegistered(javaType, xmlType)) {
- serFactory = (SerializerFactory) tm.getSerializer(javaType, xmlType);
+ while (javaType != null) {
+ serFactory = (SerializerFactory) tm.getSerializer(javaType, xmlType);
+ if (serFactory != null)
+ break;
+
+ // Walk my interfaces...
+ Class [] interfaces = javaType.getInterfaces();
+ if (interfaces != null) {
+ for (int i = 0; i < interfaces.length; i++) {
+ Class iface = interfaces[i];
+ serFactory = (SerializerFactory) tm.getSerializer(iface,
+ xmlType);
+ if (serFactory != null)
+ break;
+ }
}
- } catch(JAXRPCException e) {}
+ // Finally, head to my superclass
+ if (serFactory != null)
+ break;
+
+ javaType = javaType.getSuperclass();
+ }
// Using the serialization factory, create a serializer
Serializer ser = null;
@@ -1309,4 +1329,9 @@
return info;
}
+ public String getValueAsString(Object value, QName xmlType) throws IOException {
+ SerializerInfo info = getSerializer(value.getClass(), xmlType);
+ SimpleValueSerializer ser = (SimpleValueSerializer)info.ser;
+ return ser.getValueAsString(value);
+ }
}
1.23.2.1 +54 -3 xml-axis/java/src/org/apache/axis/encoding/TypeMappingImpl.java
Index: TypeMappingImpl.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/TypeMappingImpl.java,v
retrieving revision 1.23
retrieving revision 1.23.2.1
diff -u -r1.23 -r1.23.2.1
--- TypeMappingImpl.java 18 Jul 2002 17:38:15 -0000 1.23
+++ TypeMappingImpl.java 15 Aug 2002 05:23:18 -0000 1.23.2.1
@@ -298,9 +298,40 @@
{
javax.xml.rpc.encoding.SerializerFactory sf = null;
+ while (javaType != null && !javaType.equals(Object.class)) {
+ sf = getSerializerHelper(javaType, xmlType);
+ if (sf != null)
+ return sf;
+
+ javaType = null;
+// // Walk my interfaces...
+// Class [] interfaces = javaType.getInterfaces();
+// if (interfaces != null) {
+// for (int i = 0; i < interfaces.length; i++) {
+// Class iface = interfaces[i];
+// sf = getSerializerHelper(iface, xmlType);
+// if (sf != null)
+// return sf;
+// }
+// }
+//
+// // Finally, head to my superclass
+// javaType = javaType.getSuperclass();
+ }
+
+ return null;
+ }
+
+ private javax.xml.rpc.encoding.SerializerFactory
+ getSerializerHelper(Class javaType, QName xmlType)
+ throws JAXRPCException
+ {
+ javax.xml.rpc.encoding.SerializerFactory sf = null;
+
// If the xmlType was not provided, get one
if (xmlType == null) {
xmlType = getTypeQName(javaType);
+
// If we couldn't find one, we're hosed, since getTypeQName()
// already asked all of our delegates.
if (xmlType == null) {
@@ -436,11 +467,31 @@
* @param javaType class or type
* @return xmlType qname or null
*/
- public QName getTypeQName(Class javaType) {
+ public QName getAnyTypeQName(Class javaType) {
//log.debug("getTypeQName javaType =" + javaType);
- if (javaType == null)
- return null;
+ while (javaType != null) {
+ QName xmlType = getTypeQName(javaType);
+ if (xmlType != null)
+ return xmlType;
+
+ // Walk my interfaces...
+ Class [] interfaces = javaType.getInterfaces();
+ if (interfaces != null) {
+ for (int i = 0; i < interfaces.length; i++) {
+ Class iface = interfaces[i];
+ xmlType = getTypeQName(iface);
+ if (xmlType != null)
+ return xmlType;
+ }
+ }
+
+ // Finally, head to my superclass
+ javaType = javaType.getSuperclass();
+ }
+ return null;
+ }
+ public QName getTypeQName(Class javaType) {
QName xmlType = null;
Pair pair = (Pair) class2Pair.get(javaType);
if (pair == null && delegate != null) {
No revision
No revision
1.7.6.1 +9 -4 xml-axis/java/src/org/apache/axis/encoding/ser/Base64Serializer.java
Index: Base64Serializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/Base64Serializer.java,v
retrieving revision 1.7
retrieving revision 1.7.6.1
diff -u -r1.7 -r1.7.6.1
--- Base64Serializer.java 11 Jun 2002 14:53:55 -0000 1.7
+++ Base64Serializer.java 15 Aug 2002 05:23:18 -0000 1.7.6.1
@@ -72,6 +72,7 @@
import org.apache.axis.encoding.DeserializationContext;
import org.apache.axis.encoding.Deserializer;
import org.apache.axis.encoding.Base64;
+import org.apache.axis.encoding.SimpleValueSerializer;
import org.w3c.dom.Element;
import org.w3c.dom.Document;
@@ -82,7 +83,7 @@
* Modified by @author Rich Scheuerle <sc...@us.ibm.com>
* @see <a href="http://www.w3.org/TR/xmlschema-2/#base64Binary">XML Schema 3.2.16</a>
*/
-public class Base64Serializer implements Serializer {
+public class Base64Serializer implements SimpleValueSerializer {
public QName xmlType;
public Class javaType;
@@ -98,6 +99,12 @@
Object value, SerializationContext context)
throws IOException
{
+ context.startElement(name, attributes);
+ context.writeString(getValueAsString(value));
+ context.endElement();
+ }
+
+ public String getValueAsString(Object value) {
byte[] data = null;
if (javaType == byte[].class) {
data = (byte[]) value;
@@ -110,9 +117,7 @@
}
}
- context.startElement(name, attributes);
- context.writeString(Base64.encode(data, 0, data.length));
- context.endElement();
+ return Base64.encode(data, 0, data.length);
}
public String getMechanismType() { return Constants.AXIS_SAX; }
1.44.2.1 +21 -27 xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java
Index: BeanDeserializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java,v
retrieving revision 1.44
retrieving revision 1.44.2.1
diff -u -r1.44 -r1.44.2.1
--- BeanDeserializer.java 13 Aug 2002 14:58:58 -0000 1.44
+++ BeanDeserializer.java 15 Aug 2002 05:23:18 -0000 1.44.2.1
@@ -198,19 +198,10 @@
prevQName = elemQName;
if (typeDesc != null) {
-
- // First lookup the field using the target namespace context
- // and local name. If this fails and the incoming element
- // name is not prefixed, lookup the name assuming an unqualified
- // name.
+ // Lookup the name appropriately (assuming an unqualified
+ // name for SOAP encoding, using the namespace otherwise)
String fieldName = typeDesc.getFieldNameForElement(elemQName,
isEncoded);
-// if (fieldName == null && (prefix == null || prefix.equals(""))) {
-// fieldName =
-// typeDesc.getFieldNameForElement(
-// new QName("", elemQName.getLocalPart()), false);
-// }
-
propDesc = (BeanPropertyDescriptor)propertyMap.get(fieldName);
}
@@ -225,8 +216,9 @@
Deserializer dSer = null;
MessageContext messageContext = context.getMessageContext();
if (propDesc == null && !messageContext.isEncoded()) {
- // try to put unknown elements into an Object property
- propDesc = getObjectPropertyDesc(elemQName, context);
+ // try to put unknown elements into an Object property, if
+ // appropriate
+ propDesc = getAnyPropertyDesc();
if (propDesc != null) {
dSer = context.getDeserializerForType(elemQName);
if (dSer == null) {
@@ -300,20 +292,22 @@
return (SOAPHandler)dSer;
}
- public BeanPropertyDescriptor
- getObjectPropertyDesc(QName qname,
- DeserializationContext context) {
- for (Iterator iterator = propertyMap.values().iterator();
- iterator.hasNext();) {
- BeanPropertyDescriptor propertyDesc =
- (BeanPropertyDescriptor) iterator.next();
- // try to find xsd:any namespace="##any" property
- if (propertyDesc.getName().equals("any") &&
- propertyDesc.getType().getName().equals("java.lang.Object")) {
- return propertyDesc;
- }
- }
- return null;
+ /**
+ * Get a BeanPropertyDescriptor which indicates where we should
+ * put extensibility elements (i.e. XML which falls under the
+ * auspices of an <xsd:any> declaration in the schema)
+ *
+ * @return an appropriate BeanPropertyDescriptor, or null
+ */
+ public BeanPropertyDescriptor getAnyPropertyDesc() {
+ if (typeDesc == null)
+ return null;
+
+ String anyName = typeDesc.getAnyName();
+ if (anyName == null)
+ return null;
+
+ return (BeanPropertyDescriptor)propertyMap.get(anyName);
}
/**
1.49.2.1 +2 -8 xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java
Index: BeanSerializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java,v
retrieving revision 1.49
retrieving revision 1.49.2.1
diff -u -r1.49 -r1.49.2.1
--- BeanSerializer.java 14 Aug 2002 14:43:54 -0000 1.49
+++ BeanSerializer.java 15 Aug 2002 05:23:19 -0000 1.49.2.1
@@ -211,7 +211,7 @@
context.serialize(qname,
null,
propValue,
- context.getQNameForClass(javaType),
+ context.getQNameForClass(propertyDescriptor[i].getType()),
true,
null);
} else {
@@ -499,13 +499,7 @@
QName qname,
AttributesImpl attrs,
SerializationContext context) throws Exception {
- StringWriter writer = new StringWriter();
- SerializationContext attributeContext = new AttributeSerializationContextImpl(writer, context);
- attributeContext.serialize(qname,
- null,
- propValue);
- writer.close();
- String propString = writer.getBuffer().toString();
+ String propString = context.getValueAsString(propValue, null);
String namespace = qname.getNamespaceURI();
String localName = qname.getLocalPart();
1.5.6.1 +11 -10 xml-axis/java/src/org/apache/axis/encoding/ser/CalendarSerializer.java
Index: CalendarSerializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/CalendarSerializer.java,v
retrieving revision 1.5
retrieving revision 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- CalendarSerializer.java 21 Jun 2002 13:00:30 -0000 1.5
+++ CalendarSerializer.java 15 Aug 2002 05:23:19 -0000 1.5.6.1
@@ -63,8 +63,8 @@
import org.apache.axis.Constants;
import org.apache.axis.wsdl.fromJava.Types;
-import org.apache.axis.encoding.Serializer;
import org.apache.axis.encoding.SerializationContext;
+import org.apache.axis.encoding.SimpleValueSerializer;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@@ -78,7 +78,7 @@
* Modified by @author Rich scheuerle <sc...@us.ibm.com>
* @see <a href="http://www.w3.org/TR/xmlschema-2/#dateTime">XML Schema 3.2.16</a>
*/
-public class CalendarSerializer implements Serializer {
+public class CalendarSerializer implements SimpleValueSerializer {
private static SimpleDateFormat zulu =
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
@@ -96,18 +96,19 @@
throws IOException
{
context.startElement(name, attributes);
+ context.writeString(getValueAsString(value));
+ context.endElement();
+ }
- Date date = value instanceof Date ? (Date) value : ((Calendar) value).getTime();
+ public String getValueAsString(Object value) {
+ Date date = value instanceof Date ? (Date) value :
+ ((Calendar) value).getTime();
- // Sun JDK bug http://developer.java.sun.com/developer/bugParade/bugs/4229798.html
- String format = null;
+ // Serialize including convert to GMT
synchronized (zulu) {
- format = zulu.format(date);
+ // Sun JDK bug http://developer.java.sun.com/developer/bugParade/bugs/4229798.html
+ return zulu.format(date);
}
- // Serialize including convert to GMT
- context.writeString(format);
-
- context.endElement();
}
public String getMechanismType() { return Constants.AXIS_SAX; }
1.5.2.1 +10 -7 xml-axis/java/src/org/apache/axis/encoding/ser/DateSerializer.java
Index: DateSerializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/DateSerializer.java,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- DateSerializer.java 31 Jul 2002 20:47:01 -0000 1.5
+++ DateSerializer.java 15 Aug 2002 05:23:19 -0000 1.5.2.1
@@ -65,6 +65,7 @@
import org.apache.axis.wsdl.fromJava.Types;
import org.apache.axis.encoding.Serializer;
import org.apache.axis.encoding.SerializationContext;
+import org.apache.axis.encoding.SimpleValueSerializer;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@@ -79,7 +80,7 @@
* Modified by @author Rich scheuerle <sc...@us.ibm.com>
* @see <a href="http://www.w3.org/TR/xmlschema-2/#dateTime">XML Schema 3.2.16</a>
*/
-public class DateSerializer implements Serializer {
+public class DateSerializer implements SimpleValueSerializer {
private static SimpleDateFormat zulu =
new SimpleDateFormat("yyyy-MM-dd");
@@ -94,21 +95,23 @@
throws IOException
{
context.startElement(name, attributes);
- String fdate;
+ context.writeString(getValueAsString(value));
+ context.endElement();
+ }
+ public String getValueAsString(Object value) {
+ StringBuffer buf = new StringBuffer();
synchronized (calendar) {
calendar.setTime((Date)value);
if (calendar.get(Calendar.ERA) == GregorianCalendar.BC) {
- context.writeString("-");
+ buf.append("-");
calendar.setTime((Date)value);
calendar.set(Calendar.ERA, GregorianCalendar.AD);
value = calendar.getTime();
}
- fdate = zulu.format((Date)value);
+ buf.append(zulu.format((Date)value));
}
-
- context.writeString(fdate);
- context.endElement();
+ return buf.toString();
}
public String getMechanismType() { return Constants.AXIS_SAX; }
1.10.2.1 +8 -8 xml-axis/java/src/org/apache/axis/encoding/ser/EnumSerializer.java
Index: EnumSerializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/EnumSerializer.java,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -r1.10 -r1.10.2.1
--- EnumSerializer.java 12 Aug 2002 22:58:47 -0000 1.10
+++ EnumSerializer.java 15 Aug 2002 05:23:19 -0000 1.10.2.1
@@ -87,7 +87,7 @@
* @author Rich Scheuerle <sc...@us.ibm.com>
* @author Sam Ruby <ru...@us.ibm.com>
*/
-public class EnumSerializer extends SimpleSerializer implements Serializer
+public class EnumSerializer extends SimpleSerializer
{
protected static Log log =
LogFactory.getLog(EnumSerializer.class.getName());
@@ -106,21 +106,21 @@
throws IOException
{
context.startElement(name, attributes);
-
+ context.writeString(getValueAsString(value));
+ context.endElement();
+ }
+
+ public String getValueAsString(Object value) {
// Invoke the toString method on the enumeration class and
// write out the result as a string.
try {
if (toStringMethod == null) {
toStringMethod = javaType.getMethod("toString", null);
}
- String propValue = (String) toStringMethod.invoke(value, null);
- context.writeString(propValue);
+ return (String) toStringMethod.invoke(value, null);
} catch (Exception e) {
log.error(JavaUtils.getMessage("exception00"), e);
- throw new IOException(e.toString());
}
-
- context.endElement();
+ return null;
}
-
}
1.7.2.1 +9 -16 xml-axis/java/src/org/apache/axis/encoding/ser/HexSerializer.java
Index: HexSerializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/HexSerializer.java,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- HexSerializer.java 7 Aug 2002 21:02:09 -0000 1.7
+++ HexSerializer.java 15 Aug 2002 05:23:19 -0000 1.7.2.1
@@ -56,7 +56,6 @@
package org.apache.axis.encoding.ser;
import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
import javax.xml.namespace.QName;
@@ -64,17 +63,9 @@
import org.apache.axis.Constants;
import org.apache.axis.wsdl.fromJava.Types;
-import org.apache.axis.encoding.Serializer;
-import org.apache.axis.encoding.SerializerFactory;
import org.apache.axis.encoding.SerializationContext;
-import org.apache.axis.encoding.Deserializer;
-import org.apache.axis.encoding.DeserializerFactory;
-import org.apache.axis.encoding.DeserializationContext;
-import org.apache.axis.encoding.Deserializer;
import org.apache.axis.types.HexBinary;
-import org.w3c.dom.Element;
-import org.w3c.dom.Document;
-import org.apache.axis.encoding.Base64;
+import org.apache.axis.encoding.SimpleValueSerializer;
import org.apache.axis.utils.JavaUtils;
/**
* Serializer for hexBinary.
@@ -83,7 +74,7 @@
* Modified by @author Rich scheuerle <sc...@us.ibm.com>
* @see <a href="http://www.w3.org/TR/xmlschema-2/#hexBinary">XML Schema 3.2.16</a>
*/
-public class HexSerializer implements Serializer {
+public class HexSerializer implements SimpleValueSerializer {
public QName xmlType;
public Class javaType;
@@ -100,15 +91,17 @@
throws IOException
{
context.startElement(name, attributes);
-
+ context.writeString(getValueAsString(value));
+ context.endElement();
+ }
+
+ public String getValueAsString(Object value) {
value = JavaUtils.convert(value, javaType);
if (javaType == HexBinary.class) {
- context.writeString(((HexBinary) value).toString());
+ return ((HexBinary) value).toString();
} else {
- context.writeString(HexBinary.encode((byte[]) value));
+ return HexBinary.encode((byte[]) value);
}
-
- context.endElement();
}
public String getMechanismType() { return Constants.AXIS_SAX; }
1.4.6.1 +7 -1 xml-axis/java/src/org/apache/axis/encoding/ser/QNameSerializer.java
Index: QNameSerializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/QNameSerializer.java,v
retrieving revision 1.4
retrieving revision 1.4.6.1
diff -u -r1.4 -r1.4.6.1
--- QNameSerializer.java 11 Jun 2002 14:53:56 -0000 1.4
+++ QNameSerializer.java 15 Aug 2002 05:23:19 -0000 1.4.6.1
@@ -58,6 +58,7 @@
import org.apache.axis.Constants;
import org.apache.axis.encoding.SerializationContext;
import org.apache.axis.encoding.Serializer;
+import org.apache.axis.encoding.SimpleValueSerializer;
import org.apache.axis.wsdl.fromJava.Types;
import org.xml.sax.Attributes;
@@ -68,7 +69,7 @@
/**
* Serializer for QNames.
*/
-public class QNameSerializer implements Serializer {
+public class QNameSerializer implements SimpleValueSerializer {
/**
* Serialize a QName.
@@ -82,6 +83,11 @@
context.startElement(name, attributes);
context.writeString(str);
context.endElement();
+ }
+
+ public String getValueAsString(Object value) {
+ // crap - FIXME!
+ return null;
}
public String getMechanismType() { return Constants.AXIS_SAX; }
1.22.2.1 +52 -43 xml-axis/java/src/org/apache/axis/encoding/ser/SimpleSerializer.java
Index: SimpleSerializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/SimpleSerializer.java,v
retrieving revision 1.22
retrieving revision 1.22.2.1
diff -u -r1.22 -r1.22.2.1
--- SimpleSerializer.java 14 Aug 2002 14:43:54 -0000 1.22
+++ SimpleSerializer.java 15 Aug 2002 05:23:19 -0000 1.22.2.1
@@ -60,8 +60,8 @@
import org.apache.axis.description.FieldDesc;
import org.apache.axis.description.TypeDesc;
import org.apache.axis.encoding.SerializationContext;
-import org.apache.axis.encoding.Serializer;
import org.apache.axis.encoding.SimpleType;
+import org.apache.axis.encoding.SimpleValueSerializer;
import org.apache.axis.utils.BeanPropertyDescriptor;
import org.apache.axis.utils.BeanUtils;
import org.apache.axis.utils.JavaUtils;
@@ -74,16 +74,26 @@
import javax.xml.namespace.QName;
import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
+
/**
* Serializer for primitives and anything simple whose value is obtained with toString()
*
* @author Rich Scheuerle <di...@yahoo.com>
*/
-public class SimpleSerializer implements Serializer {
+public class SimpleSerializer implements SimpleValueSerializer {
+ private static SimpleDateFormat zulu =
+ new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+ // 0123456789 0 123456789
+
+ static {
+ zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
+ }
public QName xmlType;
public Class javaType;
-
+
private BeanPropertyDescriptor[] propertyDescriptor = null;
private TypeDesc typeDesc = null;
@@ -110,11 +120,11 @@
if (typeDesc == null) {
typeDesc = TypeDesc.getTypeDescForClass(javaType);
}
- // Get the cached propertyDescriptor from the type or
+ // Get the cached propertyDescriptor from the type or
// generate a fresh one.
if (typeDesc != null) {
propertyDescriptor = typeDesc.getPropertyDescriptors();
- } else {
+ } else {
propertyDescriptor = BeanUtils.getPd(javaType, null);
}
}
@@ -138,39 +148,38 @@
// get any attributes
if (value instanceof SimpleType)
attributes = getObjectAttributes(value, attributes, context);
-
+
context.startElement(name, attributes);
if (value != null) {
- // We could have separate serializers/deserializers to take
- // care of Float/Double cases, but it makes more sence to
- // put them here with the rest of the java lang primitives.
- if (value instanceof Float ||
- value instanceof Double) {
- double data = 0.0;
- if (value instanceof Float) {
- data = ((Float) value).doubleValue();
- } else {
- data = ((Double) value).doubleValue();
- }
- if (Double.isNaN(data)) {
- context.writeString("NaN");
- } else if (data == Double.POSITIVE_INFINITY) {
- context.writeString("INF");
- } else if (data == Double.NEGATIVE_INFINITY) {
- context.writeString("-INF");
- } else {
- context.writeString(value.toString());
- }
- } else if (value instanceof String) {
- context.writeString(
- XMLUtils.xmlEncodeString(value.toString()));
- } else if (value instanceof SimpleType) {
- context.writeString(value.toString());
+ context.writeString(getValueAsString(value));
+ }
+ context.endElement();
+ }
+
+ public String getValueAsString(Object value) {
+ // We could have separate serializers/deserializers to take
+ // care of Float/Double cases, but it makes more sence to
+ // put them here with the rest of the java lang primitives.
+ if (value instanceof Float ||
+ value instanceof Double) {
+ double data = 0.0;
+ if (value instanceof Float) {
+ data = ((Float) value).doubleValue();
} else {
- context.writeString(value.toString());
+ data = ((Double) value).doubleValue();
+ }
+ if (Double.isNaN(data)) {
+ return "NaN";
+ } else if (data == Double.POSITIVE_INFINITY) {
+ return "INF";
+ } else if (data == Double.NEGATIVE_INFINITY) {
+ return "-INF";
}
+ } else if (value instanceof String) {
+ return XMLUtils.xmlEncodeString((String)value);
}
- context.endElement();
+
+ return value.toString();
}
private Attributes getObjectAttributes(Object value,
@@ -209,14 +218,14 @@
Object propValue = propertyDescriptor[i].get(value);
// If the property value does not exist, don't serialize
// the attribute. In the future, the decision to serializer
- // the attribute may be more sophisticated. For example, don't
+ // the attribute may be more sophisticated. For example, don't
// serialize if the attribute matches the default value.
if (propValue != null) {
- String propString = propValue.toString();
-
+ String propString = getValueAsString(propValue);
+
String namespace = qname.getNamespaceURI();
String localName = qname.getLocalPart();
-
+
attrs.addAttribute(namespace,
localName,
context.qName2String(qname),
@@ -232,7 +241,7 @@
return attrs;
}
-
+
public String getMechanismType() { return Constants.AXIS_SAX; }
/**
@@ -248,7 +257,7 @@
// Let the caller generate WSDL if this is not a SimpleType
if (!SimpleType.class.isAssignableFrom(javaType))
return false;
-
+
// ComplexType representation of SimpleType bean class
Element complexType = types.createElement("complexType");
types.writeSchemaElement(xmlType, complexType);
@@ -259,7 +268,7 @@
complexType.appendChild(simpleContent);
Element extension = types.createElement("extension");
simpleContent.appendChild(extension);
-
+
// Get the base type from the "value" element of the bean
String base = "string";
for (int i=0; i<propertyDescriptor.length; i++) {
@@ -305,15 +314,15 @@
Class type = bpd.getType();
// Attribute must extend a simple type, enum or SimpleType
if (!types.isAcceptableAsAttribute(type)) {
- throw new AxisFault(JavaUtils.getMessage("AttrNotSimpleType01",
+ throw new AxisFault(JavaUtils.getMessage("AttrNotSimpleType01",
type.getName()));
- }
+ }
base = types.writeType(type);
extension.setAttribute("base", base);
}
// done
return true;
-
+
}
}
No revision
No revision
1.5.6.1 +8 -2 xml-axis/java/src/org/apache/axis/utils/JWSClassLoader.java
Index: JWSClassLoader.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/JWSClassLoader.java,v
retrieving revision 1.5
retrieving revision 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- JWSClassLoader.java 20 Jun 2002 16:48:19 -0000 1.5
+++ JWSClassLoader.java 15 Aug 2002 05:23:19 -0000 1.5.6.1
@@ -54,7 +54,6 @@
*/
package org.apache.axis.utils;
-import java.util.Hashtable;
import java.io.*;
/**
@@ -102,10 +101,17 @@
/* Create a new Class object from it */
/*************************************/
byte[] data = baos.toByteArray();
-// Class cls =
defineClass( name, data, 0, data.length );
ClassUtils.setClassLoader(name,this);
+ }
+
+ public Class loadClass(String s) throws ClassNotFoundException {
+ return super.loadClass(s);
+ }
+
+ protected Class findClass(String s) throws ClassNotFoundException {
+ return super.findClass(s);
}
/**
No revision
No revision
1.54.2.1 +2 -2 xml-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java
Index: Types.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java,v
retrieving revision 1.54
retrieving revision 1.54.2.1
diff -u -r1.54 -r1.54.2.1
--- Types.java 9 Aug 2002 13:56:24 -0000 1.54
+++ Types.java 15 Aug 2002 05:23:19 -0000 1.54.2.1
@@ -507,9 +507,9 @@
Serializer ser = null;
SerializerFactory factory = null;
if (tm != null) {
- factory = (SerializerFactory)tm.getSerializer(type);
+ factory = (SerializerFactory)tm.getSerializer(type, null);
} else {
- factory = (SerializerFactory)defaultTM.getSerializer(type);
+ factory = (SerializerFactory)defaultTM.getSerializer(type, null);
}
// If no factory is found, use the BeanSerializerFactory
No revision
No revision
1.17.2.1 +8 -0 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanHelperWriter.java
Index: JavaBeanHelperWriter.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanHelperWriter.java,v
retrieving revision 1.17
retrieving revision 1.17.2.1
diff -u -r1.17 -r1.17.2.1
--- JavaBeanHelperWriter.java 8 Aug 2002 15:17:11 -0000 1.17
+++ JavaBeanHelperWriter.java 15 Aug 2002 05:23:19 -0000 1.17.2.1
@@ -257,6 +257,14 @@
if (elementMetaData != null) {
for (int i=0; i<elementMetaData.size(); i++) {
ElementDecl elem = (ElementDecl) elementMetaData.elementAt(i);
+
+ if (elem.getAnyElement()) {
+ String anyName = "any";
+ pw.println(" typeDesc.setAnyName(\"" +
+ anyName + "\");");
+ continue;
+ }
+
String elemLocalName = elem.getName().getLocalPart();
String fieldName = Utils.xmlNameToJava(elemLocalName);
QName xmlName = elem.getName();
1.20.6.1 +2 -0 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java
Index: JavaBeanWriter.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java,v
retrieving revision 1.20
retrieving revision 1.20.6.1
diff -u -r1.20 -r1.20.6.1
--- JavaBeanWriter.java 1 Jul 2002 16:09:38 -0000 1.20
+++ JavaBeanWriter.java 15 Aug 2002 05:23:19 -0000 1.20.6.1
@@ -191,6 +191,8 @@
for (int i = 0; i < elements.size(); i++) {
ElementDecl elem = (ElementDecl)elements.get(i);
String typeName = elem.getType().getName();
+ if (elem.getAnyElement())
+ typeName = "java.lang.Object";
String elemName = elem.getName().getLocalPart();
String variableName = Utils.xmlNameToJava(elemName);
names.add(typeName);
No revision
No revision
1.33.2.1 +0 -5 xml-axis/java/test/encoding/TestSer.java
Index: TestSer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/encoding/TestSer.java,v
retrieving revision 1.33
retrieving revision 1.33.2.1
diff -u -r1.33 -r1.33.2.1
--- TestSer.java 24 Jul 2002 19:08:33 -0000 1.33
+++ TestSer.java 15 Aug 2002 05:23:19 -0000 1.33.2.1
@@ -157,9 +157,4 @@
fail(e.getMessage());
}
}
-
- public static void main(String[] args) {
- TestSer tester = new TestSer("TestSer");
- tester.testEmptyXMLNS();
- }
}