tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/xml XmlMapper.java
Date Tue, 22 Feb 2000 21:44:29 GMT
costin      00/02/22 13:44:29

  Modified:    src/share/org/apache/tomcat/context WebXmlReader.java
               src/share/org/apache/tomcat/core Context.java
                        ContextManager.java
               src/share/org/apache/tomcat/startup Tomcat.java
               src/share/org/apache/tomcat/util/xml XmlMapper.java
  Log:
  Changed XmlMapper - it no longer ignores errors.
  
  If any error happens in configuration it will report the line number
  ( if Locator is set and working ) and the xml path / attributes for the
  ofending element, and stop parsing.
  
  The caller should handle any recovery or report the error.
  
  This is the same behavior as in the case of a XML error or
  DTD violation.
  
  Revision  Changes    Path
  1.13      +2 -0      jakarta-tomcat/src/share/org/apache/tomcat/context/WebXmlReader.java
  
  Index: WebXmlReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/WebXmlReader.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- WebXmlReader.java	2000/02/18 18:14:50	1.12
  +++ WebXmlReader.java	2000/02/22 21:44:28	1.13
  @@ -118,7 +118,9 @@
   
   	    Object ctx1=xh.readXml(f, ctx);
   	} catch(Exception ex ) {
  +	    System.out.println("ERROR reading " + file);
   	    ex.printStackTrace();
  +	    // XXX we should invalidate the context and un-load it !!!
   	}
       }
   
  
  
  
  1.61      +7 -3      jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- Context.java	2000/02/22 21:06:36	1.60
  +++ Context.java	2000/02/22 21:44:28	1.61
  @@ -580,12 +580,16 @@
       public void logServlet( String msg , Throwable t ) {
   	if (firstLog == true) {
   	    csLog = Logger.getLogger("servlet_log");
  -	    csLog.setCustomOutput("true");
  -	    csLog.setVerbosityLevel(Logger.INFORMATION);
  -	    firstLog = false;
  +	    if( csLog!= null ) {
  +		csLog.setCustomOutput("true");
  +		csLog.setVerbosityLevel(Logger.INFORMATION);
  +		firstLog = false;
  +	    }
   	}
   	if (csLog != null) {
   	    csLog.log("<l:context path=\"" + path  + "\" >" + msg + "</l:context>");
  +	} else {
  +	    System.out.println("<l:context path=\"" + path  + "\" >" + msg + "</l:context>");
   	}
       }
       
  
  
  
  1.52      +6 -3      jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- ContextManager.java	2000/02/22 21:06:37	1.51
  +++ ContextManager.java	2000/02/22 21:44:28	1.52
  @@ -719,15 +719,18 @@
       public final void doLog(String msg) {
   	if (firstLog == true) {
   	    cmLog = Logger.getLogger("tc_log");
  -	    cmLog.setCustomOutput("true");
  -	    cmLog.setVerbosityLevel(Logger.INFORMATION);
  +	    if( cmLog!= null ) {
  +		cmLog.setCustomOutput("true");
  +		cmLog.setVerbosityLevel(Logger.INFORMATION);
  +	    }
   	    firstLog = false;
   	}
   
   	if (cmLog != null) {
  -	    // customOutput !
   	    cmLog.log(msg + "\n");
   	    // XXX \n should be added to logger, portable
  +	} else {
  +	    System.out.println(msg);
   	}
       }
       
  
  
  
  1.11      +7 -1      jakarta-tomcat/src/share/org/apache/tomcat/startup/Tomcat.java
  
  Index: Tomcat.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/Tomcat.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Tomcat.java	2000/02/18 18:14:51	1.10
  +++ Tomcat.java	2000/02/22 21:44:29	1.11
  @@ -90,7 +90,13 @@
   	xh.setDebug( 0 );
   	ContextManager cm=new ContextManager();
   	setHelper( xh );
  -	xh.readXml(f,cm);
  +	try {
  +	    xh.readXml(f,cm);
  +	} catch( Exception ex ) {
  +	    System.out.println("FATAL: configuration error" );
  +	    ex.printStackTrace();
  +	    System.exit(1);
  +	}
   
   	// Generate Apache configs
   	//
  
  
  
  1.10      +46 -29    jakarta-tomcat/src/share/org/apache/tomcat/util/xml/XmlMapper.java
  
  Index: XmlMapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/xml/XmlMapper.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XmlMapper.java	2000/02/22 21:06:47	1.9
  +++ XmlMapper.java	2000/02/22 21:44:29	1.10
  @@ -68,20 +68,43 @@
   	    matchStart( this);
   	    body="";
   	} catch (Exception ex) {
  -	    ex.printStackTrace();
  +	    // do not ignore messages, caller should handle it
  +	    throw new SAXException( positionToString(), ex );
   	}
       }
   
  +    private String positionToString() {
  +	StringBuffer sb=new StringBuffer();
  +	if( locator!=null ) sb.append("Line ").append(locator.getLineNumber()).append(" ");
  +	sb.append("/");
  +	for( int i=0; i< sp ; i++ ) sb.append( tagStack[i] ).append( "/" );
  +	sb.append(" ");
  +	AttributeList attributes=(AttributeList) attributeStack[sp-1];
  +	if( attributes!=null) 
  +	    for (int i = 0; i < attributes.getLength (); i++) {
  +		sb.append(attributes.getName(i)).append( "=" ).append(attributes.getValue(i));
  +		sb.append(" ");
  +	    }
  +	
  +	return sb.toString();
  +    }
  +    
       public void endElement (String tag) throws SAXException
       {
  -	// Find a match for the current tag in the context
  -	matchEnd( this);
  +	try {
  +	    // Find a match for the current tag in the context
  +	    matchEnd( this);
   	    
  -	if( sp > 1 ) {
  -	    tagStack[sp] = null;
  -	    attributeStack[sp]=null;
  +	    if( sp > 1 ) {
  +		tagStack[sp] = null;
  +		attributeStack[sp]=null;
  +	    }
  +	    sp--;
  +	} catch (Exception ex) {
  +	    // do not ignore messages, caller should handle it
  +	    throw new SAXException(  positionToString(), ex );
   	}
  -	sp--;
  +
       }
   
       public void characters (char buf [], int offset, int len)
  @@ -190,10 +213,12 @@
   		" due to: " + ioe;
   	    throw new Exception(msg);
   	} catch (SAXException se) {
  -	    se.printStackTrace();
  -	    String msg = "Can't open config file: " + xmlFile +
  -		" due to: " + se;
  -	    throw new Exception(msg);
  +	    System.out.println("ERROR reading " + xmlFile);
  +	    System.out.println("At " + se.getMessage());
  +	    //	    se.printStackTrace();
  +	    System.out.println();
  +	    Exception ex1=se.getException();
  +	    throw ex1;
   	}
       }
   
  @@ -283,27 +308,19 @@
   	return matchCount;
       }
   
  -    void matchStart(SaxContext ctx ) {
  -	try {
  -	    int matchCount=match( ctx, matching );
  -	    for ( int i=0; i< matchCount; i++ ) {
  -		matching[i].action.start( ctx );
  -	    }
  -	} catch(Exception ex) {
  -	    ex.printStackTrace();
  +    void matchStart(SaxContext ctx ) throws Exception {
  +	int matchCount=match( ctx, matching );
  +	for ( int i=0; i< matchCount; i++ ) {
  +	    matching[i].action.start( ctx );
   	}
       }
   
  -    void matchEnd(SaxContext ctx ) {
  -	try {
  -	    int matchCount=match( ctx, matching );
  -	    for ( int i=0; i< matchCount; i++ ) 
  -		matching[i].action.end( ctx );
  -	    for ( int i=0; i< matchCount; i++ ) 
  -		matching[i].action.cleanup( ctx );
  -	} catch(Exception ex) {
  -	    ex.printStackTrace();
  -	}
  +    void matchEnd(SaxContext ctx ) throws Exception {
  +	int matchCount=match( ctx, matching );
  +	for ( int i=0; i< matchCount; i++ ) 
  +	    matching[i].action.end( ctx );
  +	for ( int i=0; i< matchCount; i++ ) 
  +	    matching[i].action.cleanup( ctx );
       }
   
       /** Trick for off-line usage
  
  
  

Mime
View raw message