Java - Implemented singleton pattern and dependency inversion principle