Is there a way to define custom guice modules that are being picked up by atmosphere? I've found GuiceObjectFactory
and within it the private class AtmosphereModule
which does not help here.
The goal is to create guice provider bindings that can be used within an atmosphere application.
Thanks.
EDIT
There is not much more to add. As stated above my goal is to be able to define custom guice providers like
public class ObjectMapperProvider implements Provider<ObjectMapper> {
@Override
public ObjectMapper get() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return objectMapper;
}
}
I've followed the instructions from the official wiki on how to enable guice for DI. The question is now if there is a way to bind my custom provider (like in https://github.com/google/guice/wiki/ProviderBindings).
Ok, after looking at the code again the answer was quite obvious. You can create a injector yourself and add it to the serlvet context during the bootstrap process, it will then be picked up by atmosphere.
Config.Builder builder = new Config.Builder();
builder.resource(MyResource.class)
.port(8080)
.host("localhost")
.servletContextAttribute(Injector.class.getName(), Guice.createInjector(new CustomModule()))
.build();