Introduced repository layer.

Added repositories and moved persistence logic there. Also replaced
Servlets with Spring components.