com.sun.xml.ws.api
Class EndpointAddress

java.lang.Object
  extended by com.sun.xml.ws.api.EndpointAddress

public final class EndpointAddress
extends Object

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

  1. 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.
  2. 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.)


Constructor Summary
EndpointAddress(String url)
           
EndpointAddress(URI uri)
           
 
Method Summary
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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EndpointAddress

public EndpointAddress(URI uri)

EndpointAddress

public EndpointAddress(String url)
                throws URISyntaxException
Throws:
URISyntaxException
See Also:
create(String)
Method Detail

create

public static EndpointAddress create(String url)
Creates a new EndpointAddress with a reasonably generic error handling.


getURL

public URL getURL()
Returns an URL of this endpoint adress.

Returns:
null if this endpoint address doesn't have a registered URLStreamHandler.

getURI

public URI getURI()
Returns an URI of the endpoint address.

Returns:
always non-null.

openConnection

public URLConnection openConnection()
                             throws IOException
Tries to open URLConnection for this endpoint.

This is possible only when an endpoint address has the corresponding URLStreamHandler.

Throws:
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.

toString

public String toString()
Overrides:
toString in class Object