Comment by [email protected]:
pavankum: When your object's lifecycle isn't controlled by Guice (e.g.:
constructed by some other framework), but you want Guice to provide
additional dependencies, you can annotate the methods with @Inject and use
http://google-guice.googlecode.com/svn/tags/2.0/javadoc/com/google/inject/Injector.html#injectMembers(java.lang.Object)
injectmembers to ask guice to do the right thing there.
georgian: You shouldn't use Field Injection to inject final fields, you
should use constructor injection (as described here) to inject those final
fields. Field injection uses reflective magic, which the JVM doesn't
guarantee to be consistent across threads. However, using constructor
injection, the fields will be initialized normally as final fields and all
things are hunky dory.
For more information:
https://code.google.com/p/google-guice/wiki/MinimizeMutability
--
You received this message because you are subscribed to the Google Groups
"google-guice-dev" 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-dev.
For more options, visit https://groups.google.com/groups/opt_out.