SlideShare a Scribd company logo
1 of 42
Download to read offline
Kotlin+MicroProfile: Teaching 20 year old tricks to
a new language
V´ıctor Orozco
19 de Julho de 2019
@tuxtor
1
Java - Morrendo desde 1995
2
¿Microsservi¸cos?
Microsservi¸cos
Figura 1: Microservicios
3
Microsservi¸cos - Java
• DIY - Jooby, Javalin, Micronaut, Spark, Vert.x, Helidon SE
• Enterprise - Spring Boot, Microprofile (implementa¸c˜oes)
4
Microsservi¸cos - Kotlin
• DIY - Jooby, Javalin, Micronaut, Spark, Vert.x, Helidon SE,
Ktor
• Enterprise - Spring Boot, Microprofile (implementa¸c˜oes)
5
Eclipse MicroProfile
Eclipse MicroProfile
Figura 2: Credito: Reza Rahman
6
Eclipse MicroProfile
7
Eclipse MicroProfile
8
Eclipse MicroProfile
9
Eclipse MicroProfile - implementa¸c˜oes
Bibliotecas
• SmallRye (Red Hat)
• Hammock
• Apache Geronimo
• Fujitsu Launcher
JEAS - Fat Jar, Uber Jar
• Dropwizard
• KumuluzEE
• Helidon (Oracle)
• Open Liberty (IBM)
• Apache Meecrowave
• Thorntail (Red Hat)
• Quarkus (Red Hat)
• Payara Micro
10
Eclipse MicroProfile - Implementaciones
Micro server - Thin War
• Payara Micro
• TomEE JAX-RS
Full server
• Payara Application Server
• JBoss Application Server / Wildfly Application Server
• WebSphere Liberty (IBM)
https://wiki.eclipse.org/MicroProfile/Implementation
11
Eclipse MicroProfile - 1, 2, 3 com Kotlin
1. Projeto Java Maven (Gradle)
2. Dependencia no MicroProfile (JavaEE, Arquillian, JUnit, . . .)
3. Plugin Maven (maven-compiler-plugin)
4. Plugin Kotlin (kotlin-maven-plugin)
5. Desenvolver em Kotlin e ser uma pessoa feliz
12
Eclipse MicroProfile + Kotlin + Maven
Eclipse MicroProfile com Payara 5
<dependency >
<groupId >org.eclipse.microprofile </ groupId >
<artifactId >microprofile </ artifactId >
<type >pom </type >
<version >2.0.1 </ version >
<scope >provided </scope >
</dependency >
13
Kotlin en Maven - Dependˆencias
<dependency >
<groupId >org.jetbrains.kotlin </groupId >
<artifactId >kotlin -stdlib -jdk8 </artifactId >
<version >${ kotlin.version}</version >
</dependency >
14
Kotlin en Maven - maven-compiler-plugin
<execution >
<id >default -compile </id >
<phase >none </phase >
</execution >
<execution >
<id >default -testCompile </id >
<phase >none </phase >
</execution >
<execution >
<id >java -compile </id >
<phase >compile </phase >
<goals > <goal >compile </goal > </goals >
</execution >
<execution >
<id >java -test -compile </id >
<phase >test -compile </phase >
<goals > <goal >testCompile </goal > </goals >
</execution > 15
Kotlin en Maven - kotlin-maven-plugin
<c o m p i l e r P l u g i n s>
<plugin>a l l −open</plugin>
</c o m p i l e r P l u g i n s>
. . .
<option>a l l −open : annotation=j av a x . ws . r s . Path</option>
<option>a l l −open : annotation=j av a x . e n t e r p r i s e . context . RequestScoped</option>
<option>a l l −open : annotation=j av a x . e n t e r p r i s e . context . SessionScoped </option>
<option>a l l −open : annotation=j av a x . e n t e r p r i s e . context . ApplicationScoped </option>
<option>a l l −open : annotation=j av a x . e n t e r p r i s e . context . Dependent</option>
<option>a l l −open : annotation=j av a x . e j b . Singleton </option>
<option>a l l −open : annotation=j av a x . e j b . S t a t e f u l </option>
<option>a l l −open : annotation=j av a x . e j b . S t a t e l e s s </option>
Ideia geral: Adicionar as anota¸c˜oes do ciclo de vida no CDI e EJB
16
Demo
Kotlin + Jakarta EE + MicroProfile - Demo
• Kotlin 1.3
• Bibliotecas - SLF4J, Flyway, PostgreSQL
• Jakarta EE 8 - EJB, JPA
• MicroProfile - CDI, JAX-RS, MicroProfile Config
• Testing - Arquillian, JUnit, Payara Embedded
https://dzone.com/articles/
the-state-of-kotlin-for-jakarta-eemicroprofile-tra
https://github.com/tuxtor/integrum-ee
17
Kotlin + Jakarta EE + MicroProfile - Demo
18
Kotlin + Jakarta EE + MicroProfile - Demo
19
Kotlin - Entidade JPA
@Entity
@Table(name = "adm_phrase")
@TableGenerator (...)
data class AdmPhrase(
@Id
@GeneratedValue (strategy = GenerationType .TABLE ,
generator = " admPhraseIdGenerator ")
@Column(name = "phrase_id")
var phraseId:Long? = null ,
var author:String = "",
var phrase:String = ""
)
Data Clases, Nullable Types
20
Kotlin - Reposit´orio CDI
@RequestScoped
class AdmPhraseRepository {
@Inject
private lateinit var em:EntityManager
...
}
Lateinit (nullable type)
21
Kotlin - Reposit´orio CDI
fun create(admPhrase:AdmPhrase) = em.persist(admPhrase)
fun update(admPhrase:AdmPhrase) = em.merge(admPhrase)
fun findById(phraseId: Long) =
em.find(AdmPhrase :: class.java , phraseId)
fun delete(admPhrase: AdmPhrase) = em.remove(admPhrase)
. . .
Single expression functions (One line methods)
22
Kotlin - Reposit´orio CDI
fun listAll(author: String , phrase: String ):
List <AdmPhrase > {
val query = """SELECT p FROM AdmPhrase p
where p.author LIKE :author
and p.phrase LIKE :phrase
"""
return em.createQuery(query , AdmPhrase :: class.java)
.setParameter("author", "%$author%")
.setParameter("phrase", "%$phrase%")
.resultList
}
Multiline String, mutable declaration
23
Kotlin - Controlador JAX-RS
@Path ( "/phrases" )
@Produces ( MediaType . APPLICATION JSON)
@Consumes ( MediaType . APPLICATION JSON)
c l a s s AdmPhraseController {
@Inject
p r i v a t e l a t e i n i t var admPhraseRepository : AdmPhraseReposit
@Inject
p r i v a t e l a t e i n i t var l o g g e r : Logger
. . .
}
24
Kotlin - Controlador JAX-RS
@GET
fun f i n d A l l (
@QueryParam ( "author" ) @DefaultValue ( "%" ) author : String ,
@QueryParam ( "phrase" ) @DefaultValue ( "%" ) phrase : S t r i n g ) =
admPhraseRepository . l i s t A l l ( author , phrase )
@GET
@Path ( "/{id :[0 -9][0 -9]*}" )
fun f i n d B y I d ( @PathParam ( "id" ) i d : Long ) =
admPhraseRepository . f i n d B y I d ( i d )
@PUT
fun c r e a t e ( phrase : AdmPhrase ) : Response {
admPhraseRepository . c r e a t e ( phrase )
return Response . ok ( ) . b u i l d ()
}
25
Kotlin - Controlador JAX-RS
@POST
@Path ( "/{id :[0 -9][0 -9]*}" )
fun update ( @PathParam ( "id" ) i d : Long ? , phrase : AdmPhrase )
: Response {
i f ( i d != phrase . p h r a s e I d )
return Response . s t a t u s ( Response . Status .NOT FOUND) .
v a l updatedEntity = admPhraseRepository . update ( phrase )
return Response . ok ( updatedEntity ) . b u i l d ()
}
@DELETE
@Path ( "/{id :[0 -9][0 -9]*}" )
fun d e l e t e ( @PathParam ( "id" ) i d : Long ) : Response {
v a l updatedEntity = admPhraseRepository . f i n d B y I d ( i d ) ? :
return Response . s t a t u s ( Response . Status .NOT FOUND) . b u i l d ()
admPhraseRepository . d e l e t e ( updatedEntity )
return Response . ok ( ) . b u i l d ()
}
Elvis operator as expression 26
12 fatores cloud native (Heroku)
Microprofile
• Config
• Backing service
• Disposability
Cloud
• Codebase (Git-Flow)
• Dependencies (Maven)
• Build, Release, Run
• Processes (Pipelines)
• Port binding
• Concurrency (Docker - k8s)
• Dev / Prod parity
• Logs
• Admin process
27
Oracle Cloud
<groupId>i o . f a b r i c 8</ groupId>
<a r t i f a c t I d>docker−maven−p l u g i n</ a r t i f a c t I d>
<version>0 . 3 0 . 0</version>
. . .
<image>
<name>iad . o c i r . i o / t u x t o r / m i c r o p r o f i l e / integrum−ee</name>
<b u i l d>
<d o c k e r F i l e>${ p r o j e c t . b a s e d i r }/ D o c k e r f i l e</ d o c k e r F
</ b u i l d>
</image>
28
Oracle Cloud
29
Oracle Cloud
30
Oracle Cloud
31
Oracle Cloud
32
Kotlin
Kotlin
• Static typing
• Java inter-op
• OO + FP
• Null safety
• Extension functions
• Operator overloading
• Data classes
• One line methods
33
Kotlin - Fatos interessantes
• Effective Java -
Inmutabilidade, builder,
singleton, override, final by
default, variance by generics
• Elvis - Groovy
• Inferˆencia de tipos - Scala
• Imutabilidade - Scala
• Identificadores - Scala
• Gest˜ao de null values -
Groovy
• Closures e funciones -
Groovy
34
Java - Morrendo desde 1995
• Retrocompatibilidade
• Spring Boot, Micronaut,
MicroProfile, GraalVM . . .
• Raw performance (Beam,
Spark, Hadoop)
• Tooling - IDE, Maven,
Drivers RDBMS
• JVM - (Twitter, Alibaba,
Spotify, etc.)
• OpenJDK
35
Kotlin
Vantagens
• C´odigo mais conciso
• Suporte real Java inter-op
• Aproveitar desenvolvedores
Android para backend
• Uma nova forma de
”Full-stack”
Desvantagens
• IntelliJ IDEA Ultimate
(monol´ıtico)
• A curva de aprendizagem do
Kotlin ´e mais complicada no
inicio
• Compila¸c˜ao (tempo)
• Os entornos EE geralmente
s˜ao tread-managed e pode
ser um problema para o uso
de Co-routines
36
V´ıctor Orozco
• vorozco@nabenik.com
• @tuxtor
• http://www.nabenik.com
This work is licensed under a
Creative Commons
Attribution-ShareAlike 3.0.
37

