David goes back into time and remembers all of the military leaders that had been by his side from the time that he had fled from Saul to this present day. You will see even in vs.39 that Uriah the Hittite is mentioned. Remember, Uriah is the husband of Bathsheba, and yet David commanded him to the battle field in order to die. But he still makes the list of the most respected commanders in David's army.
We read at the beginning of this chapter that these are the last words of David. The listing of his commanders follows David's realization that the Spirit of the Lord was upon him to speak. We see this phrase used in other contexts as well. We hear Jesus say it when he is in his hometown synagogue of Nazareth before they kick him out. We see the prophet Isaiah use these words in Isaiah 61:1 which were the precursors to Jesus' words in Luke while he is in Nazareth.
As Presbyterians we do believe that on Sunday morning while the sermon is preached that in some way the Spirit of the Lord is upon the person who is preaching. Calvin called the Word of God not only the written Word but also the spoken Word. That is something that we don't often think about when we say that the Spirit of the Lord is upon me. It really is. But it also creates a responsibility that we may not often think about either.