If you want Guice singletons to start at application start, you need to bind them with asEagerSingleton() otherwise they will start on first usage. Example code::
package com.myapp.myguice;
import com.google.inject.AbstractModule;
public class ApplicationModule extends AbstractModule {
@Override
protected void configure() {
bind(MySingleton.class).asEagerSingleton();
}
}
The singleton could look like this:
package com.myapp.myguice;
import com.google.inject.Inject;
public class MySingleton {
private String myValue;
@Inject
MySingleton() {
myValue = UnkownAPI.getMyValue();
}
public String getMyValue() {
return myValue;
}
}
Make sure you have both Guice and Stripes-Guice jar files added to your project/classpath and that you have configured your web.xml like this:
<context-param>
<param-name>Guice.Modules</param-name>
<param-value>com.myapp.myguice.ApplicationModule</param-value>
</context-param>
<listener>
<listener-class>
com.silvermindsoftware.stripes.integration.guice.GuiceContextListener
</listener-class>
</listener>
If you need to inject the singleton into an actionBean, then please read: Guice Managed Action Beans.