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 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.org.xmpp.packet.JID
createJID(String username, String resource)
Creates an XMPPAddress local to this server.org.xmpp.packet.JID
createJID(String username, String resource, boolean skipStringprep)
Creates an XMPPAddress local to this server.void
finishSetup()
Finish the setup process.AdHocCommandHandler
getAdHocCommandHandler()
Returns theAdHocCommandHandler
registered with this server.Collection<org.xmpp.packet.JID>
getAdmins()
Returns a collection with the JIDs of the server's admins.ArchiveManager
getArchiveManager()
Returns theArchiveManager
registered with this server.AuditManager
getAuditManager()
Returns theAuditManager
registered with this server.CertificateStoreManager
getCertificateStoreManager()
Returns theCertificateStoreManager
registered with this server.ConnectionManager
getConnectionManager()
Returns theConnectionManager
registered with this server.NodeID
getDefaultNodeID()
Returns the default node ID used by this server before clustering is initialized.EntityCapabilitiesManager
getEntityCapabilitiesManager()
Returns theEntityCapabilitiesManager
registered with this server.FileTransferManager
getFileTransferManager()
Returns theFileTransferManager
registered with this server.FileTransferProxy
getFileTransferProxy()
Returns theFileTransferProxy
registered with this server.FlashCrossDomainHandler
getFlashCrossDomainHandler()
Returns theFlashCrossDomainHandler
registered with this server.static XMPPServer
getInstance()
Returns a singleton instance of XMPPServer.IQDiscoInfoHandler
getIQDiscoInfoHandler()
Returns theIQDiscoInfoHandler
registered with this server.IQDiscoItemsHandler
getIQDiscoItemsHandler()
Returns theIQDiscoItemsHandler
registered with this server.List<IQHandler>
getIQHandlers()
Returns a list with all the modules registered with the server that inherit from IQHandler.IQPEPHandler
getIQPEPHandler()
Returns theIQPEPHandler
registered with this server.IQRegisterHandler
getIQRegisterHandler()
Returns theIQRegisterHandler
registered with this server.IQRouter
getIQRouter()
Returns theIQRouter
registered with this server.LockOutManager
getLockOutManager()
Returns theLockOutManager
registered with this server.MediaProxyService
getMediaProxyService()
Returns theMediaProxyService
registered with this server.MessageRouter
getMessageRouter()
Returns theMessageRouter
registered with this server.MulticastRouter
getMulticastRouter()
Returns theMulticastRouter
registered with this server.MultiUserChatManager
getMultiUserChatManager()
Returns theMultiUserChatManager
registered with this server.NodeID
getNodeID()
Returns an ID that uniquely identifies this server in a cluster.OfflineMessageStore
getOfflineMessageStore()
Returns theOfflineMessageStore
registered with this server.OfflineMessageStrategy
getOfflineMessageStrategy()
Returns theOfflineMessageStrategy
registered with this server.PacketDeliverer
getPacketDeliverer()
Returns thePacketDeliverer
registered with this server.PacketRouter
getPacketRouter()
Returns thePacketRouter
registered with this server.PluginManager
getPluginManager()
Returns thePluginManager
instance registered with this server.PresenceManager
getPresenceManager()
Returns thePresenceManager
registered with this server.PresenceRouter
getPresenceRouter()
Returns thePresenceRouter
registered with this server.PresenceSubscribeHandler
getPresenceSubscribeHandler()
Returns thePresenceSubscribeHandler
registered with this server.PresenceUpdateHandler
getPresenceUpdateHandler()
Returns thePresenceUpdateHandler
registered with this server.PrivateStorage
getPrivateStorage()
Returns thePrivateStorage
registered with this server.PubSubModule
getPubSubModule()
Returns thePubSubModule
registered with this server.RemoteSessionLocator
getRemoteSessionLocator()
Returns the locator to use to find sessions hosted in other cluster nodes.RosterManager
getRosterManager()
Returns theRosterManager
registered with this server.RoutingTable
getRoutingTable()
Returns theRoutingTable
registered with this server.List<ServerFeaturesProvider>
getServerFeaturesProviders()
Deprecated.UseIQDiscoInfoHandler
instead.List<ServerIdentitiesProvider>
getServerIdentitiesProviders()
Deprecated.UseIQDiscoInfoHandler
instead.XMPPServerInfo
getServerInfo()
Returns a snapshot of the server's status.List<ServerItemsProvider>
getServerItemsProviders()
Deprecated.UseIQDiscoItemsHandler
instead.SessionManager
getSessionManager()
Returns theSessionManager
registered with this server.TransportHandler
getTransportHandler()
Returns theTransportHandler
registered with this server.UpdateManager
getUpdateManager()
Returns theUpdateManager
registered with this server.List<UserIdentitiesProvider>
getUserIdentitiesProviders()
Deprecated.UseIQDiscoInfoHandler
instead.List<UserItemsProvider>
getUserItemsProviders()
Deprecated.UseIQDiscoInfoHandler
instead.UserManager
getUserManager()
Returns theUserManager
registered with this server.VCardManager
getVCardManager()
Returns theVCardManager
registered with this server.boolean
isLocal(org.xmpp.packet.JID jid)
Returns true if the given address is local to the server (managed by this server domain).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.boolean
isRestartable()
boolean
isSetupMode()
boolean
isShuttingDown()
Returns true if the server is being shutdown.boolean
isStandAlone()
Returns if the server is running in standalone mode.boolean
isStarted()
Returns whether or not the server has been started.boolean
matchesComponent(org.xmpp.packet.JID jid)
Returns true if the given address matches a component service JID.void
removeServerListener(XMPPServerListener listener)
Removes a server listener that was being notified when the server was being started or was about to be stopped.void
restart()
Restarts the server and all it's modules only if the server is restartable.void
restartHTTPServer()
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 void
setInstance(XMPPServer instance)
Deprecated.- for test use onlyvoid
setNodeID(NodeID nodeID)
Sets an ID that uniquely identifies this server in a cluster.void
setRemoteSessionLocator(RemoteSessionLocator remoteSessionLocator)
Sets the locator to use to find sessions hosted in other cluster nodes.void
start()
void
stop()
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 theConnectionManager
registered with this server. TheConnectionManager
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 theRoutingTable
registered with this server. TheRoutingTable
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 thePacketDeliverer
registered with this server. ThePacketDeliverer
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 theRosterManager
registered with this server. TheRosterManager
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 thePresenceManager
registered with this server. ThePresenceManager
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 theOfflineMessageStore
registered with this server. TheOfflineMessageStore
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 theOfflineMessageStrategy
registered with this server. TheOfflineMessageStrategy
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 thePacketRouter
registered with this server. ThePacketRouter
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 theIQRegisterHandler
registered with this server. TheIQRegisterHandler
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 theIQPEPHandler
registered with this server. TheIQPEPHandler
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 thePluginManager
instance registered with this server.- Returns:
- the PluginManager instance.
-
getPubSubModule
public PubSubModule getPubSubModule()
Returns thePubSubModule
registered with this server. ThePubSubModule
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 theArchiveManager
registered with this server. TheArchiveManager
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 theSessionManager
registered with this server. TheSessionManager
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 theTransportHandler
registered with this server. TheTransportHandler
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 thePresenceUpdateHandler
registered with this server. ThePresenceUpdateHandler
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 thePresenceSubscribeHandler
registered with this server. ThePresenceSubscribeHandler
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 theIQRouter
registered with this server. TheIQRouter
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 theMessageRouter
registered with this server. TheMessageRouter
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 thePresenceRouter
registered with this server. ThePresenceRouter
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 theMulticastRouter
registered with this server. TheMulticastRouter
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 theUserManager
registered with this server. TheUserManager
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 theLockOutManager
registered with this server. TheLockOutManager
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 theUpdateManager
registered with this server. TheUpdateManager
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 theAuditManager
registered with this server. TheAuditManager
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 theEntityCapabilitiesManager
registered with this server. TheEntityCapabilitiesManager
was registered with the server as a module while starting up the server.- Returns:
- the
EntityCapabilitiesManager
registered with this server.
-
getServerFeaturesProviders
@Deprecated public List<ServerFeaturesProvider> getServerFeaturesProviders()
Deprecated.UseIQDiscoInfoHandler
instead.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.UseIQDiscoInfoHandler
instead.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.UseIQDiscoItemsHandler
instead.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.UseIQDiscoInfoHandler
instead.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.UseIQDiscoInfoHandler
instead.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 theIQDiscoInfoHandler
registered with this server. TheIQDiscoInfoHandler
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 theIQDiscoItemsHandler
registered with this server. TheIQDiscoItemsHandler
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 thePrivateStorage
registered with this server. ThePrivateStorage
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 theMultiUserChatManager
registered with this server. TheMultiUserChatManager
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 theAdHocCommandHandler
registered with this server. TheAdHocCommandHandler
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 theFileTransferProxy
registered with this server. TheFileTransferProxy
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 theFileTransferManager
registered with this server. TheFileTransferManager
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 theMediaProxyService
registered with this server. TheMediaProxyService
was registered with the server as a module while starting up the server.- Returns:
- the
MediaProxyService
registered with this server.
-
getFlashCrossDomainHandler
public FlashCrossDomainHandler getFlashCrossDomainHandler()
Returns theFlashCrossDomainHandler
registered with this server. TheFlashCrossDomainHandler
was registered with the server as a module while starting up the server.- Returns:
- the
FlashCrossDomainHandler
registered with this server.
-
getVCardManager
public VCardManager getVCardManager()
Returns theVCardManager
registered with this server. TheVCardManager
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 theCertificateStoreManager
registered with this server. TheCertificateStoreManager
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 anull
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 anull
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.
-
-