An idiomatic solution is to create a CacheModule which you would ask clients of Cache to install.
Within the module you would: 1. create the binding for Cache 2. add any additional logic for your CacheMonitor Not knowing anything about either of these classes it's difficult to say what (2) would look like. If there is significant work to "initiate" the monitor then consider binding this as a Guava Service <https://github.com/google/guava/wiki/ServiceExplained> and using a ServiceManager to execute the logic within your server's main(). Fred On Thu, Sep 10, 2015 at 4:00 AM, Michiel ten Hagen < [email protected]> wrote: > All > > I have two classes, Cache and CacheMonitor. If someone binds the Cache I > want the CacheMonitor to be initiated. > > Currently I have the Cache class depend on the CacheMonitor but this > creates a unnecassary dependency, the Cache should be able to be used > without the CacheMonitor. > > Is there a way to specify that CacheMonitor should be loaded only if the > Cache is binded? > > Regards, > > Michiel > > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-guice/9a306fd5-1170-4496-af05-372fb09b05a2%40googlegroups.com > <https://groups.google.com/d/msgid/google-guice/9a306fd5-1170-4496-af05-372fb09b05a2%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 [email protected]. To post to this group, send email to [email protected]. 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/CAKCukAKWrSd7D1per8o-uAOkcD1TNURefduKV9gvj4k8C8E4EA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