More Related Content

What's hot

Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaRick Warren
 
Taking advantage of Prometheus relabeling
Taking advantage of Prometheus relabelingTaking advantage of Prometheus relabeling
Taking advantage of Prometheus relabelingJulien Pivotto
 
RxJava applied [JavaDay Kyiv 2016]
RxJava applied [JavaDay Kyiv 2016]RxJava applied [JavaDay Kyiv 2016]
RxJava applied [JavaDay Kyiv 2016]Igor Lozynskyi
 
An Introduction to RxJava
An Introduction to RxJavaAn Introduction to RxJava
An Introduction to RxJavaSanjay Acharya
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for AndroidTomáš Kypta
 
Introduction to rx java for android
Introduction to rx java for androidIntroduction to rx java for android
Introduction to rx java for androidEsa Firman
 
Reactive Functional Programming with Java 8 on Android N
Reactive Functional Programming with Java 8 on Android NReactive Functional Programming with Java 8 on Android N
Reactive Functional Programming with Java 8 on Android NShipeng Xu
 
Streams, Streams Everywhere! An Introduction to Rx
Streams, Streams Everywhere! An Introduction to RxStreams, Streams Everywhere! An Introduction to Rx
Streams, Streams Everywhere! An Introduction to RxAndrzej Sitek
 
