+1
I'd like to hear some opinions about this too.

My current approach:
- create a (small) injector, only containing the injectable configuration
- use this injector to inject members of the actual application modules
- once the modules are injected create the "real" injector and use that

Started with parent/child injectors but that started to be problematic,
since every class participating in AOP must be bound explicitly (which is
something of a bug IMHO) Refactoring was not feasible, but the double
injector solution turned out to be just fine for our use case.

Is there a better solution ?

--
L


--
L


On Wed, Jul 10, 2013 at 10:16 AM, Andrew Z <[email protected]> wrote:

> Having been using Guice for a while I still cannot decide what is the best
> way to pass properties to Guice modules.
>
> One of examples that really bothers me is
> "com.google.inject.persist.jpa.JpaPersistModule" in guice-persist that has
> a "properties" setter method. This kind of design requires me to have an
> exact instance of JPA connection properties at the time of module creation.
> Doesn't this violate the whole idea of dependency injection? These
> properties can come from external sources and be bound by another module -
> this makes perfect sense to me. Surely one can have a workaround (with
> parent injectors for example), but the question remains - why such design
> decision was made in the first place? Maybe I'm missing something
> important? Is there any "best practice" or "recommended" approach for such
> cases?
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/google-guice.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to