Class XMPPServer


  • public class XMPPServer
    extends Object
    The main XMPP server that will load, initialize and start all the server's modules. The server is unique in the JVM and could be obtained by using the getInstance() method.

    The loaded modules will be initialized and may access through the server other modules. This means that the only way for a module to locate another module is through the server. The server maintains a list of loaded modules.

    After starting up all the modules the server will load any available plugin. For more information see: PluginManager.

    A configuration file keeps the server configuration. This information is required for the server to work correctly. The server assumes that the configuration file is named openfire.xml and is located in the conf folder. The folder that keeps the configuration file must be located under the home folder. The server will try different methods to locate the home folder.

    1. system property - The server will use the value defined in the openfireHome system property.
    2. working folder - The server will check if there is a conf folder in the working directory. This is the case when running in standalone mode.
    3. openfire_init.xml file - Attempt to load the value from openfire_init.xml which must be in the classpath
    Author:
    Gaston Dombiak
    • Constructor Detail

      • XMPPServer

        public XMPPServer()
        Creates a server and starts it.
    • Method Detail

      • getInstance

        public static XMPPServer getInstance()
        Returns a singleton instance of XMPPServer.
        Returns:
        an instance.
      • getServerInfo

        public XMPPServerInfo getServerInfo()
        Returns a snapshot of the server's status.
        Returns:
        the server information current at the time of the method call.
      • isLocal

        public boolean isLocal​(org.xmpp.packet.JID jid)
        Returns true if the given address is local to the server (managed by this server domain). Return false even if the jid's domain matches a local component's service JID.
        Parameters:
        jid - the JID to check.
        Returns:
        true if the address is a local address to this server.
      • isRemote

        public boolean isRemote​(org.xmpp.packet.JID jid)
        Returns true if the domain-part of the given address does not match the local server hostname and does not match a component service JID
        Parameters:
        jid - the JID to check.
        Returns:
        true if the given address does not match the local server hostname and does not match a component service JID.
      • getNodeID

        public NodeID getNodeID()
        Returns an ID that uniquely identifies this server in a cluster. When not running in cluster mode the returned value is always the same. However, when in cluster mode the value should be set when joining the cluster and must be unique even upon restarts of this node.
        Returns:
        an ID that uniquely identifies this server in a cluster.
      • setNodeID

        public void setNodeID​(NodeID nodeID)
        Sets an ID that uniquely identifies this server in a cluster. When not running in cluster mode the returned value is always the same. However, when in cluster mode the value should be set when joining the cluster and must be unique even upon restarts of this node.
        Parameters:
        nodeID - an ID that uniquely identifies this server in a cluster or null if not in a cluster.
      • getDefaultNodeID

        public NodeID getDefaultNodeID()
        Returns the default node ID used by this server before clustering is initialized.
        Returns:
        The default node ID.
      • matchesComponent

        public boolean matchesComponent​(org.xmpp.packet.JID jid)
        Returns true if the domain-part of the given address matches a component service JID for a component that is connected to the local XMPP domain.
        Parameters:
        jid - the JID to check.
        Returns:
        true if the given address matches a component service JID.
      • createJID

        public org.xmpp.packet.JID createJID​(String username,
                                             String resource)
        Creates an XMPPAddress local to this server.
        Parameters:
        username - the user name portion of the id or null to indicate none is needed.
        resource - the resource portion of the id or null to indicate none is needed.
        Returns:
        an XMPPAddress for the server.
      • createJID

        public org.xmpp.packet.JID createJID​(String username,
                                             String resource,
                                             boolean skipStringprep)
        Creates an XMPPAddress local to this server. The construction of the new JID can be optimized by skipping stringprep operations.
        Parameters:
        username - the user name portion of the id or null to indicate none is needed.
        resource - the resource portion of the id or null to indicate none is needed.
        skipStringprep - true if stringprep should not be applied.
        Returns:
        an XMPPAddress for the server.
      • getAdmins

        public Collection<org.xmpp.packet.JID> getAdmins()
        Returns a collection with the JIDs of the server's admins. The collection may include JIDs of local users and users of remote servers.
        Returns:
        a collection with the JIDs of the server's admins.
      • addServerListener

        public void addServerListener​(XMPPServerListener listener)
        Adds a new server listener that will be notified when the server has been started or is about to be stopped.
        Parameters:
        listener - the new server listener to add.
      • removeServerListener

        public void removeServerListener​(XMPPServerListener listener)
        Removes a server listener that was being notified when the server was being started or was about to be stopped.
        Parameters:
        listener - the server listener to remove.
      • finishSetup

        public void finishSetup()
        Finish the setup process. Because this method is meant to be called from inside the Admin console plugin, it spawns its own thread to do the work so that the class loader is correct.
      • start

        public void start()
      • restart

        public void restart()
        Restarts the server and all it's modules only if the server is restartable. Otherwise do nothing.
      • restartHTTPServer

        public void restartHTTPServer()
        Restarts the HTTP server only when running in stand alone mode. The restart process will be done in another thread that will wait 1 second before doing the actual restart. The delay will give time to the page that requested the restart to fully render its content.
      • stop

        public void stop()
        Stops the server only if running in standalone mode. Do nothing if the server is running inside of another server.
      • isSetupMode

        public boolean isSetupMode()
      • isRestartable

        public boolean isRestartable()
      • isStandAlone

        public boolean isStandAlone()
        Returns if the server is running in standalone mode. We consider that it's running in standalone if the "org.jivesoftware.openfire.starter.ServerStarter" class is present in the system.
        Returns:
        true if the server is running in standalone mode.
      • isShuttingDown

        public boolean isShuttingDown()
        Returns true if the server is being shutdown.
        Returns:
        true if the server is being shutdown.
      • getConnectionManager

        public ConnectionManager getConnectionManager()
        Returns the ConnectionManager registered with this server. The ConnectionManager was registered with the server as a module while starting up the server.
        Returns:
        the ConnectionManager registered with this server.
      • getRoutingTable

        public RoutingTable getRoutingTable()
        Returns the RoutingTable registered with this server. The RoutingTable was registered with the server as a module while starting up the server.
        Returns:
        the RoutingTable registered with this server.
      • getPacketDeliverer

        public PacketDeliverer getPacketDeliverer()
        Returns the PacketDeliverer registered with this server. The PacketDeliverer was registered with the server as a module while starting up the server.
        Returns:
        the PacketDeliverer registered with this server.
      • getRosterManager

        public RosterManager getRosterManager()
        Returns the RosterManager registered with this server. The RosterManager was registered with the server as a module while starting up the server.
        Returns:
        the RosterManager registered with this server.
      • getPresenceManager

        public PresenceManager getPresenceManager()
        Returns the PresenceManager registered with this server. The PresenceManager was registered with the server as a module while starting up the server.
        Returns:
        the PresenceManager registered with this server.
      • getOfflineMessageStore

        public OfflineMessageStore getOfflineMessageStore()
        Returns the OfflineMessageStore registered with this server. The OfflineMessageStore was registered with the server as a module while starting up the server.
        Returns:
        the OfflineMessageStore registered with this server.
      • getOfflineMessageStrategy

        public OfflineMessageStrategy getOfflineMessageStrategy()
        Returns the OfflineMessageStrategy registered with this server. The OfflineMessageStrategy was registered with the server as a module while starting up the server.
        Returns:
        the OfflineMessageStrategy registered with this server.
      • getPacketRouter

        public PacketRouter getPacketRouter()
        Returns the PacketRouter registered with this server. The PacketRouter was registered with the server as a module while starting up the server.
        Returns:
        the PacketRouter registered with this server.
      • getIQRegisterHandler

        public IQRegisterHandler getIQRegisterHandler()
        Returns the IQRegisterHandler registered with this server. The IQRegisterHandler was registered with the server as a module while starting up the server.
        Returns:
        the IQRegisterHandler registered with this server.
      • getIQPEPHandler

        public IQPEPHandler getIQPEPHandler()
        Returns the IQPEPHandler registered with this server. The IQPEPHandler was registered with the server as a module while starting up the server.
        Returns:
        the IQPEPHandler registered with this server.
      • getPluginManager

        public PluginManager getPluginManager()
        Returns the PluginManager instance registered with this server.
        Returns:
        the PluginManager instance.
      • getPubSubModule

        public PubSubModule getPubSubModule()
        Returns the PubSubModule registered with this server. The PubSubModule was registered with the server as a module while starting up the server.
        Returns:
        the PubSubModule registered with this server.
      • getArchiveManager

        public ArchiveManager getArchiveManager()
        Returns the ArchiveManager registered with this server. The ArchiveManager was registered with the server as a module while starting up the server.
        Returns:
        the ArchiveManager registered with this server.
      • getIQHandlers

        public List<IQHandler> getIQHandlers()
        Returns a list with all the modules registered with the server that inherit from IQHandler.
        Returns:
        a list with all the modules registered with the server that inherit from IQHandler.
      • getSessionManager

        public SessionManager getSessionManager()
        Returns the SessionManager registered with this server. The SessionManager was registered with the server as a module while starting up the server.
        Returns:
        the SessionManager registered with this server.
      • getTransportHandler

        public TransportHandler getTransportHandler()
        Returns the TransportHandler registered with this server. The TransportHandler was registered with the server as a module while starting up the server.
        Returns:
        the TransportHandler registered with this server.
      • getPresenceUpdateHandler

        public PresenceUpdateHandler getPresenceUpdateHandler()
        Returns the PresenceUpdateHandler registered with this server. The PresenceUpdateHandler was registered with the server as a module while starting up the server.
        Returns:
        the PresenceUpdateHandler registered with this server.
      • getPresenceSubscribeHandler

        public PresenceSubscribeHandler getPresenceSubscribeHandler()
        Returns the PresenceSubscribeHandler registered with this server. The PresenceSubscribeHandler was registered with the server as a module while starting up the server.
        Returns:
        the PresenceSubscribeHandler registered with this server.
      • getIQRouter

        public IQRouter getIQRouter()
        Returns the IQRouter registered with this server. The IQRouter was registered with the server as a module while starting up the server.
        Returns:
        the IQRouter registered with this server.
      • getMessageRouter

        public MessageRouter getMessageRouter()
        Returns the MessageRouter registered with this server. The MessageRouter was registered with the server as a module while starting up the server.
        Returns:
        the MessageRouter registered with this server.
      • getPresenceRouter

        public PresenceRouter getPresenceRouter()
        Returns the PresenceRouter registered with this server. The PresenceRouter was registered with the server as a module while starting up the server.
        Returns:
        the PresenceRouter registered with this server.
      • getMulticastRouter

        public MulticastRouter getMulticastRouter()
        Returns the MulticastRouter registered with this server. The MulticastRouter was registered with the server as a module while starting up the server.
        Returns:
        the MulticastRouter registered with this server.
      • getUserManager

        public UserManager getUserManager()
        Returns the UserManager registered with this server. The UserManager was registered with the server as a module while starting up the server.
        Returns:
        the UserManager registered with this server.
      • getLockOutManager

        public LockOutManager getLockOutManager()
        Returns the LockOutManager registered with this server. The LockOutManager was registered with the server as a module while starting up the server.
        Returns:
        the LockOutManager registered with this server.
      • getUpdateManager

        public UpdateManager getUpdateManager()
        Returns the UpdateManager registered with this server. The UpdateManager was registered with the server as a module while starting up the server.
        Returns:
        the UpdateManager registered with this server.
      • getAuditManager

        public AuditManager getAuditManager()
        Returns the AuditManager registered with this server. The AuditManager was registered with the server as a module while starting up the server.
        Returns:
        the AuditManager registered with this server.
      • getEntityCapabilitiesManager

        public EntityCapabilitiesManager getEntityCapabilitiesManager()
        Returns the EntityCapabilitiesManager registered with this server. The EntityCapabilitiesManager was registered with the server as a module while starting up the server.
        Returns:
        the EntityCapabilitiesManager registered with this server.
      • getIQDiscoInfoHandler

        public IQDiscoInfoHandler getIQDiscoInfoHandler()
        Returns the IQDiscoInfoHandler registered with this server. The IQDiscoInfoHandler was registered with the server as a module while starting up the server.
        Returns:
        the IQDiscoInfoHandler registered with this server.
      • getIQDiscoItemsHandler

        public IQDiscoItemsHandler getIQDiscoItemsHandler()
        Returns the IQDiscoItemsHandler registered with this server. The IQDiscoItemsHandler was registered with the server as a module while starting up the server.
        Returns:
        the IQDiscoItemsHandler registered with this server.
      • getPrivateStorage

        public PrivateStorage getPrivateStorage()
        Returns the PrivateStorage registered with this server. The PrivateStorage was registered with the server as a module while starting up the server.
        Returns:
        the PrivateStorage registered with this server.
      • getMultiUserChatManager

        public MultiUserChatManager getMultiUserChatManager()
        Returns the MultiUserChatManager registered with this server. The MultiUserChatManager was registered with the server as a module while starting up the server.
        Returns:
        the MultiUserChatManager registered with this server.
      • getAdHocCommandHandler

        public AdHocCommandHandler getAdHocCommandHandler()
        Returns the AdHocCommandHandler registered with this server. The AdHocCommandHandler was registered with the server as a module while starting up the server.
        Returns:
        the AdHocCommandHandler registered with this server.
      • getFileTransferProxy

        public FileTransferProxy getFileTransferProxy()
        Returns the FileTransferProxy registered with this server. The FileTransferProxy was registered with the server as a module while starting up the server.
        Returns:
        the FileTransferProxy registered with this server.
      • getFileTransferManager

        public FileTransferManager getFileTransferManager()
        Returns the FileTransferManager registered with this server. The FileTransferManager was registered with the server as a module while starting up the server.
        Returns:
        the FileTransferProxy registered with this server.
      • getMediaProxyService

        public MediaProxyService getMediaProxyService()
        Returns the MediaProxyService registered with this server. The MediaProxyService was registered with the server as a module while starting up the server.
        Returns:
        the MediaProxyService registered with this server.
      • getVCardManager

        public VCardManager getVCardManager()
        Returns the VCardManager registered with this server. The VCardManager was registered with the server as a module while starting up the server.
        Returns:
        the VCardManager registered with this server.
      • getCertificateStoreManager

        public CertificateStoreManager getCertificateStoreManager()
        Returns the CertificateStoreManager registered with this server. The CertificateStoreManager was registered with the server as a module while starting up the server.
        Returns:
        the CertificateStoreManager registered with this server.
      • getRemoteSessionLocator

        public RemoteSessionLocator getRemoteSessionLocator()
        Returns the locator to use to find sessions hosted in other cluster nodes. When not running in a cluster a null value is returned.
        Returns:
        the locator to use to find sessions hosted in other cluster nodes.
      • setRemoteSessionLocator

        public void setRemoteSessionLocator​(RemoteSessionLocator remoteSessionLocator)
        Sets the locator to use to find sessions hosted in other cluster nodes. When not running in a cluster set a null value.
        Parameters:
        remoteSessionLocator - the locator to use to find sessions hosted in other cluster nodes.
      • isStarted

        public boolean isStarted()
        Returns whether or not the server has been started.
        Returns:
        whether or not the server has been started.
      • sendMessageToAdmins

        public Future<?> sendMessageToAdmins​(String message)
        Asynchronously send a message to every administrator on the system.
        Parameters:
        message - The message to send
        Returns:
        the future result of sending the message.