Trying to achieve desired result from spring-based factory pattern.