Monitoring as an entry point for collaboration
Monitoring as an entry point for collaborationMonitoring as an entry point for collaboration
Monitoring as an entry point for collaborationJulien Pivotto
 
Functional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event SystemsFunctional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event SystemsLeonardo Borges
 
Intro to RxJava/RxAndroid - GDG Munich Android
Intro to RxJava/RxAndroid - GDG Munich AndroidIntro to RxJava/RxAndroid - GDG Munich Android
Intro to RxJava/RxAndroid - GDG Munich AndroidEgor Andreevich
 
Reactive programming with RxJava
Reactive programming with RxJavaReactive programming with RxJava
Reactive programming with RxJavaJobaer Chowdhury
 
Android architecture components
Android architecture componentsAndroid architecture components
Android architecture componentsDiego Figueredo
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJSstefanmayer13
 
Prometheus for the traditional datacenter
Prometheus for the traditional datacenterPrometheus for the traditional datacenter
Prometheus for the traditional datacenterJulien Pivotto
 
Reactive Fault Tolerant Programming with Hystrix and RxJava
Reactive Fault Tolerant Programming with Hystrix and RxJavaReactive Fault Tolerant Programming with Hystrix and RxJava
Reactive Fault Tolerant Programming with Hystrix and RxJavaMatt Stine
 
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015NAVER / MusicPlatform
 
Reactive Android: RxJava and beyond
Reactive Android: RxJava and beyondReactive Android: RxJava and beyond
Reactive Android: RxJava and beyondFabio Tiriticco
 

What's hot (20)

Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
 
Taking advantage of Prometheus relabeling
Taking advantage of Prometheus relabelingTaking advantage of Prometheus relabeling
Taking advantage of Prometheus relabeling
 
RxJava applied [JavaDay Kyiv 2016]
RxJava applied [JavaDay Kyiv 2016]RxJava applied [JavaDay Kyiv 2016]
RxJava applied [JavaDay Kyiv 2016]
 
An Introduction to RxJava
An Introduction to RxJavaAn Introduction to RxJava
An Introduction to RxJava
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for Android
 
