Solution: Build a Multi-Tenant Service Factory
Use chained object lookups to resolve a service from tenant scope, falling back to the default, without conditionals.
We'll cover the following...
We'll cover the following...
Solution explanation
Lines 1–21: We define a
serviceRegistryobject containing all tenant-specific and default service classes.The
acmetenant overrides only theLoggerservice withAcmeLogger.The
defaulttenant providesDefaultLoggerandDefaultAuth, used whenever a tenant doesn’t override a service.
Lines 23–29: The
createService(tenantId, serviceName)factory resolves and returns the ...