Long story short, I've painted myself into a corner.
I was creating new modules and a new injector in some code each time a
service started.
The problem is I need to keep state by moving over singletons to the new
injector.
The problem is, some of these bindings are now changes and possibly
r
It sounds like you might want to use a childInjector pattern here.
Structure it something like this:
Global Injector binds everything that is truly a singleton in your project.
Then in the service(s) where you want to be able to set some state and
create a new object that references the global sta
This is my understanding as well...
However, my problem is that if I update the bindings , say by replacing one
with a new binding, then when I create the child injector it fails because
that binding was "already configured"
I replace bindings because during init various systems changes. For
I don't really understand how you aren't able to come up with a static set
of singletons that you want to be changing at each type of request.
The solution that you're trying to take sounds like a terribly hard one to
maintain. I advise you to look, seriously, into picking an alternative
dependenc
I'm aware that it's probably that I might need to refactor some things ...
However, I'm not sure the ideal way to have certain bindings, without
replacing them.
I have one binding, Caller, which is literally just a string explaining
what root service called an object.
This way I can trace thi
Do you ever run two tasks simultaneously? If not, perhaps you can create a
special provider that you can swap out the Caller where you're currently
considering creating a new injector.
import com.google.inject.Provider;
import java.util.concurrent.atomic.AtomicReference;
public class CallerProvid
You can also use custom scopes to change the returned instance depending
on your logic.
This may be a little cleaner than having too much logic in the providers.
On 10/19/2014 06:55 PM, Nate Bauernfeind wrote:
Do you ever run two tasks simultaneously? If not, perhaps you can
create a special p