Package org.jivesoftware.openfire
Class XMPPServer
- java.lang.Object
-
- org.jivesoftware.openfire.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 thegetInstance()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.
- system property - The server will use the value defined in the openfireHome system property.
- 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.
- openfire_init.xml file - Attempt to load the value from openfire_init.xml which must be in the classpath
- Author:
- Gaston Dombiak
-
-
Constructor Summary
Constructors Constructor Description XMPPServer()Creates a server and starts it.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddServerListener(XMPPServerListener listener)Adds a new server listener that will be notified when the server has been started or is about to be stopped.org.xmpp.packet.JIDcreateJID(String username, String resource)Creates an XMPPAddress local to this server.org.xmpp.packet.JIDcreateJID(String username, String resource, boolean skipStringprep)Creates an XMPPAddress local to this server.voidfinishSetup()Finish the setup process.AdHocCommandHandlergetAdHocCommandHandler()Returns theAdHocCommandHandlerregistered with this server.Collection<org.xmpp.packet.JID>getAdmins()Returns a collection with the JIDs of the server's admins.ArchiveManagergetArchiveManager()Returns theArchiveManagerregistered with this server.AuditManagergetAuditManager()Returns theAuditManagerregistered with this server.CertificateStoreManagergetCertificateStoreManager()Returns theCertificateStoreManagerregistered with this server.ConnectionManagergetConnectionManager()Returns theConnectionManagerregistered with this server.NodeIDgetDefaultNodeID()Returns the default node ID used by this server before clustering is initialized.EntityCapabilitiesManagergetEntityCapabilitiesManager()Returns theEntityCapabilitiesManagerregistered with this server.FileTransferManagergetFileTransferManager()Returns theFileTransferManagerregistered with this server.FileTransferProxygetFileTransferProxy()Returns theFileTransferProxyregistered with this server.FlashCrossDomainHandlergetFlashCrossDomainHandler()Returns theFlashCrossDomainHandlerregistered with this server.static XMPPServergetInstance()Returns a singleton instance of XMPPServer.IQDiscoInfoHandlergetIQDiscoInfoHandler()Returns theIQDiscoInfoHandlerregistered with this server.IQDiscoItemsHandlergetIQDiscoItemsHandler()Returns theIQDiscoItemsHandlerregistered with this server.List<IQHandler>getIQHandlers()Returns a list with all the modules registered with the server that inherit from IQHandler.IQPEPHandlergetIQPEPHandler()Returns theIQPEPHandlerregistered with this server.IQRegisterHandlergetIQRegisterHandler()Returns theIQRegisterHandlerregistered with this server.IQRoutergetIQRouter()Returns theIQRouterregistered with this server.LockOutManagergetLockOutManager()Returns theLockOutManagerregistered with this server.MediaProxyServicegetMediaProxyService()Returns theMediaProxyServiceregistered with this server.MessageRoutergetMessageRouter()Returns theMessageRouterregistered with this server.MulticastRoutergetMulticastRouter()Returns theMulticastRouterregistered with this server.MultiUserChatManagergetMultiUserChatManager()Returns theMultiUserChatManagerregistered with this server.NodeIDgetNodeID()Returns an ID that uniquely identifies this server in a cluster.OfflineMessageStoregetOfflineMessageStore()Returns theOfflineMessageStoreregistered with this server.OfflineMessageStrategygetOfflineMessageStrategy()Returns theOfflineMessageStrategyregistered with this server.PacketDeliverergetPacketDeliverer()Returns thePacketDelivererregistered with this server.PacketRoutergetPacketRouter()Returns thePacketRouterregistered with this server.PluginManagergetPluginManager()Returns thePluginManagerinstance registered with this server.PresenceManagergetPresenceManager()Returns thePresenceManagerregistered with this server.PresenceRoutergetPresenceRouter()Returns thePresenceRouterregistered with this server.PresenceSubscribeHandlergetPresenceSubscribeHandler()Returns thePresenceSubscribeHandlerregistered with this server.PresenceUpdateHandlergetPresenceUpdateHandler()Returns thePresenceUpdateHandlerregistered with this server.PrivateStoragegetPrivateStorage()Returns thePrivateStorageregistered with this server.PubSubModulegetPubSubModule()Returns thePubSubModuleregistered with this server.RemoteSessionLocatorgetRemoteSessionLocator()Returns the locator to use to find sessions hosted in other cluster nodes.RosterManagergetRosterManager()Returns theRosterManagerregistered with this server.RoutingTablegetRoutingTable()Returns theRoutingTableregistered with this server.List<ServerFeaturesProvider>getServerFeaturesProviders()Deprecated.UseIQDiscoInfoHandlerinstead.List<ServerIdentitiesProvider>getServerIdentitiesProviders()Deprecated.UseIQDiscoInfoHandlerinstead.XMPPServerInfogetServerInfo()Returns a snapshot of the server's status.List<ServerItemsProvider>getServerItemsProviders()Deprecated.UseIQDiscoItemsHandlerinstead.SessionManagergetSessionManager()Returns theSessionManagerregistered with this server.TransportHandlergetTransportHandler()Returns theTransportHandlerregistered with this server.UpdateManagergetUpdateManager()Returns theUpdateManagerregistered with this server.List<UserIdentitiesProvider>getUserIdentitiesProviders()Deprecated.UseIQDiscoInfoHandlerinstead.List<UserItemsProvider>getUserItemsProviders()Deprecated.UseIQDiscoInfoHandlerinstead.UserManagergetUserManager()Returns theUserManagerregistered with this server.VCardManagergetVCardManager()Returns theVCardManagerregistered with this server.booleanisLocal(org.xmpp.packet.JID jid)Returns true if the given address is local to the server (managed by this server domain).booleanisRemote(org.xmpp.packet.JID jid)Returns true if the given address does not match the local server hostname and does not match a component service JID.booleanisRestartable()booleanisSetupMode()booleanisShuttingDown()Returns true if the server is being shutdown.booleanisStandAlone()Returns if the server is running in standalone mode.booleanisStarted()Returns whether or not the server has been started.booleanmatchesComponent(org.xmpp.packet.JID jid)Returns true if the given address matches a component service JID.voidremoveServerListener(XMPPServerListener listener)Removes a server listener that was being notified when the server was being started or was about to be stopped.voidrestart()Restarts the server and all it's modules only if the server is restartable.voidrestartHTTPServer()Restarts the HTTP server only when running in stand alone mode.Future<?>sendMessageToAdmins(String message)Asynchronously send a message to every administrator on the system.static voidsetInstance(XMPPServer instance)Deprecated.- for test use onlyvoidsetNodeID(NodeID nodeID)Sets an ID that uniquely identifies this server in a cluster.voidsetRemoteSessionLocator(RemoteSessionLocator remoteSessionLocator)Sets the locator to use to find sessions hosted in other cluster nodes.voidstart()voidstop()Stops the server only if running in standalone mode.
-
-
-
Field Detail
-
EXIT
public static final String EXIT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static XMPPServer getInstance()
Returns a singleton instance of XMPPServer.- Returns:
- an instance.
-
setInstance
@Deprecated public static void setInstance(XMPPServer instance)
Deprecated.- for test use onlyTODO: (2019-04-24) Remove and replace with Mockito mocking of static methods, when available- Parameters:
instance- the mock/stub/spy XMPPServer to return whengetInstance()is called.
-
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 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 given address matches a component service JID.- 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 theConnectionManagerregistered with this server. TheConnectionManagerwas registered with the server as a module while starting up the server.- Returns:
- the
ConnectionManagerregistered with this server.
-
getRoutingTable
public RoutingTable getRoutingTable()
Returns theRoutingTableregistered with this server. TheRoutingTablewas registered with the server as a module while starting up the server.- Returns:
- the
RoutingTableregistered with this server.
-
getPacketDeliverer
public PacketDeliverer getPacketDeliverer()
Returns thePacketDelivererregistered with this server. ThePacketDelivererwas registered with the server as a module while starting up the server.- Returns:
- the
PacketDelivererregistered with this server.
-
getRosterManager
public RosterManager getRosterManager()
Returns theRosterManagerregistered with this server. TheRosterManagerwas registered with the server as a module while starting up the server.- Returns:
- the
RosterManagerregistered with this server.
-
getPresenceManager
public PresenceManager getPresenceManager()
Returns thePresenceManagerregistered with this server. ThePresenceManagerwas registered with the server as a module while starting up the server.- Returns:
- the
PresenceManagerregistered with this server.
-
getOfflineMessageStore
public OfflineMessageStore getOfflineMessageStore()
Returns theOfflineMessageStoreregistered with this server. TheOfflineMessageStorewas registered with the server as a module while starting up the server.- Returns:
- the
OfflineMessageStoreregistered with this server.
-
getOfflineMessageStrategy
public OfflineMessageStrategy getOfflineMessageStrategy()
Returns theOfflineMessageStrategyregistered with this server. TheOfflineMessageStrategywas registered with the server as a module while starting up the server.- Returns:
- the
OfflineMessageStrategyregistered with this server.
-
getPacketRouter
public PacketRouter getPacketRouter()
Returns thePacketRouterregistered with this server. ThePacketRouterwas registered with the server as a module while starting up the server.- Returns:
- the
PacketRouterregistered with this server.
-
getIQRegisterHandler
public IQRegisterHandler getIQRegisterHandler()
Returns theIQRegisterHandlerregistered with this server. TheIQRegisterHandlerwas registered with the server as a module while starting up the server.- Returns:
- the
IQRegisterHandlerregistered with this server.
-
getIQPEPHandler
public IQPEPHandler getIQPEPHandler()
Returns theIQPEPHandlerregistered with this server. TheIQPEPHandlerwas registered with the server as a module while starting up the server.- Returns:
- the
IQPEPHandlerregistered with this server.
-
getPluginManager
public PluginManager getPluginManager()
Returns thePluginManagerinstance registered with this server.- Returns:
- the PluginManager instance.
-
getPubSubModule
public PubSubModule getPubSubModule()
Returns thePubSubModuleregistered with this server. ThePubSubModulewas registered with the server as a module while starting up the server.- Returns:
- the
PubSubModuleregistered with this server.
-
getArchiveManager
public ArchiveManager getArchiveManager()
Returns theArchiveManagerregistered with this server. TheArchiveManagerwas registered with the server as a module while starting up the server.- Returns:
- the
ArchiveManagerregistered 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 theSessionManagerregistered with this server. TheSessionManagerwas registered with the server as a module while starting up the server.- Returns:
- the
SessionManagerregistered with this server.
-
getTransportHandler
public TransportHandler getTransportHandler()
Returns theTransportHandlerregistered with this server. TheTransportHandlerwas registered with the server as a module while starting up the server.- Returns:
- the
TransportHandlerregistered with this server.
-
getPresenceUpdateHandler
public PresenceUpdateHandler getPresenceUpdateHandler()
Returns thePresenceUpdateHandlerregistered with this server. ThePresenceUpdateHandlerwas registered with the server as a module while starting up the server.- Returns:
- the
PresenceUpdateHandlerregistered with this server.
-
getPresenceSubscribeHandler
public PresenceSubscribeHandler getPresenceSubscribeHandler()
Returns thePresenceSubscribeHandlerregistered with this server. ThePresenceSubscribeHandlerwas registered with the server as a module while starting up the server.- Returns:
- the
PresenceSubscribeHandlerregistered with this server.
-
getIQRouter
public IQRouter getIQRouter()
Returns theIQRouterregistered with this server. TheIQRouterwas registered with the server as a module while starting up the server.- Returns:
- the
IQRouterregistered with this server.
-
getMessageRouter
public MessageRouter getMessageRouter()
Returns theMessageRouterregistered with this server. TheMessageRouterwas registered with the server as a module while starting up the server.- Returns:
- the
MessageRouterregistered with this server.
-
getPresenceRouter
public PresenceRouter getPresenceRouter()
Returns thePresenceRouterregistered with this server. ThePresenceRouterwas registered with the server as a module while starting up the server.- Returns:
- the
PresenceRouterregistered with this server.
-
getMulticastRouter
public MulticastRouter getMulticastRouter()
Returns theMulticastRouterregistered with this server. TheMulticastRouterwas registered with the server as a module while starting up the server.- Returns:
- the
MulticastRouterregistered with this server.
-
getUserManager
public UserManager getUserManager()
Returns theUserManagerregistered with this server. TheUserManagerwas registered with the server as a module while starting up the server.- Returns:
- the
UserManagerregistered with this server.
-
getLockOutManager
public LockOutManager getLockOutManager()
Returns theLockOutManagerregistered with this server. TheLockOutManagerwas registered with the server as a module while starting up the server.- Returns:
- the
LockOutManagerregistered with this server.
-
getUpdateManager
public UpdateManager getUpdateManager()
Returns theUpdateManagerregistered with this server. TheUpdateManagerwas registered with the server as a module while starting up the server.- Returns:
- the
UpdateManagerregistered with this server.
-
getAuditManager
public AuditManager getAuditManager()
Returns theAuditManagerregistered with this server. TheAuditManagerwas registered with the server as a module while starting up the server.- Returns:
- the
AuditManagerregistered with this server.
-
getEntityCapabilitiesManager
public EntityCapabilitiesManager getEntityCapabilitiesManager()
Returns theEntityCapabilitiesManagerregistered with this server. TheEntityCapabilitiesManagerwas registered with the server as a module while starting up the server.- Returns:
- the
EntityCapabilitiesManagerregistered with this server.
-
getServerFeaturesProviders
@Deprecated public List<ServerFeaturesProvider> getServerFeaturesProviders()
Deprecated.UseIQDiscoInfoHandlerinstead.Returns a list with all the modules that provide "discoverable" features.- Returns:
- a list with all the modules that provide "discoverable" features.
-
getServerIdentitiesProviders
@Deprecated public List<ServerIdentitiesProvider> getServerIdentitiesProviders()
Deprecated.UseIQDiscoInfoHandlerinstead.Returns a list with all the modules that provide "discoverable" identities.- Returns:
- a list with all the modules that provide "discoverable" identities.
-
getServerItemsProviders
@Deprecated public List<ServerItemsProvider> getServerItemsProviders()
Deprecated.UseIQDiscoItemsHandlerinstead.Returns a list with all the modules that provide "discoverable" items associated with the server.- Returns:
- a list with all the modules that provide "discoverable" items associated with the server.
-
getUserIdentitiesProviders
@Deprecated public List<UserIdentitiesProvider> getUserIdentitiesProviders()
Deprecated.UseIQDiscoInfoHandlerinstead.Returns a list with all the modules that provide "discoverable" user identities.- Returns:
- a list with all the modules that provide "discoverable" user identities.
-
getUserItemsProviders
@Deprecated public List<UserItemsProvider> getUserItemsProviders()
Deprecated.UseIQDiscoInfoHandlerinstead.Returns a list with all the modules that provide "discoverable" items associated with users.- Returns:
- a list with all the modules that provide "discoverable" items associated with users.
-
getIQDiscoInfoHandler
public IQDiscoInfoHandler getIQDiscoInfoHandler()
Returns theIQDiscoInfoHandlerregistered with this server. TheIQDiscoInfoHandlerwas registered with the server as a module while starting up the server.- Returns:
- the
IQDiscoInfoHandlerregistered with this server.
-
getIQDiscoItemsHandler
public IQDiscoItemsHandler getIQDiscoItemsHandler()
Returns theIQDiscoItemsHandlerregistered with this server. TheIQDiscoItemsHandlerwas registered with the server as a module while starting up the server.- Returns:
- the
IQDiscoItemsHandlerregistered with this server.
-
getPrivateStorage
public PrivateStorage getPrivateStorage()
Returns thePrivateStorageregistered with this server. ThePrivateStoragewas registered with the server as a module while starting up the server.- Returns:
- the
PrivateStorageregistered with this server.
-
getMultiUserChatManager
public MultiUserChatManager getMultiUserChatManager()
Returns theMultiUserChatManagerregistered with this server. TheMultiUserChatManagerwas registered with the server as a module while starting up the server.- Returns:
- the
MultiUserChatManagerregistered with this server.
-
getAdHocCommandHandler
public AdHocCommandHandler getAdHocCommandHandler()
Returns theAdHocCommandHandlerregistered with this server. TheAdHocCommandHandlerwas registered with the server as a module while starting up the server.- Returns:
- the
AdHocCommandHandlerregistered with this server.
-
getFileTransferProxy
public FileTransferProxy getFileTransferProxy()
Returns theFileTransferProxyregistered with this server. TheFileTransferProxywas registered with the server as a module while starting up the server.- Returns:
- the
FileTransferProxyregistered with this server.
-
getFileTransferManager
public FileTransferManager getFileTransferManager()
Returns theFileTransferManagerregistered with this server. TheFileTransferManagerwas registered with the server as a module while starting up the server.- Returns:
- the
FileTransferProxyregistered with this server.
-
getMediaProxyService
public MediaProxyService getMediaProxyService()
Returns theMediaProxyServiceregistered with this server. TheMediaProxyServicewas registered with the server as a module while starting up the server.- Returns:
- the
MediaProxyServiceregistered with this server.
-
getFlashCrossDomainHandler
public FlashCrossDomainHandler getFlashCrossDomainHandler()
Returns theFlashCrossDomainHandlerregistered with this server. TheFlashCrossDomainHandlerwas registered with the server as a module while starting up the server.- Returns:
- the
FlashCrossDomainHandlerregistered with this server.
-
getVCardManager
public VCardManager getVCardManager()
Returns theVCardManagerregistered with this server. TheVCardManagerwas registered with the server as a module while starting up the server.- Returns:
- the
VCardManagerregistered with this server.
-
getCertificateStoreManager
public CertificateStoreManager getCertificateStoreManager()
Returns theCertificateStoreManagerregistered with this server. TheCertificateStoreManagerwas registered with the server as a module while starting up the server.- Returns:
- the
CertificateStoreManagerregistered 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 anullvalue 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 anullvalue.- 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.
-
-