Refactor ComponentFactory.php

Change-Id: I0dfc0af1a4560017d8025d360c12cce49adea2be