RxJava on Android
RxJava on AndroidRxJava on Android
RxJava on Android
 
Introduction to rx java for android
Introduction to rx java for androidIntroduction to rx java for android
Introduction to rx java for android
 
Reactive Functional Programming with Java 8 on Android N
Reactive Functional Programming with Java 8 on Android NReactive Functional Programming with Java 8 on Android N
Reactive Functional Programming with Java 8 on Android N
 
Rx java in action
Rx java in actionRx java in action
Rx java in action
 
Streams, Streams Everywhere! An Introduction to Rx
Streams, Streams Everywhere! An Introduction to RxStreams, Streams Everywhere! An Introduction to Rx
Streams, Streams Everywhere! An Introduction to Rx
 
Monitoring as an entry point for collaboration
Monitoring as an entry point for collaborationMonitoring as an entry point for collaboration
Monitoring as an entry point for collaboration
 
Functional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event SystemsFunctional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event Systems
 
Intro to RxJava/RxAndroid - GDG Munich Android
Intro to RxJava/RxAndroid - GDG Munich AndroidIntro to RxJava/RxAndroid - GDG Munich Android
Intro to RxJava/RxAndroid - GDG Munich Android
 
Reactive programming with RxJava
Reactive programming with RxJavaReactive programming with RxJava
Reactive programming with RxJava
 
Android architecture components
Android architecture componentsAndroid architecture components
Android architecture components
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
 
Prometheus for the traditional datacenter
Prometheus for the traditional datacenterPrometheus for the traditional datacenter
Prometheus for the traditional datacenter
 
Reactive Fault Tolerant Programming with Hystrix and RxJava
Reactive Fault Tolerant Programming with Hystrix and RxJavaReactive Fault Tolerant Programming with Hystrix and RxJava
Reactive Fault Tolerant Programming with Hystrix and RxJava
 
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
 
Reactive Android: RxJava and beyond
Reactive Android: RxJava and beyondReactive Android: RxJava and beyond
Reactive Android: RxJava and beyond
 

Similar to Kotlin+MicroProfile: Ensinando 20 anos para uma linguagem nova

Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Martijn Verburg
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomyDongmin Yu
 
Dev Day 2019: Mike Sperber – Software Design für die Seele
Dev Day 2019: Mike Sperber – Software Design für die SeeleDev Day 2019: Mike Sperber – Software Design für die Seele
Dev Day 2019: Mike Sperber – Software Design für die SeeleDevDay Dresden
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기NAVER D2
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformationLars Marius Garshol
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9Ivan Krylov
 
«Продакшн в Kotlin DSL» Сергей Рыбалкин
«Продакшн в Kotlin DSL» Сергей Рыбалкин«Продакшн в Kotlin DSL» Сергей Рыбалкин
«Продакшн в Kotlin DSL» Сергей РыбалкинMail.ru Group
 
Kotlin, smarter development for the jvm
Kotlin, smarter development for the jvmKotlin, smarter development for the jvm
Kotlin, smarter development for the jvmArnaud Giuliani
 
Java EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSFJava EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSFJiayun Zhou
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 itiAhmed mar3y
 
Innovative Specifications for Better Performance Logging and Monitoring
Innovative Specifications for Better Performance Logging and MonitoringInnovative Specifications for Better Performance Logging and Monitoring
Innovative Specifications for Better Performance Logging and MonitoringCary Millsap
 
Practical REPL-driven Development with Clojure
Practical REPL-driven Development with ClojurePractical REPL-driven Development with Clojure
Practical REPL-driven Development with ClojureKent Ohashi
 
Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017Arnaud Giuliani
 
Rapid Web API development with Kotlin and Ktor
Rapid Web API development with Kotlin and KtorRapid Web API development with Kotlin and Ktor
Rapid Web API development with Kotlin and KtorTrayan Iliev
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGuillaume Laforge
 
A TypeScript Fans KotlinJS Adventures
A TypeScript Fans KotlinJS AdventuresA TypeScript Fans KotlinJS Adventures
A TypeScript Fans KotlinJS AdventuresGarth Gilmour
 
Excuse me, sir, do you have a moment to talk about tests in Kotlin
Excuse me, sir, do you have a moment to talk about tests in KotlinExcuse me, sir, do you have a moment to talk about tests in Kotlin
Excuse me, sir, do you have a moment to talk about tests in Kotlinleonsabr
 

Similar to Kotlin+MicroProfile: Ensinando 20 anos para uma linguagem nova (20)

Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
 
Dev Day 2019: Mike Sperber – Software Design für die Seele
Dev Day 2019: Mike Sperber – Software Design für die SeeleDev Day 2019: Mike Sperber – Software Design für die Seele
Dev Day 2019: Mike Sperber – Software Design für die Seele
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformation
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
 
