Created
February 9, 2015 01:01
-
-
Save arthurtsang/403ebbacee3cf5497187 to your computer and use it in GitHub Desktop.
Ratpack 0.9.13 HandlerFactory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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