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 ru...@apache.org on 2002/08/08 00:31:34 UTC
cvs commit: xml-axis/java/src/org/apache/axis/encoding/ser BeanSerializer.java BeanSerializerFactory.java
rubys 2002/08/07 15:31:34
Modified: java/src/org/apache/axis/encoding/ser BeanSerializer.java
BeanSerializerFactory.java
Log:
Optimize construction of a BeanSerializer by caching the
type and property descriptors in the Factory.
Revision Changes Path
1.46 +11 -3 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.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- BeanSerializer.java 29 Jul 2002 19:20:50 -0000 1.45
+++ BeanSerializer.java 7 Aug 2002 22:31:33 -0000 1.46
@@ -109,14 +109,22 @@
// Construct BeanSerializer for the indicated class/qname
public BeanSerializer(Class javaType, QName xmlType, TypeDesc typeDesc) {
- this.xmlType = xmlType;
- this.javaType = javaType;
- this.typeDesc = typeDesc;
+ this(javaType, xmlType, typeDesc, null);
+
if (typeDesc != null) {
propertyDescriptor = typeDesc.getPropertyDescriptors();
} else {
propertyDescriptor = BeanUtils.getPd(javaType, null);
}
+ }
+
+ // Construct BeanSerializer for the indicated class/qname/propertyDesc
+ public BeanSerializer(Class javaType, QName xmlType, TypeDesc typeDesc,
+ BeanPropertyDescriptor[] propertyDescriptor) {
+ this.xmlType = xmlType;
+ this.javaType = javaType;
+ this.typeDesc = typeDesc;
+ this.propertyDescriptor = propertyDescriptor;
}
/**
1.5 +35 -0 xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializerFactory.java
Index: BeanSerializerFactory.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializerFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BeanSerializerFactory.java 11 Jun 2002 14:53:55 -0000 1.4
+++ BeanSerializerFactory.java 7 Aug 2002 22:31:33 -0000 1.5
@@ -62,6 +62,7 @@
import javax.xml.rpc.JAXRPCException;
import java.io.IOException;
+import org.apache.axis.description.TypeDesc;
import org.apache.axis.encoding.Serializer;
import org.apache.axis.encoding.SerializerFactory;
import org.apache.axis.encoding.SerializationContext;
@@ -69,13 +70,20 @@
import org.apache.axis.encoding.DeserializerFactory;
import org.apache.axis.encoding.DeserializationContext;
import org.apache.axis.encoding.Deserializer;
+import org.apache.axis.utils.BeanUtils;
import org.apache.axis.utils.JavaUtils;
+import org.apache.axis.utils.BeanPropertyDescriptor;
+
/**
* SerializerFactory for Bean
*
* @author Rich Scheuerle <sc...@us.ibm.com>
*/
public class BeanSerializerFactory extends BaseSerializerFactory {
+
+ protected TypeDesc typeDesc = null;
+ protected BeanPropertyDescriptor[] propertyDescriptor = null;
+
public BeanSerializerFactory(Class javaType, QName xmlType) {
super(BeanSerializer.class, false, xmlType, javaType);
// Sometimes an Enumeration class is registered as a Bean.
@@ -88,5 +96,32 @@
public javax.xml.rpc.encoding.Serializer getSerializerAs(String mechanismType)
throws JAXRPCException {
return (Serializer) super.getSerializerAs(mechanismType);
+ }
+
+ /**
+ * Optimize construction of a BeanSerializer by caching the
+ * type and property descriptors.
+ */
+ protected Serializer getGeneralPurpose(String mechanismType) {
+ if (javaType == null || xmlType == null) {
+ return super.getGeneralPurpose(mechanismType);
+ }
+
+ if (serClass == EnumSerializer.class) {
+ return super.getGeneralPurpose(mechanismType);
+ }
+
+ if (propertyDescriptor == null && firstCall) {
+ typeDesc = TypeDesc.getTypeDescForClass(javaType);
+
+ if (typeDesc != null) {
+ propertyDescriptor = typeDesc.getPropertyDescriptors();
+ } else {
+ propertyDescriptor = BeanUtils.getPd(javaType, null);
+ }
+ }
+
+ return new BeanSerializer(javaType, xmlType, typeDesc,
+ propertyDescriptor);
}
}