@Override
    public Collection<String> getSharedGroupNames() {
        HashSet<String> groupNames;
        synchronized (sharedGroupMetaCache) {
            groupNames = getSharedGroupsFromCache();
            if (groupNames != null) {
                return groupNames;
            }

            groupNames = new HashSet<>();
            Connection con = null;
            PreparedStatement pstmt = null;
            ResultSet rs = null;
            try {
                con = DbConnectionManager.getConnection();
                pstmt = con.prepareStatement(LOAD_SHARED_GROUPS);
                rs = pstmt.executeQuery();
                while (rs.next()) {
                    groupNames.add(rs.getString(1));
                }
                saveSharedGroupsInCache(groupNames);
                saveHasSharedGroupsInCache(!groupNames.isEmpty());
            } catch (SQLException sqle) {
                Log.error(sqle.getMessage(), sqle);
            } finally {
                DbConnectionManager.closeConnection(rs, pstmt, con);
            }
        }
        return groupNames;
    }
Returns the name of the groups that are shared groups.

@return the name of the groups that are shared groups.
xmppserver/src/main/java/org/jivesoftware/openfire/group/AbstractGroupProvider.java