@Override
    public List<JID> getRoutes(JID route, JID requester) {

        List<JID> jids = new ArrayList<>();
        if (serverName.equals(route.getDomain())) {

            // Address belongs to local user
            if (route.getResource() != null) {
                // Address is a full JID of a user
                ClientRoute clientRoute = getClientRouteForLocalUser(route);
                if (clientRoute != null &&
                        (clientRoute.isAvailable() || presenceUpdateHandler.hasDirectPresence(route, requester))) {
                    jids.add(route);
                }
            }
            else {
                // Address is a bare JID so return all AVAILABLE resources of user
                final Map<String, ClientRoute> clientRoutes = new HashMap<>();
                final Lock lock = usersSessionsCache.getLock(route.toBareJID());
                lock.lock(); // temporarily block new sessions for this JID
                try {
                    Set<String> sessionFullJids = usersSessionsCache.get(route.toBareJID());
                    if (sessionFullJids != null) {
                        for (String sessionFullJid : sessionFullJids) {
                            ClientRoute clientRoute = usersCache.get(sessionFullJid);
                            if (clientRoute != null) {
                                clientRoutes.put(sessionFullJid, clientRoute);
                            }
                        }
                    }
                }
                finally {
                    lock.unlock();
                }

                // Filter routes to only those that are accessible to the requester.
                jids.addAll(clientRoutes.entrySet().stream()
                    .filter(entry -> (entry.getValue().isAvailable() || presenceUpdateHandler.hasDirectPresence(new JID(entry.getKey()), requester)))
                    .map(entry -> new JID(entry.getKey()))
                    .collect(Collectors.toList()));
            }
        }
        else if (route.getDomain().contains(serverName)) {
            // Packet sent to component hosted in this server
            if (componentsCache.containsKey(route.getDomain())) {
                jids.add(new JID(route.getDomain()));
            }
        }
        else {
            // Packet sent to remote server
            jids.add(route);
        }
        return jids;
    }
Gets the non-negative session from a minimal priority.

@param sessions The sessions.
@param min      The minimal priority.
@return The filtered sessions.
xmppserver/src/main/java/org/jivesoftware/openfire/spi/RoutingTableImpl.java