Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Injecting a previously injected instance #20

Closed
kristoferjoseph opened this issue Feb 27, 2010 · 3 comments
Closed

Injecting a previously injected instance #20

kristoferjoseph opened this issue Feb 27, 2010 · 3 comments

Comments

@kristoferjoseph
Copy link

This might be more of a use case than a bug.
I have a bootstrap loader app with it's own context that prepares a service class by injecting all of it's dependencies.
I then load a sub-app with it's own context and wanted to use injector.mapValue(IMyInterface, myInstance) to inject it around the sub application. This fails because the injector tries to inject the dependencies that have already been injected by the bootstrap into the instance supplied. This seems to be working exactly as intended. Which makes sense. I would like a flag to be able to tell the injector that the injections have already been supplied to the instance and to just map the value.

I have gotten around this by just using the instance passed from the boot strap loader in a service locator style approach; No injections, but this changes the way I test it.

Ideas?

@tschneidereit
Copy link
Owner

Thanks for the explanation. That's an issue that Shaun and others have already brought up. By now, I think it really is a bug - specifically, the fact that the injector ever tries injects into an object that mapped with mapValue is a bug.
As much as I'm willing to fix this problem, I fear that it might cause subtle, very hard to debug changes in runtime behavior for some people.

I'll once again bring this to the attention of the Robotlegs list, in the hope of people agreeing that the change is ok and can be implemented in a point release.

@tschneidereit
Copy link
Owner

Changed behavior of mapValue: Mapped values aren't injected into once they are themselves injected into another instance anymore

Closed by c051fe9

@kristoferjoseph
Copy link
Author

Great news. Thanks for the fix. I will roll it in immediately.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants