I have heard a pearl is a disease of oysters.
Astonished by the statement, I searched a bit in deep  and I understood it is in real a protection mechanism of the oyster.
I know this defense mechanism is not unique in nature. E.g. humans can isolate foreign bodies (this happens with not-extractable bullets), as well as bees propolize foreign bodies if they can’t eject them.
How is the process, the ability of those organisms called?
How does it works? E.g. how organisms recognize foreign bodies other than other things?