public final class EndpointAddress extends Object
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.
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.
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.)
Constructor and Description |
---|
EndpointAddress(String url) |
EndpointAddress(URI uri) |
Modifier and Type | Method and Description |
---|---|
static EndpointAddress |
create(String url)
Creates a new
EndpointAddress with a reasonably
generic error handling. |
URI |
getURI()
Returns an URI of the endpoint address.
|
URL |
getURL()
Returns an URL of this endpoint adress.
|
URLConnection |
openConnection()
Tries to open
URLConnection for this endpoint. |
String |
toString() |
public EndpointAddress(URI uri)
public EndpointAddress(String url) throws URISyntaxException
URISyntaxException
create(String)
public static EndpointAddress create(String url)
EndpointAddress
with a reasonably
generic error handling.public URL getURL()
URLStreamHandler
.public URI getURI()
public URLConnection openConnection() throws IOException
URLConnection
for this endpoint.
This is possible only when an endpoint address has
the corresponding URLStreamHandler
.
IOException
- if URL.openConnection()
reports an error.AssertionError
- if this endpoint doesn't have an associated URL.
if the code is written correctly this shall never happen.Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.