use spring framework to refactory this application.