Why do you think that simply not creating multiple instances wouldn't work? Implement a ServiceManagerProvider
as a singleton and use only serviceManagerProvider.get()
for accessing the Service Manager.
Consider using Dependency Injection instead of the singleton (anti-)pattern:
@Singleton
public class ServiceManagerProvider implements Provider<ServiceManager> {
private final ServiceManager serviceManager = ...
@Overrride
public ServiceManager get() {
return serviceManager;
}
}
Here, you get a single instance per injector, which is exactly what you (should) want.