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​(@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
      • 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.