Class MultiUserChatManager

    • Constructor Detail

      • MultiUserChatManager

        public MultiUserChatManager()
        Creates a new MultiUserChatManager instance.
    • Method Detail

      • start

        public void start()
        Called when manager starts up, to initialize things.
        Specified by:
        start in interface Module
        Overrides:
        start in class BasicModule
      • stop

        public void stop()
        Called when manager is stopped, to clean things up.
        Specified by:
        stop in interface Module
        Overrides:
        stop in class BasicModule
      • 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 the XMPPServer.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 interface ClusterEventListener
      • 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 interface ClusterEventListener
        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 and joined 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 interface ClusterEventListener
      • 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 and joined 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 interface ClusterEventListener
        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() and ClusterEventListener.joinedCluster() events.

        Specified by:
        markedAsSeniorClusterMember in interface ClusterEventListener