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 Sat, 03 Jun 2000 06:35:25 GMT
costin      00/06/02 23:35:24

  Modified:    src/share/org/apache/tomcat/context WebXmlReader.java
               src/share/org/apache/tomcat/core ContextManager.java
               src/share/org/apache/tomcat/net ServerSocketFactory.java
               src/share/org/apache/tomcat/request Jdk12Interceptor.java
               src/share/org/apache/tomcat/service PoolTcpConnector.java
               src/share/org/apache/tomcat/util MimeMap.java
               src/share/org/apache/tomcat/util/xml XmlMapper.java
  Removed:     src/share/org/apache/tomcat/service TODO
  Log:
  A number of changes:
  
  - PoolTcpConnector - a bit of code move, but very little change. We now treat setProperty
  and setAttribute the same, and we have a cleaner set of properties.
  - Pass all the properties/attributes to the ConnectionHandler and SocketFactory - this
  way you can configure all the connector components in the same way.
  - That includes creation of a SocketFactory by passing the name of the class. Not tested,
  I'll do that when we have SSLFactory ready
  
  - added an option to validate ( by default on ) - some parsers have problems,
  and we want to be able to turn it off if we want ( and it's faster without )
  
  - fall back to old sax parser if jaxp is not available. Default is crimson, see next.
  
  - I still can't use it with Xerces - at least if I'm not connected, it seems to
  be a bug in the way it handles external entities. Crimson and the old sun parser
  work fine, I'll try to find a workaround in xerces.
  
  - in ContextManager, few debug messages ( I want to know exactly who needs tomcat home,
and
  minimize the need for it - for embeding tomcat ), plus set the CM in interceptors ( it
  works fine if server.xml is used, but have problems if "programatic" startup is used )
  
  - ServerSocketFactory - add a setAttribute() method, a simple way to pass info from
  Connector ( like keystore ). The preffered method is still "bean-like" setters, but sometimes
  it's good to have a backup.
  
  Revision  Changes    Path
  1.21      +23 -8     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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- WebXmlReader.java	2000/05/19 23:27:07	1.20
  +++ WebXmlReader.java	2000/06/03 06:35:20	1.21
  @@ -19,12 +19,19 @@
    * @author costin@dnt.ro
    */
   public class WebXmlReader extends BaseInterceptor {
  +    public static final String defaultWelcomeList[]={"index.jsp", "index.html", "index.htm"};
  +    public static final int DEFAULT_SESSION_TIMEOUT=30;
   
       private static StringManager sm =StringManager.getManager("org.apache.tomcat.core");
  +    boolean validate=true;
   
       public WebXmlReader() {
       }
   
  +    public void setValidate( boolean b ) {
  +	validate=b;
  +    }
  +
       public void contextInit(Context ctx) throws TomcatException {
   	if( ctx.getDebug() > 0 ) ctx.log("XmlReader - init  " + ctx.getPath() + " " + ctx.getDocBase()
);
   
  @@ -53,9 +60,11 @@
   	    if( ! default_xml.exists() )
   		throw new TomcatException("Can't find default web.xml configuration");
   
  -	    String dtdURL = "file:" + default_dtd.toString();
  +	    if( validate && ! default_dtd.exists() )
  +		throw new TomcatException("Can't find default web.dtd configuration");
   
  -	    processFile(ctx, default_xml.toString(), dtdURL);
  +
  +	    processFile(ctx, default_xml.toString(), default_dtd.toString() );
   	    ctx.expectUserWelcomeFiles();
   
   	    File inf_xml = new File(ctx.getDocBase() + "/WEB-INF/web.xml");
  @@ -63,7 +72,7 @@
   	    if (!inf_xml.isAbsolute())
   		inf_xml = new File(home, inf_xml.toString());
   
  -	    processFile(ctx, inf_xml.toString(), dtdURL);
  +	    processFile(ctx, inf_xml.toString(), default_dtd.toString() );
   	    XmlMapper xh=new XmlMapper();
   	} catch (Exception e) {
   	    String msg = sm.getString("context.getConfig.e",ctx.getPath() + " " + ctx.getDocBase());
  @@ -72,8 +81,10 @@
   
       }
   
  -    void processFile( Context ctx, String file, String dtdURL) {
  +    void processFile( Context ctx, String file, String default_dtd) {
   	try {
  +	    String dtdURL = "file:" + default_dtd.toString();
  +	    
   	    File f=new File(FileUtil.patch(file));
   	    if( ! f.exists() ) {
   		ctx.log( "File not found " + f + ", using only defaults" );
  @@ -81,11 +92,14 @@
   	    }
   	    if( ctx.getDebug() > 0 ) ctx.log("Reading " + file );
   	    XmlMapper xh=new XmlMapper();
  -	    xh.setValidating(true);
  -	    xh.register("-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN",
  -			dtdURL);
  -	    //	    if( ctx.getDebug() > 5 ) xh.setDebug( 3 );
  +	    if( validate ) {
  +		xh.setValidating(true);
  +		//	    if( ctx.getDebug() > 5 ) xh.setDebug( 3 );
  +	    }
   
  +	    // By using dtdURL you brake most parsers ( at least xerces )
  +	    xh.register("-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN",
  +			dtdURL );
   	    xh.addRule("web-app/context-param", xh.methodSetter("addInitParameter", 2) );
   	    xh.addRule("web-app/context-param/param-name", xh.methodParam(0) );
   	    xh.addRule("web-app/context-param/param-value", xh.methodParam(1) );
  @@ -332,3 +346,4 @@
   
   
   }
  +
  
  
  
  1.85      +21 -1     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.84
  retrieving revision 1.85
  diff -u -r1.84 -r1.85
  --- ContextManager.java	2000/05/31 20:58:37	1.84
  +++ ContextManager.java	2000/06/03 06:35:21	1.85
  @@ -196,6 +196,15 @@
        *  just throw error instead of guessing wrong.
        */
       public String getHome() {
  +	if( debug > 20 ) {
  +	    // we want to know all places that need this property
  +	    // and find how it's computed - for embeding tc.
  +	    log( "getHome " + home + " " + installDir + " " +
  +		 System.getProperty("tomcat.home") + " " +
  +		 FileUtil.getCanonicalPath( "." ));
  +	    /*DEBUG*/ try {throw new Exception(); } catch(Exception ex) {ex.printStackTrace();}
  +	}
  +	
   	if(home!=null) return home;
   
   	// If none defined, assume tomcat.home is used as base.
  @@ -217,6 +226,14 @@
        *  evaluate it relative to the current working directory.
        */
       public String getInstallDir() {
  +	if( debug > 20 ) {
  +	    // we want to know all places that need this property
  +	    // and find how it's computed - for embeding tc.
  +	    log( "getInstallDir " + installDir + " " +
  +		 System.getProperty("tomcat.home"));
  +	    /*DEBUG*/ try {throw new Exception(); } catch(Exception ex) {ex.printStackTrace();}
  +	}
  +
   	if(installDir!= null) return installDir;
   	
   	installDir=System.getProperty("tomcat.home");
  @@ -515,6 +532,8 @@
       
       public void addRequestInterceptor( RequestInterceptor ri ) {
   	if(debug>0) log("Add requestInterceptor javaClass=\"" + ri.getClass().getName() + "\"
");
  +	// XXX for programatic access, it'll go away after the interceptor is fixed.
  +	if( ri instanceof BaseInterceptor ) ((BaseInterceptor)ri).setContextManager( this );
   	requestInterceptors.addElement( ri );
   	if( ri instanceof ContextInterceptor )
   	    contextInterceptors.addElement( ri );
  @@ -541,6 +560,7 @@
   
       public void addContextInterceptor( ContextInterceptor ci) {
   	if(debug>0) log("Add contextInterceptor javaClass=\"" + ci.getClass().getName() + "\"
");
  +	if( ci instanceof BaseInterceptor ) ((BaseInterceptor)ci).setContextManager( this );
   	contextInterceptors.addElement( ci );
       }
   
  @@ -1007,7 +1027,7 @@
       }
       
       public final void log(String msg) {
  -	doLog( msg );
  +	doLog( "CM: " + msg );
       }
   
       public final void doLog(String msg) {
  
  
  
  1.3       +18 -5     jakarta-tomcat/src/share/org/apache/tomcat/net/ServerSocketFactory.java
  
  Index: ServerSocketFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/net/ServerSocketFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServerSocketFactory.java	1999/10/15 03:20:29	1.2
  +++ ServerSocketFactory.java	2000/06/03 06:35:22	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/net/ServerSocketFactory.java,v
1.2 1999/10/15 03:20:29 harishp Exp $
  - * $Revision: 1.2 $
  - * $Date: 1999/10/15 03:20:29 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/net/ServerSocketFactory.java,v
1.3 2000/06/03 06:35:22 costin Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/06/03 06:35:22 $
    *
    * ====================================================================
    *
  @@ -66,6 +66,7 @@
   
   import java.io.*;
   import java.net.*;
  +import java.util.Hashtable;
   
   /**
    * This class creates server sockets.  It may be subclassed by other
  @@ -105,6 +106,7 @@
       //
   
       private static ServerSocketFactory theFactory;
  +    protected Hashtable attributes=new Hashtable();
   
       /**
        * Constructor is used only by subclasses.
  @@ -114,10 +116,22 @@
           /* NOTHING */
       }
   
  +    /** General mechanism to pass attributes from the
  +     *  ServerConnector to the socket factory.
  +     *
  +     *  Note that the "prefered" mechanism is to
  +     *  use bean setters and explicit methods, but
  +     *  this allows easy configuration via server.xml
  +     *  or simple Properties
  +     */
  +    public void setAttribute( String name, Object value ) {
  +	if( name!=null && value !=null)
  +	    attributes.put( name, value );
  +    }
  +    
       /**
        * Returns a copy of the environment's default socket factory.
        */
  -
       public static ServerSocketFactory getDefault () {
           //
           // optimize typical case:  no synch needed
  @@ -153,7 +167,6 @@
        * @exception IOException for networking errors
        * @exception InstantiationException for construction errors
        */
  -
       public abstract ServerSocket createSocket (int port)
       throws IOException, InstantiationException;
   
  
  
  
  1.4       +7 -0      jakarta-tomcat/src/share/org/apache/tomcat/request/Jdk12Interceptor.java
  
  Index: Jdk12Interceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/request/Jdk12Interceptor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Jdk12Interceptor.java	2000/05/26 17:32:12	1.3
  +++ Jdk12Interceptor.java	2000/06/03 06:35:22	1.4
  @@ -127,6 +127,13 @@
       // XXX move it to interceptor !!!
       final private void fixJDKContextClassLoader( ClassLoader cl ) {
   	if( cl==null ) return;
  +
  +// 	java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
  +// 	    public Object run()  {
  +// 		Thread.currentThread().setContextClassLoader(cl);
  +// 		return null;
  +// 	    }
  +// 	});
   	Thread t=Thread.currentThread();
   	t.setContextClassLoader( cl );
       }
  
  
  
  1.6       +124 -54   jakarta-tomcat/src/share/org/apache/tomcat/service/PoolTcpConnector.java
  
  Index: PoolTcpConnector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/PoolTcpConnector.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PoolTcpConnector.java	2000/05/31 20:58:37	1.5
  +++ PoolTcpConnector.java	2000/06/03 06:35:23	1.6
  @@ -85,14 +85,11 @@
    * @author costin@eng.sun.com
    * @author Gal Shachor [shachor@il.ibm.com]
    */
  -public class PoolTcpConnector implements ServerConnector {
  +public final class PoolTcpConnector implements ServerConnector {
       // Attributes we accept ( to support the old model of
       // configuration, will be deprecated )
       public static final String VHOST_PORT="vhost_port";
       public static final String VHOST_NAME="vhost_name";
  -
  -    // needed only as a "hack" to HttpServerConnector
  -    public static final String SERVER="server";
       public static final String VHOST_ADDRESS="vhost_address";
       public static final String SOCKET_FACTORY="socketFactory";
   
  @@ -120,6 +117,7 @@
       Hashtable attributes = new Hashtable();
       Object cm;
   
  +    private String vhost;
       private InetAddress address;
       private int port;
   
  @@ -133,11 +131,14 @@
       private ServerSocket serverSocket;
   
       boolean running = true;
  -
  +    int debug=0;
  +    
       public PoolTcpConnector() {
       	ep = new PoolTcpEndpoint();
       }
   
  +    // -------------------- Start/stop --------------------
  +    
       public void start() throws Exception {
       	if(con==null)
       	    throw new Exception( "Invalid ConnectionHandler");
  @@ -171,6 +172,13 @@
   
   	if(socketFactory != null) {
   	    ep.setServerSocketFactory( socketFactory );
  +	    // Pass properties to the socket factory
  +	    attE=attributes.keys();
  +	    while( attE.hasMoreElements() ) {
  +		String key=(String)attE.nextElement();
  +		Object v=attributes.get( key );
  +		socketFactory.setAttribute( key, v );
  +	    }
   	}
   	ep.setConnectionHandler( con );
   	ep.startEndpoint();
  @@ -183,11 +191,8 @@
       public void stop() throws Exception {
       	ep.stopEndpoint();
       }
  -
  -    public void setServer( Object ctx ) {
  -	    this.cm=ctx;
  -    }
   
  +    // -------------------- Tcp-server specific methods --------------------
       public void setTcpConnectionHandler( TcpConnectionHandler handler) {
       	this.con=handler;
       }
  @@ -196,6 +201,15 @@
   	    return con;
       }
   
  +    // -------------------- Bean-setters for TcpConnector --------------------
  +    public void setServer( Object ctx ) {
  +	    this.cm=ctx;
  +    }
  +
  +    public void setDebug( int i ) {
  +	debug=i;
  +    }
  +    
       public void setPort( int port ) {
       	this.port=port;
       }
  @@ -208,63 +222,119 @@
       	return port;
       }
   
  +    /** Generic configure system - this allows Connector
  +     * 	configuration using name/value.
  +     *
  +     *  The "prefered" configuration is to call setters,
  +     * 	and tomcat using server.xml will do that, but
  +     *	this allows (minimal) integration with simpler
  +     *	systems.
  +     *
  +     *  Only a minimal number of properties can be set
  +     *  this way. This mechanism may be deprecated
  +     *  after we improve the startup system.
  +     *
  +     *  Supported attributes:
  +     *  "vhost_port" - port ( will act as a virtual host )
  +     *  "vhost_name" - virtual host name 
  +     *  "vhost_address" - virtual host binding address
  +     *  "socketFactory" - socket factory - for ssl.
  +     *  XXX add the others
  +     * 
  +     *  Note that the attributes are passed to the Endpoint.
  +     */
  +    public void setAttribute( String prop, Object value) {
  +	if( debug > 0 ) log( "setAttribute( " + prop + " , " + value + ")");
  +
  +	if( value instanceof String ) {
  +	    String valueS=(String)value;
  +	    
  +	    if( PORT.equals(prop) ) {
  +		setPort( valueS );
  +	    } else if(HANDLER.equals(prop)) {
  +		con=string2ConnectionHandler( valueS );
  +	    } else if(THREAD_POOL.equals(prop)) {
  +		usePools = ! valueS.equalsIgnoreCase("off");
  +	    } else if(INET.equals(prop)) {
  +		address=string2Inet( prop );
  +	    } else if( MAX_THREADS.equals(prop)) {
  +		maxThreads = string2Int(valueS);
  +	    } else if( MAX_SPARE_THREADS.equals(prop)) {
  +		maxSpareThreads = string2Int(valueS);
  +	    } else if( MIN_SPARE_THREADS.equals(prop)) {
  +		minSpareThreads = string2Int(valueS);
  +	    } else if(VHOST_NAME.equals(prop) ) {
  +		vhost=valueS;
  +	    } else if( BACKLOG.equals(prop)) {
  +		backlog = string2Int(valueS);
  +	    } else if(VHOST_PORT.equals(prop) ) {
  +		port= string2Int( valueS );
  +	    } else if(SOCKET_FACTORY.equals(prop)) {
  +		socketFactory= string2SocketFactory( valueS );
  +	    } else if(VHOST_ADDRESS.equals(prop)) {
  +		address= string2Inet(valueS);
  +	    } else {
  +		if( valueS!=null)
  +		    attributes.put( prop, valueS );
  +	    }
  +	} else {
  +	    // Objects - avoids String-based "serialization" 
  +	    if(VHOST_PORT.equals(prop) ) {
  +		port=((Integer)value).intValue();
  +	    } else if(VHOST_ADDRESS.equals(prop)) {
  +		address=(InetAddress)value;
  +	    } else if(SOCKET_FACTORY.equals(prop)) {
  +		socketFactory=(ServerSocketFactory)value;
  +	    } else {
  +		if( value!=null)
  +		    attributes.put( prop, value );
  +	    }
  +	}
  +    }
  +
       public void setProperty( String prop, String value) {
  -    	if(PORT.equals(prop) ) {
  -    	    setPort( value );
  -    	} else if(HANDLER.equals(prop)) {
  -    	    try {
  -        		Class chC=Class.forName( value );
  -    	    	con=(TcpConnectionHandler)chC.newInstance();
  -    	    } catch( Exception ex) {
  -        		ex.printStackTrace();
  -    	    }
  -    	} else if(THREAD_POOL.equals(prop)) {
  -    	    if(value.equalsIgnoreCase("off")) {
  -    	        usePools = false;
  -    	    }
  -    	} else if(INET.equals(prop)) {
  -    	    try {
  -		address=InetAddress.getByName( value );
  -    	    } catch( Exception ex) {
  -    	    }
  -    	} else if(MAX_THREADS.equals(prop)) {
  -    	    maxThreads = string2Int(value);
  -    	} else if(MAX_SPARE_THREADS.equals(prop)) {
  -    	    maxSpareThreads = string2Int(value);
  -    	} else if(MIN_SPARE_THREADS.equals(prop)) {
  -    	    minSpareThreads = string2Int(value);
  -    	} else if(BACKLOG.equals(prop)) {
  -    	    backlog = string2Int(value);
  -    	}
  +	setAttribute( prop, value );
       }
   
  -    // XXX use constants, remove dep on HttpServer
  -    public void setAttribute( String prop, Object value) {
  -    	if(VHOST_NAME.equals(prop) ) {
  -	    //vhost=(String)value;
  -	} else if(VHOST_PORT.equals(prop) ) {
  -	    System.out.println("Setting port to " + port );
  -	    port=((Integer)value).intValue();
  -	} else if(VHOST_ADDRESS.equals(prop)) {
  -	    address=(InetAddress)value;
  -	} else if(SERVER.equals(prop)) {
  -    	    //server=(HttpServer)value;
  -	} else if(SOCKET_FACTORY.equals(prop)) {
  -    	    socketFactory=(ServerSocketFactory)value;
  -	} else {
  -	    attributes.put( prop, value );
  +    // -------------------- Implementation methods --------------------
  +
  +    private static TcpConnectionHandler string2ConnectionHandler( String val) {
  +	try {
  +	    Class chC=Class.forName( val );
  +	    return (TcpConnectionHandler)chC.newInstance();
  +	} catch( Exception ex) {
  +	    ex.printStackTrace();
   	}
  +	return null;
       }
   
  -    public Object getAttribute( String prop ) {
  -	    return null;
  +    private static ServerSocketFactory string2SocketFactory( String val) {
  +	try {
  +	    Class chC=Class.forName( val );
  +	    return (ServerSocketFactory)chC.newInstance();
  +	} catch( Exception ex) {
  +	    ex.printStackTrace();
  +	}
  +	return null;
       }
   
  -    private int string2Int( String val) {
  +    private static InetAddress string2Inet( String val) {
  +	try {
  +	    return InetAddress.getByName( val );
  +	} catch( Exception ex) {
  +	}
  +	return null;
  +    }
  +    
  +    private static int string2Int( String val) {
       	try {
   	        return Integer.parseInt(val);
       	} catch (NumberFormatException nfe) {
   	        return 0;
       	}
  +    }
  +
  +    void log( String s ) {
  +	System.out.println("PoolTcpConnector: " + s );
       }
   }
  
  
  
  1.4       +95 -4     jakarta-tomcat/src/share/org/apache/tomcat/util/MimeMap.java
  
  Index: MimeMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/MimeMap.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MimeMap.java	2000/04/25 17:54:33	1.3
  +++ MimeMap.java	2000/06/03 06:35:23	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/MimeMap.java,v 1.3
2000/04/25 17:54:33 costin Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/04/25 17:54:33 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/MimeMap.java,v 1.4
2000/06/03 06:35:23 costin Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/06/03 06:35:23 $
    *
    * ====================================================================
    *
  @@ -74,9 +74,99 @@
    * @author James Duncan Davidson [duncan@eng.sun.com]
    * @author Jason Hunter [jch@eng.sun.com]
    */
  -
   public class MimeMap implements FileNameMap {
   
  +    // Defaults - all of them are "well-known" types,
  +    // you can add using normal web.xml.
  +    
  +    public static Hashtable mimeMappings=new Hashtable();
  +    static {
  +        mimeMappings.put("txt", "text/plain");
  +        mimeMappings.put("html","text/html");
  +        mimeMappings.put("htm", "text/html");
  +        mimeMappings.put("gif", "image/gif");
  +        mimeMappings.put("jpg", "image/jpeg");
  +        mimeMappings.put("jpe", "image/jpeg");
  +        mimeMappings.put("jpeg", "image/jpeg");
  +	mimeMappings.put("java", "text/plain");
  +        mimeMappings.put("body", "text/html");
  +        mimeMappings.put("rtx", "text/richtext");
  +        mimeMappings.put("tsv", "text/tab-separated-values");
  +        mimeMappings.put("etx", "text/x-setext");
  +        mimeMappings.put("ps", "application/x-postscript");
  +        mimeMappings.put("class", "application/java");
  +        mimeMappings.put("csh", "application/x-csh");
  +        mimeMappings.put("sh", "application/x-sh");
  +        mimeMappings.put("tcl", "application/x-tcl");
  +        mimeMappings.put("tex", "application/x-tex");
  +        mimeMappings.put("texinfo", "application/x-texinfo");
  +        mimeMappings.put("texi", "application/x-texinfo");
  +        mimeMappings.put("t", "application/x-troff");
  +        mimeMappings.put("tr", "application/x-troff");
  +        mimeMappings.put("roff", "application/x-troff");
  +        mimeMappings.put("man", "application/x-troff-man");
  +        mimeMappings.put("me", "application/x-troff-me");
  +        mimeMappings.put("ms", "application/x-wais-source");
  +        mimeMappings.put("src", "application/x-wais-source");
  +        mimeMappings.put("zip", "application/zip");
  +        mimeMappings.put("bcpio", "application/x-bcpio");
  +        mimeMappings.put("cpio", "application/x-cpio");
  +        mimeMappings.put("gtar", "application/x-gtar");
  +        mimeMappings.put("shar", "application/x-shar");
  +        mimeMappings.put("sv4cpio", "application/x-sv4cpio");
  +        mimeMappings.put("sv4crc", "application/x-sv4crc");
  +        mimeMappings.put("tar", "application/x-tar");
  +        mimeMappings.put("ustar", "application/x-ustar");
  +        mimeMappings.put("dvi", "application/x-dvi");
  +        mimeMappings.put("hdf", "application/x-hdf");
  +        mimeMappings.put("latex", "application/x-latex");
  +        mimeMappings.put("bin", "application/octet-stream");
  +        mimeMappings.put("oda", "application/oda");
  +        mimeMappings.put("pdf", "application/pdf");
  +        mimeMappings.put("ps", "application/postscript");
  +        mimeMappings.put("eps", "application/postscript");
  +        mimeMappings.put("ai", "application/postscript");
  +        mimeMappings.put("rtf", "application/rtf");
  +        mimeMappings.put("nc", "application/x-netcdf");
  +        mimeMappings.put("cdf", "application/x-netcdf");
  +        mimeMappings.put("cer", "application/x-x509-ca-cert");
  +        mimeMappings.put("exe", "application/octet-stream");
  +        mimeMappings.put("gz", "application/x-gzip");
  +        mimeMappings.put("Z", "application/x-compress");
  +        mimeMappings.put("z", "application/x-compress");
  +        mimeMappings.put("hqx", "application/mac-binhex40");
  +        mimeMappings.put("mif", "application/x-mif");
  +        mimeMappings.put("ief", "image/ief");
  +        mimeMappings.put("tiff", "image/tiff");
  +        mimeMappings.put("tif", "image/tiff");
  +        mimeMappings.put("ras", "image/x-cmu-raster");
  +        mimeMappings.put("pnm", "image/x-portable-anymap");
  +        mimeMappings.put("pbm", "image/x-portable-bitmap");
  +        mimeMappings.put("pgm", "image/x-portable-graymap");
  +        mimeMappings.put("ppm", "image/x-portable-pixmap");
  +        mimeMappings.put("rgb", "image/x-rgb");
  +        mimeMappings.put("xbm", "image/x-xbitmap");
  +        mimeMappings.put("xpm", "image/x-xpixmap");
  +        mimeMappings.put("xwd", "image/x-xwindowdump");
  +        mimeMappings.put("au", "audio/basic");
  +        mimeMappings.put("snd", "audio/basic");
  +        mimeMappings.put("aif", "audio/x-aiff");
  +        mimeMappings.put("aiff", "audio/x-aiff");
  +        mimeMappings.put("aifc", "audio/x-aiff");
  +        mimeMappings.put("wav", "audio/x-wav");
  +        mimeMappings.put("mpeg", "video/mpeg");
  +        mimeMappings.put("mpg", "video/mpeg");
  +        mimeMappings.put("mpe", "video/mpeg");
  +        mimeMappings.put("qt", "video/quicktime");
  +        mimeMappings.put("mov", "video/quicktime");
  +        mimeMappings.put("avi", "video/x-msvideo");
  +        mimeMappings.put("movie", "video/x-sgi-movie");
  +        mimeMappings.put("avx", "video/x-rad-screenplay");
  +        mimeMappings.put("wrl", "x-world/x-vrml");
  +        mimeMappings.put("mpv2", "video/mpeg2");
  +    }
  +    
  +
       private Hashtable map = new Hashtable();
   
       public void addContentType(String extn, String type) {
  @@ -127,4 +217,5 @@
               return null;
           }
       }
  +
   }
  
  
  
  1.21      +29 -15    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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- XmlMapper.java	2000/05/23 16:57:12	1.20
  +++ XmlMapper.java	2000/06/03 06:35:24	1.21
  @@ -11,14 +11,8 @@
   import java.util.StringTokenizer;
   import javax.xml.parsers.SAXParser;
   import javax.xml.parsers.SAXParserFactory;
  -import org.xml.sax.AttributeList;
  -import org.xml.sax.DocumentHandler;
  -import org.xml.sax.DTDHandler;
  -import org.xml.sax.EntityResolver;
  -import org.xml.sax.HandlerBase;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.Locator;
  -import org.xml.sax.SAXException;
  +import org.xml.sax.*;
  +import org.xml.sax.helpers.*;
   
   
   /**
  @@ -212,15 +206,31 @@
   	}
   	SAXParser parser=null;
   	try {
  -	    SAXParserFactory factory = SAXParserFactory.newInstance();
  -	    factory.setNamespaceAware(false);
  -	    factory.setValidating(validating);
  -	    parser = factory.newSAXParser();
  -	    parser.parse(xmlFile, this);
  +	    try {
  +		SAXParserFactory factory = SAXParserFactory.newInstance();
  +		factory.setNamespaceAware(false);
  +		factory.setValidating(validating);
  +		parser = factory.newSAXParser();
  +		parser.parse(xmlFile, this);
  +	    } catch (javax.xml.parsers.FactoryConfigurationError jaxpE ) {
  +		org.xml.sax.Parser saxparser=null;
  +		if(System.getProperty("org.xml.sax.parser") != null )
  +		    saxparser=ParserFactory.makeParser();
  +		else
  +		    saxparser=ParserFactory.makeParser("org.apache.crimson.parser.Parser");
  +
  +		saxparser.setDocumentHandler( this );
  +		saxparser.setEntityResolver( this );
  +		saxparser.setDTDHandler( this );
  +		if( debug > 0 ) log("No jaxp, defaulting to old xml style " + xmlFile);
  +		saxparser.parse(new InputSource( new FileReader( xmlFile)));
  +	    }
  +
   	    return root;
   	    // assume the stack is in the right position.
   	    // or throw an exception is more than one element is on the stack
      	} catch (IOException ioe) {
  +	    ioe.printStackTrace();
   	    String msg = "Can't open config file: " + xmlFile +
   		" due to: " + ioe;
   	    throw new Exception(msg);
  @@ -230,7 +240,10 @@
   	    //	    se.printStackTrace();
   	    System.out.println();
   	    Exception ex1=se.getException();
  -	    throw ex1;
  +	    if( ex1 != null )
  +		throw ex1;// xerces bug
  +	    else
  +		throw se;
   	}
       }
   
  @@ -394,8 +407,9 @@
        */
       public InputSource resolveEntity(String publicId, String systemId)
   	throws SAXException {
  -
   	String dtdURL = (String) dtds.get(publicId);
  +	//	System.out.println("Entity: " + publicId + " --> " + systemId + " \"" + dtdURL +"\"");
  +
   	if (dtdURL == null) {
   	    //	    log("Entity: " + publicId + " --> " + systemId);
   	    return (null);
  
  
  

Mime
View raw message