0

This is regarding to the Play framework 2.5.x

I have few Guice modules which extended by the AbstractModule and they are added as bindings to the GuiceApplicationBuilder method like below.

@Override
public GuiceApplicationBuilder builder(ApplicationLoader.Context context) {
    return initialBuilder
            .in(context.environment())
            .bindings(new LoggerModule())
            .bindings(new BaseConnectionModule(configuration))
            .bindings(new CacheModule(configuration))
            .bindings(new DaoModule())
            ....

One of my module (say CacheModule) declared private variables in that which are also Guice injected to be used in that class(inside Guice @Provides methods). The bindings for those variable are done in one of a GuiceModule (say BaseConnectionModule) which bound prior to the current module as mentioned in above code.

My question is, when the application get started, such variables declared as private in the CacheModule are not get instantiated.

Can someone please answer to this?

udayanga
  • 411
  • 4
  • 12
  • Can you show relevant code from `CacheModule`? – ketan vijayvargiya Sep 11 '17 at 16:55
  • Did you mean injected private variables or method (with @Provides) where used them? – udayanga Sep 11 '17 at 18:05
  • [As I wrote here](https://stackoverflow.com/q/15989991/1426891), there are very limited ways that you can access injected values from within a Guice module. It is very atypical to use @Inject fields in a Module, unless you are getting a Guice Module from a different injector. I will second Ketan above that it is important for us to see CacheModule so we can give you more specific advice or alternatives. – Jeff Bowman Sep 14 '17 at 01:54

0 Answers0