«Продакшн в Kotlin DSL» Сергей Рыбалкин
«Продакшн в Kotlin DSL» Сергей Рыбалкин«Продакшн в Kotlin DSL» Сергей Рыбалкин
«Продакшн в Kotlin DSL» Сергей Рыбалкин
 
Kotlin, smarter development for the jvm
Kotlin, smarter development for the jvmKotlin, smarter development for the jvm
Kotlin, smarter development for the jvm
 
Java EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSFJava EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSF
 
Polyglot
PolyglotPolyglot
Polyglot
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 iti
 
Innovative Specifications for Better Performance Logging and Monitoring
Innovative Specifications for Better Performance Logging and MonitoringInnovative Specifications for Better Performance Logging and Monitoring
Innovative Specifications for Better Performance Logging and Monitoring
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
Practical REPL-driven Development with Clojure
Practical REPL-driven Development with ClojurePractical REPL-driven Development with Clojure
Practical REPL-driven Development with Clojure
 
Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017
 
Koin Quickstart
Koin QuickstartKoin Quickstart
Koin Quickstart
 
Rapid Web API development with Kotlin and Ktor
Rapid Web API development with Kotlin and KtorRapid Web API development with Kotlin and Ktor
Rapid Web API development with Kotlin and Ktor
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
 
A TypeScript Fans KotlinJS Adventures
A TypeScript Fans KotlinJS AdventuresA TypeScript Fans KotlinJS Adventures
A TypeScript Fans KotlinJS Adventures
 
Excuse me, sir, do you have a moment to talk about tests in Kotlin
Excuse me, sir, do you have a moment to talk about tests in KotlinExcuse me, sir, do you have a moment to talk about tests in Kotlin
Excuse me, sir, do you have a moment to talk about tests in Kotlin
 

More from Víctor Leonel Orozco López

Iniciando microservicios reales con JakartaEE/MicroProfile y arquetipos de Maven
Iniciando microservicios reales con JakartaEE/MicroProfile y arquetipos de MavenIniciando microservicios reales con JakartaEE/MicroProfile y arquetipos de Maven
Iniciando microservicios reales con JakartaEE/MicroProfile y arquetipos de MavenVíctor Leonel Orozco López
 
Desde la TV, hasta la nube, el ecosistema de Java en 26 años
Desde la TV, hasta la nube, el ecosistema de Java en 26 añosDesde la TV, hasta la nube, el ecosistema de Java en 26 años
Desde la TV, hasta la nube, el ecosistema de Java en 26 añosVíctor Leonel Orozco López
 
Bootstraping real world Jakarta EE/MicroProfile microservices with Maven Arch...
Bootstraping real world Jakarta EE/MicroProfile microservices with Maven Arch...Bootstraping real world Jakarta EE/MicroProfile microservices with Maven Arch...
Bootstraping real world Jakarta EE/MicroProfile microservices with Maven Arch...Víctor Leonel Orozco López
 
Explorando los objetos centrales de Kubernetes con Oracle Cloud
Explorando los objetos centrales de Kubernetes con Oracle CloudExplorando los objetos centrales de Kubernetes con Oracle Cloud
Explorando los objetos centrales de Kubernetes con Oracle CloudVíctor Leonel Orozco López
 
Introducción a GraalVM Native para aplicaciones JVM
Introducción a GraalVM Native para aplicaciones JVMIntroducción a GraalVM Native para aplicaciones JVM
Introducción a GraalVM Native para aplicaciones JVMVíctor Leonel Orozco López
 
Design Patterns para Microsserviços com MicroProfile
 Design Patterns para Microsserviços com MicroProfile Design Patterns para Microsserviços com MicroProfile
Design Patterns para Microsserviços com MicroProfileVíctor Leonel Orozco López
 
MicroProfile benefits for your monolithic applications
MicroProfile benefits for your monolithic applicationsMicroProfile benefits for your monolithic applications
MicroProfile benefits for your monolithic applicationsVíctor Leonel Orozco López
 
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...Víctor Leonel Orozco López
 
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...Víctor Leonel Orozco López
 
Consejos y el camino del desarrollador de software
Consejos y el camino del desarrollador de softwareConsejos y el camino del desarrollador de software
Consejos y el camino del desarrollador de softwareVíctor Leonel Orozco López
 
Seguridad de aplicaciones Java/JakartaEE con OWASP Top 10
Seguridad de aplicaciones Java/JakartaEE con OWASP Top 10Seguridad de aplicaciones Java/JakartaEE con OWASP Top 10
Seguridad de aplicaciones Java/JakartaEE con OWASP Top 10Víctor Leonel Orozco López
 

More from Víctor Leonel Orozco López (20)

Introducción al análisis de datos
Introducción al análisis de datosIntroducción al análisis de datos
Introducción al análisis de datos
 
