Class MultiUserChatManager
- java.lang.Object
-
- org.jivesoftware.openfire.container.BasicModule
-
- org.jivesoftware.openfire.muc.MultiUserChatManager
-
- All Implemented Interfaces:
ClusterEventListener
,Module
,UserEventListener
,MUCServicePropertyEventListener
public class MultiUserChatManager extends BasicModule implements ClusterEventListener, 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 MultiUserChatServiceImpl
createMultiUserChatService(String subdomain, String description, Boolean isHidden)
Creates a new MUC service and registers it with the manager, 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 ID of MUC service by subdomain.List<MultiUserChatService>
getMultiUserChatServices()
Retrieves all of the MultiUserChatServices managed and configured for this server, sorted by subdomain.Integer
getMultiUserChatServicesCount()
Retrieves the number of MultiUserChatServices that are configured for this server.String
getMultiUserChatSubdomain(Long serviceID)
Retrieves the subdomain of a specified service ID.Integer
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
joinedCluster()
Notification event indicating that this JVM is now part of a cluster.void
joinedCluster(byte[] nodeID)
Notification event indicating that another JVM is now part of a cluster.void
leftCluster()
Notification event indicating that this JVM is no longer part of the cluster.void
leftCluster(byte[] nodeID)
Notification event indicating that another JVM is no longer part of the cluster.void
markedAsSeniorClusterMember()
Notification event indicating that this JVM is now the senior cluster member.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
registerMultiUserChatService(MultiUserChatService service)
Registers a new MultiUserChatService implementation to the manager.void
registerMultiUserChatService(MultiUserChatService service, boolean allNodes)
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)
void
updateMultiUserChatService(Long serviceID, String subdomain, String description)
Updates the configuration of a MUC service.void
updateMultiUserChatService(String cursubdomain, 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(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, implementating MultiUserChatService. It is also used internally to register services from the database. Triggers the service to start up.- Parameters:
service
- The MultiUserChatService to be registered.
-
registerMultiUserChatService
public void registerMultiUserChatService(MultiUserChatService service, boolean allNodes)
-
unregisterMultiUserChatService
public void unregisterMultiUserChatService(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.- Parameters:
subdomain
- The subdomain of the service to be unregistered.
-
unregisterMultiUserChatService
public void unregisterMultiUserChatService(String subdomain, boolean allNodes)
-
getServicesCount
public Integer 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
public MultiUserChatServiceImpl createMultiUserChatService(String subdomain, String description, Boolean isHidden) throws AlreadyExistsException
Creates a new MUC service and registers it with the manager, 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, String subdomain, 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(String cursubdomain, String newsubdomain, 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:
cursubdomain
- 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(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
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
public MultiUserChatService getMultiUserChatService(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
public MultiUserChatService getMultiUserChatService(org.xmpp.packet.JID jid)
Retrieves a MultiUserChatService instance specified by any JID that refers to it. In other words, it can be a hostname for the service, a room JID, or even the JID of a occupant of the room. Basically it takes the hostname part of the JID, strips off the server hostname 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
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 Integer getMultiUserChatServicesCount()
Retrieves the number of MultiUserChatServices that are configured for this server.- Returns:
- The number of registered MultiUserChatServices.
-
isServiceRegistered
public boolean isServiceRegistered(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(String subdomain)
Retrieves ID of 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
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.
-
joinedCluster
public void joinedCluster()
Description copied from interface:ClusterEventListener
Notification event indicating that this JVM is now part of a cluster. At this point theXMPPServer.getNodeID()
holds the new nodeID value.When joining the cluster as the senior cluster member the
ClusterEventListener.markedAsSeniorClusterMember()
event will be sent right after this event.At this point the CacheFactory holds clustered caches. That means that modifications to the caches will be reflected in the cluster. The clustered caches were just obtained from the cluster and no local cached data was automatically moved.
- Specified by:
joinedCluster
in interfaceClusterEventListener
-
joinedCluster
public void joinedCluster(byte[] nodeID)
Description copied from interface:ClusterEventListener
Notification event indicating that another JVM is now part of a cluster.At this point the CacheFactory of the new node holds clustered caches. That means that modifications to the caches of this JVM will be reflected in the cluster and in particular in the new node.
- Specified by:
joinedCluster
in interfaceClusterEventListener
- Parameters:
nodeID
- ID of the node that joined the cluster.
-
leftCluster
public void leftCluster()
Description copied from interface:ClusterEventListener
Notification event indicating that this JVM is no longer part of the cluster. This could happen when disabling clustering support, removing the enterprise plugin that provides clustering support or connection to cluster got lost.Moreover, if we were in a "split brain" scenario (ie. separated cluster islands) and the island were this JVM belonged was marked as "old" then all nodes of that island will get the
left cluster event
andjoined cluster events
. That means that caches will be reset and thus will need to be repopulated again with fresh data from this JVM. This also includes the case where this JVM was the senior cluster member and when the islands met again then this JVM stopped being the senior member.At this point the CacheFactory holds local caches. That means that modifications to the caches will only affect this JVM.
- Specified by:
leftCluster
in interfaceClusterEventListener
-
leftCluster
public void leftCluster(byte[] nodeID)
Description copied from interface:ClusterEventListener
Notification event indicating that another JVM is no longer part of the cluster. This could happen when disabling clustering support, removing the enterprise plugin that provides clustering support or connection to cluster got lost.Moreover, if we were in a "split brain" scenario (ie. separated cluster islands) and the island were the other JVM belonged was marked as "old" then all nodes of that island will get the
left cluster event
andjoined cluster events
. That means that caches will be reset and thus will need to be repopulated again with fresh data from this JVM. This also includes the case where the other JVM was the senior cluster member and when the islands met again then the other JVM stopped being the senior member.At this point the CacheFactory of the leaving node holds local caches. That means that modifications to the caches of this JVM will not affect the leaving node but other cluster members.
- Specified by:
leftCluster
in interfaceClusterEventListener
- Parameters:
nodeID
- ID of the node that is left the cluster.
-
markedAsSeniorClusterMember
public void markedAsSeniorClusterMember()
Description copied from interface:ClusterEventListener
Notification event indicating that this JVM is now the senior cluster member. This could either happen when initially joining the cluster or when the senior cluster member node left the cluster and this JVM was marked as the new senior cluster member.Moreover, in the case of a "split brain" scenario (ie. separated cluster islands) each island will have its own senior cluster member. However, when the islands meet again there could only be one senior cluster member so one of the senior cluster members will stop playing that role. When that happens the JVM no longer playing that role will receive the
ClusterEventListener.leftCluster()
andClusterEventListener.joinedCluster()
events.- Specified by:
markedAsSeniorClusterMember
in interfaceClusterEventListener
-
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.
-
-