I have a singleton scoped class that needs access to a filename string that is only determined downstream in a narrower scope. The usual solution is to inject a provider into the singleton scoped class and call provider.get() when it’s actually time to get the narrower scoped object. In this case, however, the narrower scoped object is simply a string, which means I need to use a binding annotation to differentiate it from every other string. Two questions:
Can a binding annotation be applied to an injected provider just like any other injected object?
Do you agree that it’s better to just inject the filename string, which is all the singleton scoped class really needs to know about, or should I just take the simpler approach, which is to inject the object within which the filename string is contained (and accessible via a getter)? What I don’t like about the latter approach is that the singleton class has access to all kinds of stuff it doesn’t care about, which seems like it might make some folks weep.
Thanks!