private DiscoItemsProvider getServerItemsProvider() {
        return (name, node, senderJID) -> {
            if (node != null) {
                // Check if there is a provider for the requested node
                if (serverNodeProviders.get(node) != null) {
                    return serverNodeProviders.get(node).getItems(name, node, senderJID);
                }
                return null;
            }
            if (name == null) {
                return getServerItems().iterator();
            }
            else {
                // If addressed to user@domain, add items from UserItemsProviders to
                // the reply.
                if ( userItemsProviders.isEmpty()) {
                    // If we didn't find any UserItemsProviders, then answer a not found error
                    return null;
                }
                List<DiscoItem> answer = new ArrayList<>();
                for (UserItemsProvider itemsProvider : userItemsProviders ) {
                    // Check if we have items associated with the requested name
                    Iterator<Element> itemsItr = itemsProvider.getUserItems(name, senderJID);
                    if (itemsItr != null) {
                        // Add to the reply all the items provided by the UserItemsProvider
                        Element item;
                        while (itemsItr.hasNext()) {
                            item = itemsItr.next();
                            JID itemJid = new JID(item.attributeValue("jid"));
                            String itemName = item.attributeValue("name");
                            String itemNode = item.attributeValue("node");
                            String itemAction = item.attributeValue("action");
                            answer.add(new DiscoItem(itemJid, itemName, itemNode, itemAction));
                        }
                    }
                }
                return answer.iterator();
            }
        };
    }
When the local node is joining or leaving a cluster, {@link org.jivesoftware.util.cache.CacheFactory} will swap
the implementation used to instantiate caches. This causes the cache content to be 'reset': it will no longer
contain the data that's provided by the local node. This method restores data that's provided by the local node
in the cache. It is expected to be invoked right after joining ({@link #joinedCluster()} or leaving
({@link #leftCluster()} a cluster.
xmppserver/src/main/java/org/jivesoftware/openfire/disco/IQDiscoItemsHandler.java