Skip to content

Instantly share code, notes, and snippets.

@arthurtsang
Created February 9, 2015 01:01
Show Gist options
  • Save arthurtsang/403ebbacee3cf5497187 to your computer and use it in GitHub Desktop.
Save arthurtsang/403ebbacee3cf5497187 to your computer and use it in GitHub Desktop.
Ratpack 0.9.13 HandlerFactory
public class HandlerFactory implements ratpack.launch.HandlerFactory{
private final static Logger logger = LoggerFactory.getLogger(HandlerFactory.class);
private ConfigData configData;
public HandlerFactory(ConfigData configData) {
this.configData = configData;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Handler create(Registry registry) throws Exception {
return Guice.builder(registry)
.bindings(bindingsSpec -> {
bindingsSpec.add(new JacksonModule(), config -> {
config.prettyPrint(false);
config.modules(new HalModule());
});
bindingsSpec.add(new HystrixModule().sse());
bindingsSpec.bindInstance(IdolConfig.class, configData.get("/idol", IdolConfig.class));
bindingsSpec.bindInstance(Service.class, new Service() {
@Override
public void onStart(StartEvent event) throws Exception {
RxRatpack.initialize();
}
});
}).build(chain -> {
...
}).handler("hystrix.stream", new HystrixMetricsEventStreamHandler());
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment