The book's "derivation" is unusual. Usually, Plank's energy distribution is derived by considering the energy in a large cavity, which tells you about the energy that would be emitted through a small hole in the cavity. That energy has the blackbody spectrum. I think the book is trying to whitewash away a bunch of details by talking about "oscillators present on the walls of the cavity" instead of talking about where the real oscillators are. However, the derivation only really requires the fact that there are oscillators, so the results from the book's derivation is still correct. Moreover, the derivation using a cavity is only meant to be a problem that produces the same results as a real blackbody surface; the cavity is not itself a blackbody surface. So, in that sense, the book's derivation is just as good.
Usually the "oscillators" in a black-body cavity are standing waves (modes) within the cavity. These standing waves are effectively quantum simple harmonic oscillators because of their energy levels. Mode $i$ with frequency $f_i$ can have $n$ photons in it, resulting in the energy of the $m$th mode being $E_i = h f_i \left(n+\frac{1}{2}\right)$. (The $\frac{1}{2}$ doesn't much matter because that energy can't be radiated away.) That is exactly the energy spectrum of a simple harmonic oscillator, so it makes sense to refer to these standing waves as oscillators.
Unlike what the book says, there are discrete modes in a cavity even in classical mechanics. For a 1D cavity of length $L$, the states have discrete wavelengths $\lambda_i = \frac{L}{n_i}$. (Think about the discrete modes of standing waves on a string -- an example often used in introductory physics courses.) However, in deriving the blackbody spectrum, usually the size of the cavity is taken to be large, in which case the energy of the modes become closely spaced so that it makes sense to think of a continuum of states.