axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rineh...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/utils XMLUtils.java
Date Mon, 25 Mar 2002 23:55:30 GMT
rineholt    02/03/25 15:55:30

  Modified:    java/src/org/apache/axis/attachments MimeUtils.java
               java/src/org/apache/axis/utils XMLUtils.java
  Log:
  Clean up the parser we reuse so it had no long references to old context handlers.
  Don't synchronize the the SAXparser creation.
  Clean up patch for multi-line headers.
  
  Revision  Changes    Path
  1.13      +1 -15     xml-axis/java/src/org/apache/axis/attachments/MimeUtils.java
  
  Index: MimeUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/attachments/MimeUtils.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- MimeUtils.java	15 Mar 2002 01:14:10 -0000	1.12
  +++ MimeUtils.java	25 Mar 2002 23:55:30 -0000	1.13
  @@ -213,21 +213,7 @@
        * This routine will get the content type.
        */
       public static String getContentType(javax.mail.internet.MimeMultipart mp) {
  -        String ct= mp.getContentType();
  -        StringBuffer ret= new StringBuffer();
  -        for(java.util.StringTokenizer st= new java.util.StringTokenizer(ct, "\n\r"); st.hasMoreTokens();
){
  -            String line= st.nextToken();
  -            if(line != null && 0 < line.length()){
  -                int i=0;
  -                for(; i < line.length() ; ++i ) {
  -                    char n = line.charAt(i);
  -                    if(n != ' ' && n != '\t' ) break;
  -                }       
  -                if( i >1 ) line= line.substring(i-1);
  -                if(line.length() >0) ret.append(line);
  -            }    
  -        }
  -        return  ret.toString(); 
  +        return mp.getContentType();
       }
       /**
        * This routine will create a multipar object from the parts and the SOAP content.
  
  
  
  1.45      +31 -7     xml-axis/java/src/org/apache/axis/utils/XMLUtils.java
  
  Index: XMLUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/XMLUtils.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- XMLUtils.java	28 Feb 2002 13:37:48 -0000	1.44
  +++ XMLUtils.java	25 Mar 2002 23:55:30 -0000	1.45
  @@ -72,6 +72,9 @@
   import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
   import org.xml.sax.SAXParseException;
  +import org.xml.sax.helpers.DefaultHandler;
  +import org.xml.sax.XMLReader;
  +
   
   import javax.xml.parsers.DocumentBuilder;
   import javax.xml.parsers.DocumentBuilderFactory;
  @@ -179,17 +182,21 @@
           return( dbf );
       }
   
  +    private static DefaultHandler doNothingContentHandler = new DefaultHandler(); //no
events should h
  +    private static boolean tryReset= true;
  +
       /** Get a SAX parser instance from the JAXP factory.
        *
        * @return a SAXParser instance.
        */
  -    public static synchronized SAXParser getSAXParser() {
  +    public static SAXParser getSAXParser() {
  +        synchronized (XMLUtils.class ) {
  +          if(!saxParsers.empty()) 
  +                 return (SAXParser )saxParsers.pop();
  +         }
           try {
  -            if (saxParsers.empty()) {
                   return saxFactory.newSAXParser();
  -            } else {
  -                return (SAXParser)saxParsers.pop();
  -            }
  +            
           } catch (ParserConfigurationException e) {
               log.error(JavaUtils.getMessage("parserConfigurationException00"), e);
               return null;
  @@ -199,11 +206,28 @@
           }
       }
   
  +
       /** Return a SAX parser for reuse.
        * @param SAXParser A SAX parser that is available for reuse
        */
  -    public static synchronized SAXParser releaseSAXParser(SAXParser parser) {
  -        return (SAXParser)saxParsers.push(parser);
  +    public static void releaseSAXParser(SAXParser parser) {
  +        if(!tryReset) return;
  +       
  +        //Free up possible ref. held by past contenthandler.
  +        try{
  +            XMLReader xmlReader= parser.getXMLReader(); 
  +            if(null != xmlReader){
  +                xmlReader.setContentHandler(doNothingContentHandler); 
  +                xmlReader.setDTDHandler(doNothingContentHandler); 
  +                xmlReader.setEntityResolver(doNothingContentHandler);
  +                xmlReader.setErrorHandler(doNothingContentHandler);
  +                synchronized (XMLUtils.class ) {
  +                saxParsers.push(parser);
  +                }
  +            }    
  +            else     
  +             tryReset= false;
  +        }catch(org.xml.sax.SAXException e){ tryReset= false;}
       }
   
       public static Document newDocument() {
  
  
  

Mime
View raw message