Added service registration.

Added a function called service which does a one-time invocation of
a service creation function. This will resolve all service
dependencies and ensure the service is a fully functional singleton
service.