Class HttpLookupMethod

java.lang.Object
org.jivesoftware.smack.altconnections.HttpLookupMethod

public final class HttpLookupMethod extends 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 getXrdStream(DomainBareJid) method. To obtain endpoints for Bosh or Websocket connection endpoints from host, use HttpLookupMethod.LinkRelation.BOSH and HttpLookupMethod.LinkRelation.WEBSOCKET respectively with the lookup(DomainBareJid, LinkRelation) method. In case one is looking for endpoints described by other than BOSH or Websocket LinkRelation, use the more flexible lookup(DomainBareJid, String) method.

Example:
 
 DomainBareJid xmppServerAddress = JidCreate.domainBareFrom("example.org");
 List<URI> endpoints = HttpLookupMethod.lookup(xmppServiceAddress, LinkRelation.WEBSOCKET);
 
 
See Also:
  • Constructor Details

    • HttpLookupMethod

      public HttpLookupMethod()
  • Method Details

    • lookup

      public static List<URI> lookup(org.jxmpp.jid.DomainBareJid xmppServiceAddress, String relation) throws IOException, org.jivesoftware.smack.xml.XmlPullParserException, URISyntaxException
      Get remote endpoints for the given LinkRelation from host.
      Parameters:
      xmppServiceAddress - address of host
      relation - LinkRelation as a string specifying type of connection
      Returns:
      list of endpoints
      Throws:
      IOException - exception due to input/output operations
      org.jivesoftware.smack.xml.XmlPullParserException - exception encountered during XML parsing
      URISyntaxException - exception to indicate that a string could not be parsed as a URI reference
    • lookup

      public static List<URI> lookup(org.jxmpp.jid.DomainBareJid xmppServiceAddress, HttpLookupMethod.LinkRelation relation) throws IOException, org.jivesoftware.smack.xml.XmlPullParserException, URISyntaxException
      Get remote endpoints for the given LinkRelation from host.
      Parameters:
      xmppServiceAddress - address of host
      relation - HttpLookupMethod.LinkRelation specifying type of connection
      Returns:
      list of endpoints
      Throws:
      IOException - exception due to input/output operations
      org.jivesoftware.smack.xml.XmlPullParserException - exception encountered during XML parsing
      URISyntaxException - exception to indicate that a string could not be parsed as a URI reference
    • getXrdStream

      public static InputStream getXrdStream(org.jxmpp.jid.DomainBareJid xmppServiceAddress) throws 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 a FileNotFoundException if host-meta isn't published.
      Parameters:
      xmppServiceAddress - address of host
      Returns:
      InputStream containing XRD element
      Throws:
      IOException - exception due to input/output operations
    • parseXrdLinkReferencesFor

      public static List<URI> parseXrdLinkReferencesFor(org.jivesoftware.smack.xml.XmlPullParser parser, String relation) throws IOException, org.jivesoftware.smack.xml.XmlPullParserException, URISyntaxException
      Get remote endpoints for the provided LinkRelation from provided XmlPullParser.
      Parameters:
      parser - XmlPullParser that contains LinkRelations
      relation - type of endpoints specified by the given LinkRelation
      Returns:
      list of endpoints
      Throws:
      IOException - exception due to input/output operations
      org.jivesoftware.smack.xml.XmlPullParserException - exception encountered during XML parsing
      URISyntaxException - exception to indicate that a string could not be parsed as a URI reference
    • parseXrdLinkReferencesFor

      public static List<URI> parseXrdLinkReferencesFor(org.jivesoftware.smack.xml.XmlPullParser parser, HttpLookupMethod.LinkRelation relation) throws IOException, org.jivesoftware.smack.xml.XmlPullParserException, URISyntaxException
      Get remote endpoints for the provided LinkRelation from provided XmlPullParser.
      Parameters:
      parser - XmlPullParser that contains LinkRelations
      relation - type of endpoints specified by the given LinkRelation
      Returns:
      list of endpoints
      Throws:
      IOException - exception due to input/output operations
      org.jivesoftware.smack.xml.XmlPullParserException - exception encountered during XML parsing
      URISyntaxException - exception to indicate that a string could not be parsed as a URI reference