From traditional to GitOps
From traditional to GitOpsFrom traditional to GitOps
From traditional to GitOps
 
De Java 8 a Java 17
De Java 8 a Java 17De Java 8 a Java 17
De Java 8 a Java 17
 
Iniciando microservicios reales con JakartaEE/MicroProfile y arquetipos de Maven
Iniciando microservicios reales con JakartaEE/MicroProfile y arquetipos de MavenIniciando microservicios reales con JakartaEE/MicroProfile y arquetipos de Maven
Iniciando microservicios reales con JakartaEE/MicroProfile y arquetipos de Maven
 
Desde la TV, hasta la nube, el ecosistema de Java en 26 años
Desde la TV, hasta la nube, el ecosistema de Java en 26 añosDesde la TV, hasta la nube, el ecosistema de Java en 26 años
Desde la TV, hasta la nube, el ecosistema de Java en 26 años
 
Bootstraping real world Jakarta EE/MicroProfile microservices with Maven Arch...
Bootstraping real world Jakarta EE/MicroProfile microservices with Maven Arch...Bootstraping real world Jakarta EE/MicroProfile microservices with Maven Arch...
Bootstraping real world Jakarta EE/MicroProfile microservices with Maven Arch...
 
Tolerancia a fallas, service mesh y chassis
Tolerancia a fallas, service mesh y chassisTolerancia a fallas, service mesh y chassis
Tolerancia a fallas, service mesh y chassis
 
Explorando los objetos centrales de Kubernetes con Oracle Cloud
Explorando los objetos centrales de Kubernetes con Oracle CloudExplorando los objetos centrales de Kubernetes con Oracle Cloud
Explorando los objetos centrales de Kubernetes con Oracle Cloud
 
Introducción a GraalVM Native para aplicaciones JVM
Introducción a GraalVM Native para aplicaciones JVMIntroducción a GraalVM Native para aplicaciones JVM
Introducción a GraalVM Native para aplicaciones JVM
 
Desarrollo moderno con DevOps y Cloud Native
Desarrollo moderno con DevOps y Cloud NativeDesarrollo moderno con DevOps y Cloud Native
Desarrollo moderno con DevOps y Cloud Native
 
Design Patterns para Microsserviços com MicroProfile
 Design Patterns para Microsserviços com MicroProfile Design Patterns para Microsserviços com MicroProfile
Design Patterns para Microsserviços com MicroProfile
 
Gestión de proyectos con Maven
Gestión de proyectos con MavenGestión de proyectos con Maven
Gestión de proyectos con Maven
 
MicroProfile benefits for your monolithic applications
MicroProfile benefits for your monolithic applicationsMicroProfile benefits for your monolithic applications
MicroProfile benefits for your monolithic applications
 
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
 
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
Actualizando aplicaciones empresariales en Java desde Java 8 on premise hasta...
 
Consejos y el camino del desarrollador de software
Consejos y el camino del desarrollador de softwareConsejos y el camino del desarrollador de software
Consejos y el camino del desarrollador de software
 
Seguridad de aplicaciones Java/JakartaEE con OWASP Top 10
Seguridad de aplicaciones Java/JakartaEE con OWASP Top 10Seguridad de aplicaciones Java/JakartaEE con OWASP Top 10
Seguridad de aplicaciones Java/JakartaEE con OWASP Top 10
 
Introducción a Kotlin para desarrolladores Java
Introducción a Kotlin para desarrolladores JavaIntroducción a Kotlin para desarrolladores Java
Introducción a Kotlin para desarrolladores Java
 
De Java 8 ate Java 14
De Java 8 ate Java 14De Java 8 ate Java 14
De Java 8 ate Java 14
 
Programación con ECMA6 y TypeScript
Programación con ECMA6 y TypeScriptProgramación con ECMA6 y TypeScript
Programación con ECMA6 y TypeScript
 

Recently uploaded

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 

