Abhinab Kanrar 15a4a23099 adding factory instance example (#1552)
* rest with spark java

* 4

* Update Application.java

* indentation changes

* spring @requestmapping shortcuts

* removing spring requestmapping and pushing spring-mvc-java

* Joining/Splitting Strings with Java and Stream API

* adding more join/split functionality

* changing package name

* testcase change

* adding webutils

* adding testcase for WebUtils and ServletRequestUtils

* adding testcase

* spring-security-stormpath

* adding ratpack module

* adding pom.xml

* adding following modules with updated testcase : DB, Filter, Json

* adding spring-boot custom banner tutorial

* changing banner format in plain text

* Delete banner.txt~

* Delete b.txt~

* CORS in JAX-RS

* ratpack with google guice

* adding factory instance example
2017-04-01 21:47:23 +02:00

32 lines
1.2 KiB
Java

package com.baeldung.guice;
import com.baeldung.guice.config.DependencyModule;
import com.baeldung.guice.service.DataPumpService;
import com.baeldung.guice.service.ServiceFactory;
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);
ctx.render(dataPumpService.generate());
}).get("factory", ctx -> ctx.render(ServiceFactory.getInstance().generate()))));
// 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());
// }).get("factory", ctx -> ctx.render(ServiceFactory.getInstance().generate()))));
}
}