There are several ways to do it.
You can simply introduce logic in you modules which allows to configure
the bindings at startup time.
This is the simplest way but if the logic gets complexer it will also be
hard to understand.
You can group bindings which belong together into modules and then
include/exclude entire modules instead of single bindings.
Another possibility is to use the override feature of guice.
This allows you to define default bindings and then selectively replace
them with another binding.
The syntax is as follows:
Modules.override(defaultBindingModule).with(specialBindingModule);
In your first post you mentioned mocks. If you want to use guice within
unit tests then there are frameworks which ease the burden of the boiler
plate code.
For example jukito will create a new injector for every test class. It
also allows to easily define the bindings you want and it can create
bindings to mockito mocks for all missing bindings on the fly.
Hope this gets you started. If you need more hints you can always come
back to this place.
On 01/30/2015 11:17 PM, Igmar Palsenberg wrote:
Even tough you have a working solution now. It is not pretty and
from my perspective hard to understand what is actually happening.
So I am still wondering if you need to change the returned type
during runtime or if the returned type gets fixed during startup
of the application.
Because if it is fixed during startup there are cleaner ways of
achieving what you want.
It get's fixed during application startup. I prefer a solution that
gives me a constructed object from the injector, but the current
solution is also acceptable, yet not perfect : Some custom annotations
of this framework stop to functioning. The stacktrace makes no sense
(a known issue with Guice 3 and Java 8).
If you have a suggestion : Please let me know.
Regards,
Igmar
--
You received this message because you are subscribed to the Google
Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to google-guice+unsubscr...@googlegroups.com
<mailto:google-guice+unsubscr...@googlegroups.com>.
To post to this group, send email to google-guice@googlegroups.com
<mailto:google-guice@googlegroups.com>.
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-guice/8ce3e03e-bd85-4bba-8604-6027d9a93249%40googlegroups.com
<https://groups.google.com/d/msgid/google-guice/8ce3e03e-bd85-4bba-8604-6027d9a93249%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to google-guice+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-guice/54CE8A95.9080609%40gmx.ch.
For more options, visit https://groups.google.com/d/optout.