santiagopg    2003/10/22 16:25:07

  Modified:    java/src/org/apache/xalan/xsltc/trax TemplatesImpl.java
  Log:
  Committing path for bugzilla 22438 from Bhakti Mehta ([EMAIL PROTECTED]). 
This patch fixes serialization problems of Templates objects in XSLTC. A 
user-defined URIResolver associated to a Templates object is also serialized 
whenever possible (i.e. if it is also serializable).
  
  Revision  Changes    Path
  1.30      +33 -3     
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TemplatesImpl.java
  
  Index: TemplatesImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TemplatesImpl.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- TemplatesImpl.java        14 Aug 2003 16:27:43 -0000      1.29
  +++ TemplatesImpl.java        22 Oct 2003 23:25:07 -0000      1.30
  @@ -67,6 +67,7 @@
   
   import java.io.IOException;
   import java.io.ObjectInputStream;
  +import java.io.ObjectOutputStream;
   import java.io.Serializable;
   import java.util.Properties;
   
  @@ -132,16 +133,18 @@
   
       /**
        * This URIResolver is passed to all Transformers.
  +     * Declaring it transient to fix bug 22438 
        */
  -    private URIResolver _uriResolver = null;
  +    private transient URIResolver _uriResolver = null;
   
       /**
        * Cache the DTM for the stylesheet in a thread local variable,
        * which is used by the document('') function.
        * Use ThreadLocal because a DTM cannot be shared between
        * multiple threads. 
  +     * Declaring it transient to fix bug 22438 
        */
  -    private ThreadLocal _sdom = new ThreadLocal();
  +    private transient ThreadLocal _sdom = new ThreadLocal();
       
       /**
        * A reference to the transformer factory that this templates
  @@ -204,13 +207,40 @@
        *  Overrides the default readObject implementation since we decided
        *  it would be cleaner not to serialize the entire tranformer
        *  factory.  [ ref bugzilla 12317 ]
  +     *  We need to check if the user defined class for URIResolver also
  +     *  implemented Serializable
  +     *  if yes then we need to deserialize the URIResolver
  +     *  Fix for bugzilla bug 22438
        */
       private void  readObject(ObjectInputStream is) 
         throws IOException, ClassNotFoundException 
       {
        is.defaultReadObject();
  +        if (is.readBoolean()) {
  +            _uriResolver = (URIResolver) is.readObject();
  +        }
  +
        _tfactory = new TransformerFactoryImpl();
       } 
  +
  +
  +    /**
  +     *  This is to fix bugzilla bug 22438
  +     *  If the user defined class implements URIResolver and Serializable
  +     *  then we want it to get serialized
  +     */
  +    private void writeObject(ObjectOutputStream os)
  +        throws IOException, ClassNotFoundException {
  +        os.defaultWriteObject();
  +        if (_uriResolver instanceof Serializable) {
  +            os.writeBoolean(true);
  +            os.writeObject((Serializable) _uriResolver);
  +        }
  +        else {
  +            os.writeBoolean(false);
  +        }
  +    }
  +
   
        /**
        * Store URIResolver needed for Transformers.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to