A solvable model of a self-gravitating system