Class ExternalComponentManager

java.lang.Object
org.jivesoftware.whack.ExternalComponentManager
All Implemented Interfaces:
org.xmpp.component.ComponentManager

public class ExternalComponentManager extends Object implements org.xmpp.component.ComponentManager
Implementation of the ComponentManager interface for external components. This implementation follows JEP-0014.
Author:
Matt Tucker
  • Constructor Details

    • ExternalComponentManager

      public ExternalComponentManager(String host)
      Constructs a new ExternalComponentManager that will make connections to the specified XMPP server on the default external component port (5275).
      Parameters:
      host - the IP address or name of the XMPP server to connect to (e.g. "example.com").
    • ExternalComponentManager

      @Deprecated public ExternalComponentManager(String host, int port)
      Deprecated.
      Constructs a new ExternalComponentManager that will make connections to the specified XMPP server on the given port.
      Parameters:
      host - the IP address or name of the XMPP server to connect to (e.g. "example.com").
      port - the port to connect on.
    • ExternalComponentManager

      public ExternalComponentManager(String host, int port, boolean startEncrypted)
  • Method Details

    • setSecretKey

      public void setSecretKey(String subdomain, String secretKey)
      Sets a secret key for a sub-domain, for future use by a component connecting to the server. Keys are used as an authentication mechanism when connecting to the server. Some servers may require a different key for each component, while others may use a global secret key.
      Parameters:
      subdomain - the sub-domain.
      secretKey - the secret key
    • getSecretKey

      public String getSecretKey(String subdomain)
      Returns the secret key for a sub-domain. If no key was found then the default secret key will be returned.
      Parameters:
      subdomain - the subdomain to return its secret key.
      Returns:
      the secret key for a sub-domain.
    • setDefaultSecretKey

      public void setDefaultSecretKey(String secretKey)
      Sets the default secret key, which will be used when connecting if a specific secret key for the component hasn't been sent. Keys are used as an authentication mechanism when connecting to the server. Some servers may require a different key for each component, while others may use a global secret key.
      Parameters:
      secretKey - the default secret key.
    • isMultipleAllowed

      public boolean isMultipleAllowed(String subdomain)
      Returns if we want components to be able to connect multiple times to the same JID. This is a custom Openfire extension and will not work with any other XMPP server. Other XMPP servers should ignore this extra setting.
      Parameters:
      subdomain - the sub-domain.
      Returns:
      True or false if we are allowing multiple connections.
    • setMultipleAllowed

      public void setMultipleAllowed(String subdomain, boolean allowMultiple)
      Sets whether we will tell the XMPP server that we want multiple components to be able to connect to the same JID. This is a custom Openfire extension and will not work with any other XMPP server. Other XMPP servers should ignore this extra setting.
      Parameters:
      subdomain - the sub-domain.
      allowMultiple - Set to true if we want to allow multiple connections to same JID.
    • addComponent

      public void addComponent(String subdomain, org.xmpp.component.Component component) throws org.xmpp.component.ComponentException
      Specified by:
      addComponent in interface org.xmpp.component.ComponentManager
      Throws:
      org.xmpp.component.ComponentException
    • addComponent

      public void addComponent(String subdomain, org.xmpp.component.Component component, Integer port) throws org.xmpp.component.ComponentException
      Throws:
      org.xmpp.component.ComponentException
    • removeComponent

      public void removeComponent(String subdomain) throws org.xmpp.component.ComponentException
      Specified by:
      removeComponent in interface org.xmpp.component.ComponentManager
      Throws:
      org.xmpp.component.ComponentException
    • sendPacket

      public void sendPacket(org.xmpp.component.Component component, org.xmpp.packet.Packet packet)
      Specified by:
      sendPacket in interface org.xmpp.component.ComponentManager
    • query

      public org.xmpp.packet.IQ query(org.xmpp.component.Component component, org.xmpp.packet.IQ packet, long timeout) throws org.xmpp.component.ComponentException
      Specified by:
      query in interface org.xmpp.component.ComponentManager
      Throws:
      org.xmpp.component.ComponentException
    • query

      public void query(org.xmpp.component.Component component, org.xmpp.packet.IQ packet, org.xmpp.component.IQResultListener listener) throws org.xmpp.component.ComponentException
      Specified by:
      query in interface org.xmpp.component.ComponentManager
      Throws:
      org.xmpp.component.ComponentException
    • getProperty

      public String getProperty(String name)
      Specified by:
      getProperty in interface org.xmpp.component.ComponentManager
    • setProperty

      public void setProperty(String name, String value)
      Specified by:
      setProperty in interface org.xmpp.component.ComponentManager
    • setServerName

      public void setServerName(String domain)
      Sets the domain of the XMPP server. The domain may or may not match the host. The domain will be used mainly for the XMPP packets while the host is used mainly for creating connections to the server.
      Parameters:
      domain - the domain of the XMPP server.
    • getServerName

      public String getServerName()
      Returns the domain of the XMPP server where we are connected to or null if this value was never configured. When the value is null then the component will register with just its subdomain and we expect the server to accept the component and append its domain to form the JID of the component.
      Specified by:
      getServerName in interface org.xmpp.component.ComponentManager
      Returns:
      the domain of the XMPP server or null if never configured.
    • getConnectTimeout

      public int getConnectTimeout()
      Returns the timeout (in milliseconds) to use when trying to connect to the server. The default value is 2 seconds.
      Returns:
      the timeout to use when trying to connect to the server.
    • setConnectTimeout

      public void setConnectTimeout(int connectTimeout)
      Sets the timeout (in milliseconds) to use when trying to connect to the server. The default value is 2 seconds.
      Parameters:
      connectTimeout - the timeout, in milliseconds, to use when trying to connect to the server.
    • isExternalMode

      public boolean isExternalMode()
      Specified by:
      isExternalMode in interface org.xmpp.component.ComponentManager