tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billbar...@apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/net StreamHandlerFactory.java
Date Fri, 28 Dec 2001 06:13:23 GMT
billbarker    01/12/27 22:13:22

  Modified:    src/share/org/apache/tomcat/util/net
                        StreamHandlerFactory.java
  Log:
  It is really great when you learn to read :)
  
  I had totally misunderstood the java.net.URL javadocs, so this wasn't working at all.  This
shouldn't effect any outstanding bugs (due to a weird combination of bugs in the previous
version, that prevented this class from doing much of anything).  However, it will now hopefully
work as advertised.
  
  TODO: make the loading of this configurable.
  
  Revision  Changes    Path
  1.7       +18 -18    jakarta-tomcat/src/share/org/apache/tomcat/util/net/StreamHandlerFactory.java
  
  Index: StreamHandlerFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/net/StreamHandlerFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StreamHandlerFactory.java	2001/12/27 07:10:11	1.6
  +++ StreamHandlerFactory.java	2001/12/28 06:13:22	1.7
  @@ -76,7 +76,7 @@
        */
       public static final String SYS_PROTOCOLS = "java.protocol.handler.pkgs";
       private String protocolString = null;
  -    private Hashtable protocols = new Hashtable();
  +    private Vector protocols = null;
       private Jdk11Compat jdk11Compat = Jdk11Compat.getJdkCompat();
   
       public StreamHandlerFactory() {
  @@ -96,21 +96,28 @@
       public  URLStreamHandler createURLStreamHandler(String protoS) {
   	if("jar".equalsIgnoreCase(protoS) || "file".equalsIgnoreCase(protoS) )
   	    return null;
  -	if(protocolString != System.getProperty(SYS_PROTOCOLS))
  -	    loadProtocols();
  +	// The following is broken in a sandbox. 
  +	// Maybe fix with privileged, but probably not. 
  +	// LoadOnStartups have done their thing before we're set.
  +	//if(protocolString != System.getProperty(SYS_PROTOCOLS))
  +	//    loadProtocols();
   	ClassLoader acl = jdk11Compat.getContextClassLoader();
   	if(acl == null)
   	    acl = getClass().getClassLoader();
   	Class phldrC = null;
  -	String phldrCN = (String)protocols.get(protoS);
  -	if(phldrCN != null) {
  -	    try {
  -		phldrC = acl.loadClass(phldrCN);
  -	    } catch(ClassNotFoundException cnfex){
  +	if(protocols != null) {
  +	    Enumeration e = protocols.elements();
  +	    while(e.hasMoreElements()) {
  +		String phldrPK = (String)e.nextElement();
  +		try {
  +		    phldrC = acl.loadClass(phldrPK+"."+protoS+".Handler");
  +		    break;
  +		} catch(ClassNotFoundException cnfex){
  +		}
   	    }
   	}
   	if(phldrC == null){
  -	    phldrCN = "sun.net.www.protocol." + protoS + ".Handler";
  +	    String phldrCN = "sun.net.www.protocol." + protoS + ".Handler";
   	    try {
   		phldrC = acl.loadClass(phldrCN);
   	    } catch(ClassNotFoundException cnfex) {
  @@ -135,19 +142,12 @@
   	if(protocolString == System.getProperty(SYS_PROTOCOLS))	
   	    return;
   	String protocolS = System.getProperty(SYS_PROTOCOLS);
  -	protocols.clear();
   	if(protocolS != null) {
  +	    protocols = new Vector();
   	    StringTokenizer tok = new StringTokenizer(protocolS,"|");
   	    while(tok.hasMoreTokens()) {
   		String protStr = tok.nextToken();
  -		int hpos = protStr.lastIndexOf(".Handler");
  -		if(hpos >= 0) {
  -		    protStr = protStr.substring(0,hpos);
  -		    int npos = protStr.lastIndexOf('.');
  -		    String prot = protStr.substring(hpos+1);
  -		    String protC = protStr.substring(0,hpos);
  -		    protocols.put(prot,protC);
  -		}
  +		protocols.addElement(protStr);
   	    }
   	}
   	protocolString = protocolS;
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message