factory pattern impl using spring