Recently uploaded (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Kotlin+MicroProfile: Ensinando 20 anos para uma linguagem nova

  • 1. Kotlin+MicroProfile: Teaching 20 year old tricks to a new language V´ıctor Orozco 19 de Julho de 2019 @tuxtor 1
  • 2. Java - Morrendo desde 1995 2
  • 5. Microsservi¸cos - Java • DIY - Jooby, Javalin, Micronaut, Spark, Vert.x, Helidon SE • Enterprise - Spring Boot, Microprofile (implementa¸c˜oes) 4
  • 6. Microsservi¸cos - Kotlin • DIY - Jooby, Javalin, Micronaut, Spark, Vert.x, Helidon SE, Ktor • Enterprise - Spring Boot, Microprofile (implementa¸c˜oes) 5
  • 8. Eclipse MicroProfile Figura 2: Credito: Reza Rahman 6
  • 12. Eclipse MicroProfile - implementa¸c˜oes Bibliotecas • SmallRye (Red Hat) • Hammock • Apache Geronimo • Fujitsu Launcher JEAS - Fat Jar, Uber Jar • Dropwizard • KumuluzEE • Helidon (Oracle) • Open Liberty (IBM) • Apache Meecrowave • Thorntail (Red Hat) • Quarkus (Red Hat) • Payara Micro 10
  • 13. Eclipse MicroProfile - Implementaciones Micro server - Thin War • Payara Micro • TomEE JAX-RS Full server • Payara Application Server • JBoss Application Server / Wildfly Application Server • WebSphere Liberty (IBM) https://wiki.eclipse.org/MicroProfile/Implementation 11
  • 14. Eclipse MicroProfile - 1, 2, 3 com Kotlin 1. Projeto Java Maven (Gradle) 2. Dependencia no MicroProfile (JavaEE, Arquillian, JUnit, . . .) 3. Plugin Maven (maven-compiler-plugin) 4. Plugin Kotlin (kotlin-maven-plugin) 5. Desenvolver em Kotlin e ser uma pessoa feliz 12
  • 15. Eclipse MicroProfile + Kotlin + Maven
  • 16. Eclipse MicroProfile com Payara 5 <dependency > <groupId >org.eclipse.microprofile </ groupId > <artifactId >microprofile </ artifactId > <type >pom </type > <version >2.0.1 </ version > <scope >provided </scope > </dependency > 13
  • 17. Kotlin en Maven - Dependˆencias <dependency > <groupId >org.jetbrains.kotlin </groupId > <artifactId >kotlin -stdlib -jdk8 </artifactId > <version >${ kotlin.version}</version > </dependency > 14
  • 18. Kotlin en Maven - maven-compiler-plugin <execution > <id >default -compile </id > <phase >none </phase > </execution > <execution > <id >default -testCompile </id > <phase >none </phase > </execution > <execution > <id >java -compile </id > <phase >compile </phase > <goals > <goal >compile </goal > </goals > </execution > <execution > <id >java -test -compile </id > <phase >test -compile </phase > <goals > <goal >testCompile </goal > </goals > </execution > 15
  • 19. Kotlin en Maven - kotlin-maven-plugin <c o m p i l e r P l u g i n s> <plugin>a l l −open</plugin> </c o m p i l e r P l u g i n s> . . . <option>a l l −open : annotation=j av a x . ws . r s . Path</option> <option>a l l −open : annotation=j av a x . e n t e r p r i s e . context . RequestScoped</option> <option>a l l −open : annotation=j av a x . e n t e r p r i s e . context . SessionScoped </option> <option>a l l −open : annotation=j av a x . e n t e r p r i s e . context . ApplicationScoped </option> <option>a l l −open : annotation=j av a x . e n t e r p r i s e . context . Dependent</option> <option>a l l −open : annotation=j av a x . e j b . Singleton </option> <option>a l l −open : annotation=j av a x . e j b . S t a t e f u l </option> <option>a l l −open : annotation=j av a x . e j b . S t a t e l e s s </option> Ideia geral: Adicionar as anota¸c˜oes do ciclo de vida no CDI e EJB 16
  • 20. Demo
  • 21. Kotlin + Jakarta EE + MicroProfile - Demo • Kotlin 1.3 • Bibliotecas - SLF4J, Flyway, PostgreSQL • Jakarta EE 8 - EJB, JPA • MicroProfile - CDI, JAX-RS, MicroProfile Config • Testing - Arquillian, JUnit, Payara Embedded https://dzone.com/articles/ the-state-of-kotlin-for-jakarta-eemicroprofile-tra https://github.com/tuxtor/integrum-ee 17
  • 22. Kotlin + Jakarta EE + MicroProfile - Demo 18
  • 23. Kotlin + Jakarta EE + MicroProfile - Demo 19
  • 24. Kotlin - Entidade JPA @Entity @Table(name = "adm_phrase") @TableGenerator (...) data class AdmPhrase( @Id @GeneratedValue (strategy = GenerationType .TABLE , generator = " admPhraseIdGenerator ") @Column(name = "phrase_id") var phraseId:Long? = null , var author:String = "", var phrase:String = "" ) Data Clases, Nullable Types 20
  • 25. Kotlin - Reposit´orio CDI @RequestScoped class AdmPhraseRepository { @Inject private lateinit var em:EntityManager ... } Lateinit (nullable type) 21
  • 26. Kotlin - Reposit´orio CDI fun create(admPhrase:AdmPhrase) = em.persist(admPhrase) fun update(admPhrase:AdmPhrase) = em.merge(admPhrase) fun findById(phraseId: Long) = em.find(AdmPhrase :: class.java , phraseId) fun delete(admPhrase: AdmPhrase) = em.remove(admPhrase) . . . Single expression functions (One line methods) 22
  • 27. Kotlin - Reposit´orio CDI fun listAll(author: String , phrase: String ): List <AdmPhrase > { val query = """SELECT p FROM AdmPhrase p where p.author LIKE :author and p.phrase LIKE :phrase """ return em.createQuery(query , AdmPhrase :: class.java) .setParameter("author", "%$author%") .setParameter("phrase", "%$phrase%") .resultList } Multiline String, mutable declaration 23
  • 28. Kotlin - Controlador JAX-RS @Path ( "/phrases" ) @Produces ( MediaType . APPLICATION JSON) @Consumes ( MediaType . APPLICATION JSON) c l a s s AdmPhraseController { @Inject p r i v a t e l a t e i n i t var admPhraseRepository : AdmPhraseReposit @Inject p r i v a t e l a t e i n i t var l o g g e r : Logger . . . } 24
  • 29. Kotlin - Controlador JAX-RS @GET fun f i n d A l l ( @QueryParam ( "author" ) @DefaultValue ( "%" ) author : String , @QueryParam ( "phrase" ) @DefaultValue ( "%" ) phrase : S t r i n g ) = admPhraseRepository . l i s t A l l ( author , phrase ) @GET @Path ( "/{id :[0 -9][0 -9]*}" ) fun f i n d B y I d ( @PathParam ( "id" ) i d : Long ) = admPhraseRepository . f i n d B y I d ( i d ) @PUT fun c r e a t e ( phrase : AdmPhrase ) : Response { admPhraseRepository . c r e a t e ( phrase ) return Response . ok ( ) . b u i l d () } 25
  • 30. Kotlin - Controlador JAX-RS @POST @Path ( "/{id :[0 -9][0 -9]*}" ) fun update ( @PathParam ( "id" ) i d : Long ? , phrase : AdmPhrase ) : Response { i f ( i d != phrase . p h r a s e I d ) return Response . s t a t u s ( Response . Status .NOT FOUND) . v a l updatedEntity = admPhraseRepository . update ( phrase ) return Response . ok ( updatedEntity ) . b u i l d () } @DELETE @Path ( "/{id :[0 -9][0 -9]*}" ) fun d e l e t e ( @PathParam ( "id" ) i d : Long ) : Response { v a l updatedEntity = admPhraseRepository . f i n d B y I d ( i d ) ? : return Response . s t a t u s ( Response . Status .NOT FOUND) . b u i l d () admPhraseRepository . d e l e t e ( updatedEntity ) return Response . ok ( ) . b u i l d () } Elvis operator as expression 26
  • 31. 12 fatores cloud native (Heroku) Microprofile • Config • Backing service • Disposability Cloud • Codebase (Git-Flow) • Dependencies (Maven) • Build, Release, Run • Processes (Pipelines) • Port binding • Concurrency (Docker - k8s) • Dev / Prod parity • Logs • Admin process 27
  • 32. Oracle Cloud <groupId>i o . f a b r i c 8</ groupId> <a r t i f a c t I d>docker−maven−p l u g i n</ a r t i f a c t I d> <version>0 . 3 0 . 0</version> . . . <image> <name>iad . o c i r . i o / t u x t o r / m i c r o p r o f i l e / integrum−ee</name> <b u i l d> <d o c k e r F i l e>${ p r o j e c t . b a s e d i r }/ D o c k e r f i l e</ d o c k e r F </ b u i l d> </image> 28
  • 38. Kotlin • Static typing • Java inter-op • OO + FP • Null safety • Extension functions • Operator overloading • Data classes • One line methods 33
  • 39. Kotlin - Fatos interessantes • Effective Java - Inmutabilidade, builder, singleton, override, final by default, variance by generics • Elvis - Groovy • Inferˆencia de tipos - Scala • Imutabilidade - Scala • Identificadores - Scala • Gest˜ao de null values - Groovy • Closures e funciones - Groovy 34
  • 40. Java - Morrendo desde 1995 • Retrocompatibilidade • Spring Boot, Micronaut, MicroProfile, GraalVM . . . • Raw performance (Beam, Spark, Hadoop) • Tooling - IDE, Maven, Drivers RDBMS • JVM - (Twitter, Alibaba, Spotify, etc.) • OpenJDK 35
  • 41. Kotlin Vantagens • C´odigo mais conciso • Suporte real Java inter-op • Aproveitar desenvolvedores Android para backend • Uma nova forma de ”Full-stack” Desvantagens • IntelliJ IDEA Ultimate (monol´ıtico) • A curva de aprendizagem do Kotlin ´e mais complicada no inicio • Compila¸c˜ao (tempo) • Os entornos EE geralmente s˜ao tread-managed e pode ser um problema para o uso de Co-routines 36
  • 42. V´ıctor Orozco • vorozco@nabenik.com • @tuxtor • http://www.nabenik.com This work is licensed under a Creative Commons Attribution-ShareAlike 3.0. 37