Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Spring Fu on GraalVM

Spring Fu on GraalVM

Kotlin Developers Meetup (https://kotlin.connpass.com/event/90679/) で発表したスライドです

Taro Nagasawa

June 27, 2018
Tweet

More Decks by Taro Nagasawa

Other Decks in Programming

Transcript

  1. GraalVM • Platform developed by Oracle • Polyglot VM ◦

    JVM-based languages (Java, Scala, Kotlin! …) ◦ JavaScript, Python, Ruby, R ◦ LLVM-based languages (C, C++, ...) • AOT Compiler ◦ Java code is compiled to native code • Community Edition / Enterprise Edition
  2. $ docker run --rm findepi/graalvm java -version openjdk version "1.8.0_171"

    OpenJDK Runtime Environment (build 1.8.0_171-11) GraalVM 1.0.0-rc2 (build25.71-b01-internal-jvmci -0.43, mixed mode)
  3. Familiar Spring Boot application @SpringBootApplication class DemoApplication fun main(args: Array<String>)

    { runApplication<DemoApplication>(*args) } @Service class HelloService { fun hello(): String = "Hello, world!" } @RestController class HelloController(val helloService: HelloService) { @GetMapping("") fun hello(): String = helloService.hello() }
  4. Hello, Spring Fu class HelloService { fun hello(): String =

    "Hello, world!" } class HelloController(val helloService: HelloService) { fun hello(request: ServerRequest): Mono<ServerResponse> { val hello = helloService.hello() return ServerResponse.ok().syncBody(hello) } }
  5. Hello, Spring Fu fun main(args: Array<String>) = application { bean<HelloService>()

    bean<HelloController>() webflux { server(netty(8080)) { routes { this.context = [email protected] val helloController = ref<HelloController>() GET("/", helloController::hello) } } } }.run(await = true)
  6. Hello, Spring Fu fun main(args: Array<String>) = application { bean<HelloService>()

    bean<HelloController>() webflux { server(netty(8080)) { routes { this.context = [email protected] val helloController = ref<HelloController>() GET("/", helloController::hello) } } } }.run(await = true)