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
-
-
Constructor Summary
Constructors Constructor Description MultiUserChatManager()
Creates a new MultiUserChatManager instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<com.google.common.collect.Multimap<String,String>>
clusteringStateConsistencyReportForMucRoomsAndOccupant()
Verifies that caches and supporting structures around rooms and occupants are in a consistent state.MultiUserChatServiceImpl
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.MultiUserChatService
getMultiUserChatService(long serviceID)
Retrieves a MultiUserChatService instance specified by it's service ID.MultiUserChatService
getMultiUserChatService(String subdomain)
Retrieves a MultiUserChatService instance specified by it's subdomain of the server's primary domain.MultiUserChatService
getMultiUserChatService(org.xmpp.packet.JID jid)
Retrieves a MultiUserChatService instance specified by any JID that refers to it.Long
getMultiUserChatServiceID(String subdomain)
Retrieves the database ID of a MUC service by subdomain.List<MultiUserChatService>
getMultiUserChatServices()
Retrieves all of the MultiUserChatServices managed and configured for this server, sorted by subdomain.int
getMultiUserChatServicesCount()
Retrieves the number of MultiUserChatServices that are configured for this server.String
getMultiUserChatSubdomain(long serviceID)
Retrieves the subdomain of a specified service ID.int
getServicesCount(boolean includePrivate)
Returns the number of registered MultiUserChatServices.boolean
isServiceRegistered(String subdomain)
Returns true if a MUC service is configured/exists for a given subdomain.void
propertyDeleted(String service, String property, Map<String,Object> params)
A property was deleted.void
propertySet(String service, String property, Map<String,Object> params)
A property was set.void
refreshService(String subdomain)
Updates the in-memory representation of a previously loaded services from the database.void
registerMultiUserChatService(MultiUserChatService service)
Registers a new MultiUserChatService implementation to the manager.void
registerMultiUserChatService(MultiUserChatService service, boolean allNodes)
Registers a new MultiUserChatService implementation to the manager.void
removeMultiUserChatService(long serviceID)
Deletes a configured MultiUserChatService by ID, and shuts it down.void
removeMultiUserChatService(String subdomain)
Deletes a configured MultiUserChatService by subdomain, and shuts it down.void
start()
Called when manager starts up, to initialize things.void
stop()
Called when manager is stopped, to clean things up.void
unregisterMultiUserChatService(String subdomain)
Unregisters a MultiUserChatService from the manager.void
unregisterMultiUserChatService(String subdomain, boolean allNodes)
Unregisters a MultiUserChatService from the manager.void
updateMultiUserChatService(long serviceID, String subdomain, String description)
Updates the configuration of a MUC service.void
updateMultiUserChatService(String currentSubdomain, String newSubdomain, String description)
Updates the configuration of a MUC service.void
userCreated(User user, Map<String,Object> params)
A user was created.void
userDeleting(User user, Map<String,Object> params)
A user is being deleted.void
userModified(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, initialize
-
-
-
-
Method Detail
-
start
public void start()
Called when manager starts up, to initialize things.- Specified by:
start
in interfaceModule
- Overrides:
start
in classBasicModule
-
stop
public void stop()
Called when manager is stopped, to clean things up.- Specified by:
stop
in interfaceModule
- Overrides:
stop
in classBasicModule
-
registerMultiUserChatService
public void registerMultiUserChatService(@Nonnull MultiUserChatService service)
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:
createMultiUserChatService(String, String, boolean)
-
registerMultiUserChatService
public void registerMultiUserChatService(@Nonnull MultiUserChatService service, boolean allNodes)
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:
createMultiUserChatService(String, String, boolean)
-
unregisterMultiUserChatService
public void unregisterMultiUserChatService(@Nonnull String subdomain)
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:
removeMultiUserChatService(String)
-
unregisterMultiUserChatService
public void unregisterMultiUserChatService(@Nonnull String subdomain, boolean allNodes)
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:
removeMultiUserChatService(String)
-
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
public void removeMultiUserChatService(@Nonnull String subdomain) throws NotFoundException
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
public void removeMultiUserChatService(long serviceID) throws NotFoundException
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
@Nullable public MultiUserChatService getMultiUserChatService(long serviceID)
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
@Nullable public MultiUserChatService getMultiUserChatService(@Nonnull String subdomain)
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
@Nullable public MultiUserChatService getMultiUserChatService(@Nonnull org.xmpp.packet.JID jid)
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
@Nonnull public List<MultiUserChatService> 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
public boolean isServiceRegistered(@Nullable String subdomain)
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
public Long getMultiUserChatServiceID(@Nonnull String subdomain)
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
@Nullable public String getMultiUserChatSubdomain(long serviceID)
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
public void refreshService(String subdomain)
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
public void propertySet(String service, String property, Map<String,Object> params)
Description copied from interface:MUCServicePropertyEventListener
A property was set. The parameter mapparams
will contain the the value of the property under the keyvalue
.- Specified by:
propertySet
in interfaceMUCServicePropertyEventListener
- Parameters:
service
- the subdomain of the service the property was set on.property
- the name of the property.params
- event parameters.
-
propertyDeleted
public void propertyDeleted(String service, String property, Map<String,Object> params)
Description copied from interface:MUCServicePropertyEventListener
A property was deleted.- Specified by:
propertyDeleted
in interfaceMUCServicePropertyEventListener
- Parameters:
service
- the subdomain of the service the property was deleted from.property
- the name of the property deleted.params
- event parameters.
-
userCreated
public void userCreated(User user, Map<String,Object> params)
Description copied from interface:UserEventListener
A user was created.- Specified by:
userCreated
in interfaceUserEventListener
- Parameters:
user
- the user.params
- event parameters.
-
userDeleting
public void userDeleting(User user, Map<String,Object> params)
Description copied from interface:UserEventListener
A user is being deleted.- Specified by:
userDeleting
in interfaceUserEventListener
- Parameters:
user
- the user.params
- event parameters.
-
userModified
public void userModified(User user, Map<String,Object> params)
Description copied from interface:UserEventListener
A user's name, email, or an extended property was changed.- Specified by:
userModified
in 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.
-
-