donaldp     2002/07/10 01:57:10

  Modified:    xmlutil/src/java/org/apache/excalibur/xmlizer/impl
                        HTMLXMLizer.java
  Log:
  Parser is always threadsafe so no need to release it.
  
  Revision  Changes    Path
  1.8       +23 -22    
jakarta-avalon-excalibur/xmlutil/src/java/org/apache/excalibur/xmlizer/impl/HTMLXMLizer.java
  
  Index: HTMLXMLizer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/xmlutil/src/java/org/apache/excalibur/xmlizer/impl/HTMLXMLizer.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- HTMLXMLizer.java  10 Jul 2002 08:53:17 -0000      1.7
  +++ HTMLXMLizer.java  10 Jul 2002 08:57:10 -0000      1.8
  @@ -41,15 +41,17 @@
       extends AbstractLogEnabled
       implements XMLizer, ThreadSafe, Composable
   {
  +    private static final String HTML_MIME_TYPE = "text/html";
  +
       /** Used for converting DOM -> SAX */
       private static final Properties c_format = createFormatProperties();
   
  -    /** The component manager */
  -    private ComponentManager m_manager;
  +    /** The parser used by {@link XMLizer} */
  +    private Parser m_parser;
   
       public void compose( final ComponentManager manager )
       {
  -        m_manager = manager;
  +        m_parser = (Parser)manager.lookup( Parser.ROLE );
       }
   
       /**
  @@ -73,29 +75,34 @@
       {
           if( null == stream )
           {
  -            throw new ComponentException( "Stream must not be null." );
  +            final String message = "Stream must not be null.";
  +            throw new ComponentException( message );
           }
   
           if( null == handler )
           {
  -            throw new ComponentException( "Handler must not be null." );
  +            final String message = "Handler must not be null.";
  +            throw new ComponentException( message );
           }
   
           if( null == mimeType )
           {
               if( getLogger().isDebugEnabled() )
               {
  -                getLogger().debug( "No mime-type for xmlizing " + systemID +
  -                                   ", guessing text/html" );
  +                final String message =
  +                    "No mime-type for xmlizing " + systemID +
  +                    ", guessing text/html";
  +                getLogger().debug( message );
               }
           }
  -        else if( !mimeType.equalsIgnoreCase( "text/html" ) )
  +        else if( !mimeType.equalsIgnoreCase( HTML_MIME_TYPE ) )
           {
               if( getLogger().isDebugEnabled() )
               {
  -                getLogger().debug( "Mime-type " + mimeType +
  -                                   "not supported for xmlizing " + systemID +
  -                                   ", guessing text/html" );
  +                final String message = "Mime-type " + mimeType +
  +                    "not supported for xmlizing " + systemID +
  +                    ", guessing text/html";
  +                getLogger().debug( message );
               }
           }
   
  @@ -103,6 +110,7 @@
           xhtmlconvert.setXmlOut( true );
           xhtmlconvert.setXHTML( true );
           xhtmlconvert.setShowWarnings( false );
  +
           final StringWriter writer = new StringWriter();
           try
           {
  @@ -119,17 +127,10 @@
   
           final InputSource inputSource =
               new InputSource( new java.io.StringReader( writer.toString() ) );
  -        if( null != systemID ) inputSource.setSystemId( systemID );
  +        if( null != systemID )
  +            inputSource.setSystemId( systemID );
   
  -        final Parser parser = (Parser)m_manager.lookup( Parser.ROLE );
  -        try
  -        {
  -            parser.parse( inputSource, handler );
  -        }
  -        finally
  -        {
  -            m_manager.release( parser );
  -        }
  +        m_parser.parse( inputSource, handler );
       }
   
       /**
  
  
  

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

Reply via email to