p***@mailarchiva.ru
2018-05-24 13:49:28 UTC
I have a class i wan't inject
For legacy code support it is like this.
injector.getInstance(Applications.class) working fine.
Regards,
Valentin.
For legacy code support it is like this.
@Singleton
public class Applications extends AbstractModule {
private Applications() {}
private static class ApplicationsLoader {
static final Applications INSTANCE = new Applications();
}
@Override protected void configure() {}
@Provides @Singleton
public Applications get() {
return ApplicationsLoader.INSTANCE;
}
public static Applications getApps() {
return ApplicationsLoader.INSTANCE;
}
}
On application startup , I create injector.public class Applications extends AbstractModule {
private Applications() {}
private static class ApplicationsLoader {
static final Applications INSTANCE = new Applications();
}
@Override protected void configure() {}
@Provides @Singleton
public Applications get() {
return ApplicationsLoader.INSTANCE;
}
public static Applications getApps() {
return ApplicationsLoader.INSTANCE;
}
}
public void startup() throws Exception {
initLogging();
Injector injector = Guice.createInjector(Stage.PRODUCTION,
Applications.getApps());
}
but some while after, when I need Applications.class i always get a nullinitLogging();
Injector injector = Guice.createInjector(Stage.PRODUCTION,
Applications.getApps());
}
public class Blob {
@Inject private Applications applications;
.....
}
Any suggestions how to share Applications.class singleton?@Inject private Applications applications;
.....
}
injector.getInstance(Applications.class) working fine.
Regards,
Valentin.
--
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+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/d02fdaa7-59e9-4b4e-8f47-4a43a04d53db%40googlegroups.com.
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+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/d02fdaa7-59e9-4b4e-8f47-4a43a04d53db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.