minchau 2004/05/13 11:19:37
Modified: java/src/org/apache/xalan/client XSLTProcessorApplet.java
Log:
PR: bugzilla
Submitted by: Brian Minchau
Reviewed by: Christine Li
Fixing binary compatibility (serialization/de-serialization)
of XSLTProcessorApplet.
Revision Changes Path
1.22 +29 -8
xml-xalan/java/src/org/apache/xalan/client/XSLTProcessorApplet.java
Index: XSLTProcessorApplet.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/client/XSLTProcessorApplet.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- XSLTProcessorApplet.java 11 Feb 2004 05:22:02 -0000 1.21
+++ XSLTProcessorApplet.java 13 May 2004 18:19:37 -0000 1.22
@@ -49,6 +49,11 @@
* <li>Call the [EMAIL PROTECTED] #getHtmlText} method (or one of the
transformToHtml() methods)
* to perform the transformation and return the result as a String.</li>
* </ol>
+ *
+ * This class extends Applet which ultimately causes this class to implement
Serializable.
+ * This is a serious restriction on this class. All fields that are not
transient and not
+ * static are written-out/read-in during serialization. So even private
fields essentially
+ * become part of the API. Developers need to take care when modifying
fields.
* @xsl.usage general
*/
public class XSLTProcessorApplet extends Applet
@@ -56,9 +61,11 @@
/**
* The stylesheet processor.
- * @serial
+ * This field is now transient because a
+ * javax.xml.transform.TransformerFactory from JAXP
+ * makes no claims to be serializable.
*/
- TransformerFactory m_tfactory = null;
+ transient TransformerFactory m_tfactory = null;
/**
* @serial
@@ -358,10 +365,6 @@
m_attrValueToSet = value;
}
- /**
- * Stylesheet parameter keys
- */
- private Enumeration m_keys;
/**
* Stylesheet parameter key/value pair stored in a hashtable
@@ -658,7 +661,8 @@
Transformer transformer = m_tfactory.newTransformer(xslSource);
- m_keys = m_parameters.keys();
+
+ Enumeration m_keys = m_parameters.keys();
while (m_keys.hasMoreElements()){
Object key = m_keys.nextElement();
Object expression = m_parameters.get(key);
@@ -753,4 +757,21 @@
}
}
}
+
+ // For compatiblity with old serialized objects
+ // We will change non-serialized fields and change methods
+ // and not have this break us.
+ private static final long serialVersionUID=4618876841979251422L;
+
+ // For compatibility when de-serializing old objects
+ private void readObject(java.io.ObjectInputStream inStream) throws
IOException, ClassNotFoundException
+ {
+ inStream.defaultReadObject();
+
+ // Needed assignment of non-serialized fields
+
+ // A TransformerFactory is not guaranteed to be serializable,
+ // so we create one here
+ m_tfactory = TransformerFactory.newInstance();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]