Package org.jivesoftware.openfire.muc
Class MultiUserChatManager
java.lang.Object
org.jivesoftware.openfire.container.BasicModule
org.jivesoftware.openfire.muc.MultiUserChatManager
- All Implemented Interfaces:
Module,UserEventListener,MUCServicePropertyEventListener
public class MultiUserChatManager
extends BasicModule
implements MUCServicePropertyEventListener, UserEventListener
Provides centralized management of all configured Multi User Chat (MUC) services.
- Author:
- Daniel Henninger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SystemProperty<String>A secret that is shared with all MUC services in the Openfire cluster. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionVerifies that caches and supporting structures around rooms and occupants are in a consistent state.createMultiUserChatService(String subdomain, String description, boolean isHidden) Creates a new MUC service and registers it with the manager (which causes a cluster-wide notification to be sent) and starts up the service.voiddeleteRetiree(String mucServiceName, String retireeName) Deletes a retiree for a MUC room.getMultiUserChatService(long serviceID) Retrieves a MultiUserChatService instance specified by it's service ID.getMultiUserChatService(String subdomain) Retrieves a MultiUserChatService instance specified by it's subdomain of the server's primary domain.getMultiUserChatService(org.xmpp.packet.JID jid) Retrieves a MultiUserChatService instance specified by any JID that refers to it.getMultiUserChatServiceID(String subdomain) Retrieves the database ID of a MUC service by subdomain.Retrieves all of the MultiUserChatServices managed and configured for this server, sorted by subdomain.intRetrieves the number of MultiUserChatServices that are configured for this server.getMultiUserChatSubdomain(long serviceID) Retrieves the subdomain of a specified service ID.intgetRetireeCount(String mucServiceName) Gets the number of MUC room retirees.getRetirees(String mucServiceName, int startIndex, int numResults) Gets the retirees for a MUC service.intgetServicesCount(boolean includePrivate) Returns the number of registered MultiUserChatServices.voidinitialize(XMPPServer server) Initializes the basic module.booleanisServiceRegistered(String subdomain) Returns true if a MUC service is configured/exists for a given subdomain.voidA property was deleted.voidA property was set.voidrefreshService(String subdomain) Updates the in-memory representation of a previously loaded services from the database.voidRegisters a new MultiUserChatService implementation to the manager.voidregisterMultiUserChatService(MultiUserChatService service, boolean allNodes) Registers a new MultiUserChatService implementation to the manager.voidremoveMultiUserChatService(long serviceID) Deletes a configured MultiUserChatService by ID, and shuts it down.voidremoveMultiUserChatService(String subdomain) Deletes a configured MultiUserChatService by subdomain, and shuts it down.voidstart()Called when manager starts up, to initialize things.voidstop()Called when manager is stopped, to clean things up.voidunregisterMultiUserChatService(String subdomain) Unregisters a MultiUserChatService from the manager.voidunregisterMultiUserChatService(String subdomain, boolean allNodes) Unregisters a MultiUserChatService from the manager.voidupdateMultiUserChatService(long serviceID, String subdomain, String description) Updates the configuration of a MUC service.voidupdateMultiUserChatService(String currentSubdomain, String newSubdomain, String description) Updates the configuration of a MUC service.voiduserCreated(User user, Map<String, Object> params) A user was created.voiduserDeleting(User user, Map<String, Object> params) A user is being deleted.voiduserModified(User user, Map<String, Object> params) A user's name, email, or an extended property was changed.Methods inherited from class org.jivesoftware.openfire.container.BasicModule
destroy, getName
-
Field Details
-
MASTER_KEY
A secret that is shared with all MUC services in the Openfire cluster. This value should never be changed after it has initially been generated.
-
-
Constructor Details
-
MultiUserChatManager
public MultiUserChatManager()Creates a new MultiUserChatManager instance.
-
-
Method Details
-
initialize
Description copied from class:BasicModuleInitializes the basic module.
Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.
- Specified by:
initializein interfaceModule- Overrides:
initializein classBasicModule- Parameters:
server- the server hosting this module.
-
start
public void start()Called when manager starts up, to initialize things.- Specified by:
startin interfaceModule- Overrides:
startin classBasicModule
-
stop
public void stop()Called when manager is stopped, to clean things up.- Specified by:
stopin interfaceModule- Overrides:
stopin classBasicModule
-
registerMultiUserChatService
Registers a new MultiUserChatService implementation to the manager. This is typically used if you have a custom MUC implementation that you want to register with the manager. In other words, it may not be database stored and may follow special rules, implementing MultiUserChatService. It is also used internally to register services from the database. Triggers the service to start up. An event will be sent to all other cluster nodes to inform them that a new service was added.- Parameters:
service- The MultiUserChatService to be registered.- See Also:
-
registerMultiUserChatService
Registers a new MultiUserChatService implementation to the manager. This is typically used if you have a custom MUC implementation that you want to register with the manager. In other words, it may not be database stored and may follow special rules, implementing MultiUserChatService. It is also used internally to register services from the database. Triggers the service to start up. This method has a boolean parameter that controls whether a 'new service added' event is to be sent to all other cluster nodes. This generally is desirable when a new service is being created. A reason to _not_ send such an event is when this method is being invoked as a result of receiving/processing such an event that was received from another cluster node, or when initializing this instance from database content (which will occur on all cluster nodes).- Parameters:
service- The MultiUserChatService to be registered.allNodes- true if a 'service added' event needs to be sent to other cluster nodes.- See Also:
-
unregisterMultiUserChatService
Unregisters a MultiUserChatService from the manager. It can be used to explicitly unregister services, and is also used internally to unregister database stored services. Triggers the service to shut down. An event will be sent to all other cluster nodes to inform them that a new service was added.- Parameters:
subdomain- The subdomain of the service to be unregistered.- See Also:
-
unregisterMultiUserChatService
Unregisters a MultiUserChatService from the manager. It can be used to explicitly unregister services, and is also used internally to unregister database stored services. Triggers the service to shut down. This method has a boolean parameter that controls whether a 'service removed' event is to be sent to all other cluster nodes. This generally is desirable when a pre-existing service is being removed. A reason to _not_ send such an event is when this method is being invoked as a result of receiving/processing such an event that was received from another cluster node, or when shutting down this instance (as the service might continue to live on other cluster nodes).- Parameters:
subdomain- The subdomain of the service to be unregistered.allNodes- true if a 'service removed' event needs to be sent to other cluster nodes.- See Also:
-
getServicesCount
public int getServicesCount(boolean includePrivate) Returns the number of registered MultiUserChatServices.- Parameters:
includePrivate- True if you want to include private/hidden services in the count.- Returns:
- Number of registered services.
-
createMultiUserChatService
@Nonnull public MultiUserChatServiceImpl createMultiUserChatService(@Nonnull String subdomain, @Nullable String description, boolean isHidden) throws AlreadyExistsException Creates a new MUC service and registers it with the manager (which causes a cluster-wide notification to be sent) and starts up the service.- Parameters:
subdomain- Subdomain of the MUC service.description- Description of the MUC service (can be null for default description)isHidden- True if the service is hidden from view in services lists.- Returns:
- MultiUserChatService implementation that was just created.
- Throws:
AlreadyExistsException- if the service already exists.
-
updateMultiUserChatService
public void updateMultiUserChatService(long serviceID, @Nonnull String subdomain, @Nullable String description) throws NotFoundException Updates the configuration of a MUC service. This is more involved than it may seem. If the subdomain is changed, we need to shut down the old service and start up the new one, registering the new subdomain and cleaning up the old one. Properties are tied to the ID, which will not change.- Parameters:
serviceID- The ID of the service to be updated.subdomain- New subdomain to assign to the service.description- New description to assign to the service.- Throws:
NotFoundException- if service was not found.
-
updateMultiUserChatService
public void updateMultiUserChatService(@Nonnull String currentSubdomain, @Nonnull String newSubdomain, @Nullable String description) throws NotFoundException Updates the configuration of a MUC service. This is more involved than it may seem. If the subdomain is changed, we need to shut down the old service and start up the new one, registering the new subdomain and cleaning up the old one. Properties are tied to the ID, which will not change.- Parameters:
currentSubdomain- The current subdomain assigned to the service.newSubdomain- New subdomain to assign to the service.description- New description to assign to the service.- Throws:
NotFoundException- if service was not found.
-
removeMultiUserChatService
Deletes a configured MultiUserChatService by subdomain, and shuts it down.- Parameters:
subdomain- The subdomain of the service to be deleted.- Throws:
NotFoundException- if the service was not found.
-
removeMultiUserChatService
Deletes a configured MultiUserChatService by ID, and shuts it down.- Parameters:
serviceID- The ID opf the service to be deleted.- Throws:
NotFoundException- if the service was not found.
-
getMultiUserChatService
Retrieves a MultiUserChatService instance specified by it's service ID.- Parameters:
serviceID- ID of the conference service you wish to query.- Returns:
- The MultiUserChatService instance associated with the id, or null if none found.
-
getMultiUserChatService
Retrieves a MultiUserChatService instance specified by it's subdomain of the server's primary domain. In other words: if the service is conference.example.org, and the server is example.org, you would specify conference here.- Parameters:
subdomain- Subdomain of the conference service you wish to query.- Returns:
- The MultiUserChatService instance associated with the subdomain, or null if none found.
-
getMultiUserChatService
Retrieves a MultiUserChatService instance specified by any JID that refers to it. In other words: the argument value can be a XMPP domain name for the service, a room JID, or even the JID of a occupant of the room. The implementation takes the domain part of the JID, strips off the server domain name from the end, leaving only the subdomain, and then calls the subdomain version of the call.- Parameters:
jid- JID that contains a reference to the conference service.- Returns:
- The MultiUserChatService instance associated with the JID, or null if none found.
-
getMultiUserChatServices
Retrieves all of the MultiUserChatServices managed and configured for this server, sorted by subdomain.- Returns:
- A list of MultiUserChatServices configured for this server.
-
getMultiUserChatServicesCount
public int getMultiUserChatServicesCount()Retrieves the number of MultiUserChatServices that are configured for this server.- Returns:
- The number of registered MultiUserChatServices.
-
isServiceRegistered
Returns true if a MUC service is configured/exists for a given subdomain.- Parameters:
subdomain- Subdomain of service to check on.- Returns:
- True or false if the subdomain is registered as a MUC service.
-
getMultiUserChatServiceID
Retrieves the database ID of a MUC service by subdomain.- Parameters:
subdomain- Subdomain of service to get ID of.- Returns:
- ID number of MUC service, or null if none found.
-
getMultiUserChatSubdomain
Retrieves the subdomain of a specified service ID.- Parameters:
serviceID- ID of service to get subdomain of.- Returns:
- Subdomain of MUC service, or null if none found.
-
refreshService
Updates the in-memory representation of a previously loaded services from the database. This call will modify database-stored characteristics for a service previously loaded to memory on the local cluster node. An exception will be thrown if used for a service that's not in memory. Note that this method will not cause MUCServiceProperties to be reloaded. It only operates on fields like the service description. This method is primarily useful to cause a service to reload its state from the database after it was changed on another cluster node.- Parameters:
subdomain- the domain of the service to refresh
-
propertySet
Description copied from interface:MUCServicePropertyEventListenerA property was set. The parameter mapparamswill contain the the value of the property under the keyvalue.- Specified by:
propertySetin interfaceMUCServicePropertyEventListener- Parameters:
service- the subdomain of the service the property was set on.property- the name of the property.params- event parameters.
-
propertyDeleted
Description copied from interface:MUCServicePropertyEventListenerA property was deleted.- Specified by:
propertyDeletedin interfaceMUCServicePropertyEventListener- Parameters:
service- the subdomain of the service the property was deleted from.property- the name of the property deleted.params- event parameters.
-
userCreated
Description copied from interface:UserEventListenerA user was created.- Specified by:
userCreatedin interfaceUserEventListener- Parameters:
user- the user.params- event parameters.
-
userDeleting
Description copied from interface:UserEventListenerA user is being deleted.- Specified by:
userDeletingin interfaceUserEventListener- Parameters:
user- the user.params- event parameters.
-
userModified
Description copied from interface:UserEventListenerA user's name, email, or an extended property was changed.- Specified by:
userModifiedin interfaceUserEventListener- Parameters:
user- the user.params- event parameters.
-
clusteringStateConsistencyReportForMucRoomsAndOccupant
public List<com.google.common.collect.Multimap<String,String>> clusteringStateConsistencyReportForMucRoomsAndOccupant()Verifies that caches and supporting structures around rooms and occupants are in a consistent state. Note that this operation can be costly in terms of resource usage. Use with caution in large / busy systems. The returned multi-map can contain up to four keys: info, fail, pass, data. All entry values are a human readable description of a checked characteristic. When the state is consistent, no 'fail' entries will be returned.- Returns:
- A consistency state report.
-
getRetireeCount
Gets the number of MUC room retirees.- Returns:
- the number of MUC room retirees.
-
getRetirees
public Collection<MUCRoomRetiree> getRetirees(String mucServiceName, int startIndex, int numResults) Gets the retirees for a MUC service.- Parameters:
mucServiceName- the name of the MUC service.startIndex- the index of the first result to return.numResults- the maximum number of results to return.- Returns:
- a collection of MUCRoomRetiree objects.
-
deleteRetiree
Deletes a retiree for a MUC room.- Parameters:
mucServiceName- the name of the MUC service.retireeName- the name of the retired room.
-