How to properly control The Wither in order to break only certain blocks?

I'd like to make a Cobblestone automatic farm that uses The Wither as the breaker, but it seems to me that it could easily get out.
What I thought about already (but I don't think it's enough for the whole mecanism): Enclose it in an Obsidian box, put a Glass Block in the wall that connects to another room in which there is a mob, and fill the room with Water, in order to absorb the blasts, but also serve as an ingredient for Cobblestone, and a few Lava. However, I guess that because of The Withers melee attack, that happens after taking damage (drowning, in this case), it might bust out.
So, how do I prevent The Wither from breaking the room's walls, and only make it break the Cobblestone that forms?


Solution 1:

There are tutorials on devices called Wither Cages on the Official Minecraft wiki, incolving several fundamental properties of the Wither's attacks, including:

Head targets The Main Head and Side Head are the two targets that the Wither attacks. This can be controlled by the use of Snow Golems in a protected area (e.g. in front of the Wither behind enchantment tables, or below the Wither throilugh Iron Bars). The Wither must be able to "see" the targets but not be able to destroy them.

Explosive Properties The Wither's movement thriugh the world is often seen to destroy all blocks except bedrock, but immobilising it in blast-resistant blocks (eg Iron Blocks or Obsidian) will often keep it contained,especially if some part of it is covered in water.

I will provide a link to the article at some date, but I am currently busy with other projects.