| Represents the endpoint address URI.
Conceptually this can be really thought of as an
URI ,
but it hides some of the details that improve the performance.
Being an
URI allows this class to represent custom made-up URIs
(like "jms" for example.) Whenever possible, this object
also creates an
URL (this is only possible when the address
has a registered
URLStreamHandler ), so that if the clients
of this code wants to use it, it can do so.
How it improves the performance
-
Endpoint address is often eventually turned into an
URLConnection ,
and given that generally this value is read more often than being set,
it makes sense to eagerly turn it into an
URL ,
thereby avoiding a repeated conversion.
-
JDK spends a lot of time choosing a list of
Proxy to connect to an
URL . Since the default proxy selector
implementation always return the same proxy for the same URL,
we can determine the proxy by ourselves to let JDK skip its
proxy-discovery step.
(That said, user-defined proxy selector can do a lot of interesting things
--- like doing a round-robin, or pick one from a proxy farm randomly,
and so it's dangerous to stick to one proxy. For this case,
we still let JDK decide the proxy. This shouldn't be that much of an
disappointment, since most people only mess with system properties,
and never with
ProxySelector . Also, avoiding optimization
with non-standard proxy selector allows people to effectively disable
this optimization, which may come in handy for a trouble-shooting.)
author: Kohsuke Kawaguchi |