119 |
*/ |
*/ |
120 |
public final class URL implements Serializable |
public final class URL implements Serializable |
121 |
{ |
{ |
122 |
|
private static final String DEFAULT_SEARCH_PATH = "gnu.java.net.protocol"; |
123 |
|
|
124 |
/** |
/** |
125 |
* The name of the protocol for this URL. |
* The name of the protocol for this URL. |
126 |
* The protocol is always stored in lower case. |
* The protocol is always stored in lower case. |
190 |
|
|
191 |
static |
static |
192 |
{ |
{ |
193 |
String s = System.getProperty("gnu.java.net.nocache_protocol_handlers"); |
String s = System.getProperty ("gnu.java.net.nocache_protocol_handlers"); |
194 |
|
|
195 |
if (s == null) |
if (s == null) |
196 |
cache_handlers = true; |
cache_handlers = true; |
197 |
else |
else |
198 |
cache_handlers = false; |
cache_handlers = false; |
199 |
|
|
200 |
ph_search_path = System.getProperty("java.protocol.handler.pkgs"); |
ph_search_path = System.getProperty ("java.protocol.handler.pkgs"); |
201 |
|
|
202 |
// Tack our default package on at the ends |
// Tack our default package on at the ends |
203 |
if (ph_search_path != null) |
if (ph_search_path != null) |
204 |
ph_search_path = ph_search_path + "|" + "gnu.java.net.protocol"; |
ph_search_path = ph_search_path + "|" + DEFAULT_SEARCH_PATH; |
205 |
else |
else |
206 |
ph_search_path = "gnu.java.net.protocol"; |
ph_search_path = DEFAULT_SEARCH_PATH; |
207 |
} |
} |
208 |
|
|
209 |
/** |
/** |
777 |
// First, see if a protocol handler is in our cache. |
// First, see if a protocol handler is in our cache. |
778 |
if (cache_handlers) |
if (cache_handlers) |
779 |
{ |
{ |
780 |
Class cls = (Class) ph_cache.get (protocol); |
if ((ph = (URLStreamHandler) ph_cache.get (protocol)) != null) |
781 |
|
return ph; |
|
if (cls != null) |
|
|
{ |
|
|
try |
|
|
{ |
|
|
return (URLStreamHandler) cls.newInstance(); |
|
|
} |
|
|
catch (Exception e) |
|
|
{ |
|
|
// Can't instantiate; handler still null. |
|
|
} |
|
|
} |
|
782 |
} |
} |
783 |
|
|
784 |
// If a non-default factory has been set, use it to find the protocol. |
// If a non-default factory has been set, use it to find the protocol. |
821 |
if (ph != null |
if (ph != null |
822 |
&& cache_handlers) |
&& cache_handlers) |
823 |
if (ph instanceof URLStreamHandler) |
if (ph instanceof URLStreamHandler) |
824 |
ph_cache.put (protocol, ph.getClass()); |
ph_cache.put (protocol, ph); |
825 |
else |
else |
826 |
ph = null; |
ph = null; |
827 |
|
|