2017-03-31 02:40:45 +05:30
|
|
|
package com.baeldung.guice;
|
|
|
|
|
|
|
|
import com.baeldung.guice.config.DependencyModule;
|
|
|
|
import com.baeldung.guice.service.DataPumpService;
|
2017-04-02 01:17:23 +05:30
|
|
|
import com.baeldung.guice.service.ServiceFactory;
|
2017-03-31 02:40:45 +05:30
|
|
|
import com.baeldung.guice.service.impl.DataPumpServiceImpl;
|
|
|
|
|
|
|
|
import ratpack.guice.Guice;
|
|
|
|
import ratpack.server.RatpackServer;
|
|
|
|
|
|
|
|
public class Application {
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
|
|
|
|
RatpackServer
|
|
|
|
.start(server -> server.registry(Guice.registry(bindings -> bindings.module(DependencyModule.class)))
|
|
|
|
.handlers(chain -> chain.get("randomString", ctx -> {
|
|
|
|
DataPumpService dataPumpService = ctx.get(DataPumpService.class);
|
2017-04-02 01:17:23 +05:30
|
|
|
ctx.render(dataPumpService.generate());
|
|
|
|
}).get("factory", ctx -> ctx.render(ServiceFactory.getInstance().generate()))));
|
2017-03-31 02:40:45 +05:30
|
|
|
|
|
|
|
// RatpackServer.start(server -> server
|
|
|
|
// .registry(Guice
|
|
|
|
// .registry(bindings -> bindings.bindInstance(DataPumpService.class, new DataPumpServiceImpl())))
|
|
|
|
// .handlers(chain -> chain.get("randomString", ctx -> {
|
|
|
|
// DataPumpService dataPumpService = ctx.get(DataPumpService.class);
|
|
|
|
// ctx.render(dataPumpService.generate());
|
2017-04-02 01:17:23 +05:30
|
|
|
// }).get("factory", ctx -> ctx.render(ServiceFactory.getInstance().generate()))));
|
2017-03-31 02:40:45 +05:30
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-04-02 01:17:23 +05:30
|
|
|
}
|