Class HttpLookupMethod
- java.lang.Object
-
- org.jivesoftware.smack.altconnections.HttpLookupMethod
-
public final class HttpLookupMethod extends java.lang.Object
The HTTP lookup method uses web host metadata to list the URIs of alternative connection methods.In order to obtain host-meta XRD element from the host in the form of an InputStream, use
Example:getXrdStream(DomainBareJid)
method. To obtain endpoints for Bosh or Websocket connection endpoints from host, useHttpLookupMethod.LinkRelation.BOSH
andHttpLookupMethod.LinkRelation.WEBSOCKET
respectively with thelookup(DomainBareJid, LinkRelation)
method. In case one is looking for endpoints described by other than BOSH or Websocket LinkRelation, use the more flexiblelookup(DomainBareJid, String)
method.
DomainBareJid xmppServerAddress = JidCreate.domainBareFrom("example.org"); List<URI> endpoints = HttpLookupMethod.lookup(xmppServiceAddress, LinkRelation.WEBSOCKET);
- See Also:
- HTTP Lookup Method from XEP-0156.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HttpLookupMethod.LinkRelation
Specifies a link relation for the selected type of connection.
-
Constructor Summary
Constructors Constructor Description HttpLookupMethod()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.io.InputStream
getXrdStream(DomainBareJid xmppServiceAddress)
Constructs a HTTP connection with the host specified by the DomainBareJid and retrieves XRD element in the form of an InputStream.static java.util.List<java.net.URI>
lookup(DomainBareJid xmppServiceAddress, java.lang.String relation)
Get remote endpoints for the given LinkRelation from host.static java.util.List<java.net.URI>
lookup(DomainBareJid xmppServiceAddress, HttpLookupMethod.LinkRelation relation)
Get remote endpoints for the given LinkRelation from host.static java.util.List<java.net.URI>
parseXrdLinkReferencesFor(XmlPullParser parser, java.lang.String relation)
Get remote endpoints for the provided LinkRelation from provided XmlPullParser.static java.util.List<java.net.URI>
parseXrdLinkReferencesFor(XmlPullParser parser, HttpLookupMethod.LinkRelation relation)
Get remote endpoints for the provided LinkRelation from provided XmlPullParser.
-
-
-
Constructor Detail
-
HttpLookupMethod
public HttpLookupMethod()
-
-
Method Detail
-
lookup
public static java.util.List<java.net.URI> lookup(DomainBareJid xmppServiceAddress, java.lang.String relation) throws java.io.IOException, XmlPullParserException, java.net.URISyntaxException
Get remote endpoints for the given LinkRelation from host.- Parameters:
xmppServiceAddress
- address of hostrelation
- LinkRelation as a string specifying type of connection- Returns:
- list of endpoints
- Throws:
java.io.IOException
- exception due to input/output operationsXmlPullParserException
- exception encountered during XML parsingjava.net.URISyntaxException
- exception to indicate that a string could not be parsed as a URI reference
-
lookup
public static java.util.List<java.net.URI> lookup(DomainBareJid xmppServiceAddress, HttpLookupMethod.LinkRelation relation) throws java.io.IOException, XmlPullParserException, java.net.URISyntaxException
Get remote endpoints for the given LinkRelation from host.- Parameters:
xmppServiceAddress
- address of hostrelation
-HttpLookupMethod.LinkRelation
specifying type of connection- Returns:
- list of endpoints
- Throws:
java.io.IOException
- exception due to input/output operationsXmlPullParserException
- exception encountered during XML parsingjava.net.URISyntaxException
- exception to indicate that a string could not be parsed as a URI reference
-
getXrdStream
public static java.io.InputStream getXrdStream(DomainBareJid xmppServiceAddress) throws java.io.IOException
Constructs a HTTP connection with the host specified by the DomainBareJid and retrieves XRD element in the form of an InputStream. The method will throw aFileNotFoundException
if host-meta isn't published.- Parameters:
xmppServiceAddress
- address of host- Returns:
- InputStream containing XRD element
- Throws:
java.io.IOException
- exception due to input/output operations
-
parseXrdLinkReferencesFor
public static java.util.List<java.net.URI> parseXrdLinkReferencesFor(XmlPullParser parser, java.lang.String relation) throws java.io.IOException, XmlPullParserException, java.net.URISyntaxException
Get remote endpoints for the provided LinkRelation from provided XmlPullParser.- Parameters:
parser
- XmlPullParser that contains LinkRelationsrelation
- type of endpoints specified by the given LinkRelation- Returns:
- list of endpoints
- Throws:
java.io.IOException
- exception due to input/output operationsXmlPullParserException
- exception encountered during XML parsingjava.net.URISyntaxException
- exception to indicate that a string could not be parsed as a URI reference
-
parseXrdLinkReferencesFor
public static java.util.List<java.net.URI> parseXrdLinkReferencesFor(XmlPullParser parser, HttpLookupMethod.LinkRelation relation) throws java.io.IOException, XmlPullParserException, java.net.URISyntaxException
Get remote endpoints for the provided LinkRelation from provided XmlPullParser.- Parameters:
parser
- XmlPullParser that contains LinkRelationsrelation
- type of endpoints specified by the given LinkRelation- Returns:
- list of endpoints
- Throws:
java.io.IOException
- exception due to input/output operationsXmlPullParserException
- exception encountered during XML parsingjava.net.URISyntaxException
- exception to indicate that a string could not be parsed as a URI reference
-
-