add service_factory

Not finished.