SlideShare una empresa de Scribd logo
1 de 31
Descargar para leer sin conexión
Spring Scala

Sneaking Scala into your corporation
Brought to you by Henryk Konsek / @hekonsek
About me

open source committer, evangelist and adopter
Apache Camel
Spring Scala (Spring Source aka VMware aka Pivotal)
7 years of professional experience
Artegence aka Filmweb
Asseco
Pitney Bowes
Java Black Belt
freelance consulting
About me

Hired by Red Hat (JBoss)
to work with JBoss Fuse stack:
Apache ServiceMix
Apache ActiveMQ
JBoss HornetQ
Apache Camel
Apache CXF

http://jboss.org/jbossfuse
1.
2.
3.
4.

This talk

Some context
What is Spring Scala
How to use Spring Scala
Why use Spring Scala
1. Some context
Inversion Of Control (IoC)
Dependency Injection (DI)
Spring
Spring guide for busy
developers
Defining dependency to be used in application:

@ of gr to
C ni u ai n
p bi c as Iv ie aC n iu ai n {
u lc l s no c Do of gr t o
@e nI vi ea i vi e a( {
Ba no cD o no cD o)
r tr n wI vi ea ( ;
e u n e n o cD o)
}
@e nI vi ee v c i v ie ev c( {
Ba no cS ri e no cS r ie )
r tr n wI vi ee v c( no cD o) ;
e u n e n o cS ri ei v ie a( )
}
}
Spring guide for busy
developers
Using the dependency in the application:

p bi c as Iv ie eo t ee ao {
u lc l s no c Rp rG nr t r
@n et
Ij c
pi ae Iv ie e vc i vi ee vc ;
rv t n oc Sr ie n oc S ri e
pb i Ls <n oc >i v ie Fr ot (n y a, i tm nh {
ul c it Iv i e no cs o Mn hi t er n o t)
I vi eu r qe y= I vi eu re .e rya )m nh m nh ;
n o cQ ey u r
n oc Q ei sy a(er . ot(o t)
r tr i vi ee vc . id no cs qe y ;
e u n n oc S ri ef nI v ie (u r)
}
}
2. What is Spring Scala

official project from Spring Source (aka VMware, aka Pivotal)
portfolio
API for defining beans in Scala
wrappers for existing Spring API (aka Pimp My Spring)
3. How to use Spring Scala
Defining beans
c as MS aa of g et ns Fn t oa Cn iu ai n {
l s y cl Cn i xe d u ci nl of g rt o
vl do =b a( ( ya ()
a a
en )M Do )
ba (( ye vc ( a( )
en ) MS ri ed o) )
}

define bean of type MyDao and bean of type MyService
MyDao is wired into MyService
Defining beans
c as MS aa of g et ns Fn t oa Cn iu ai n {
l s y cl Cn i xe d u ci nl of g rt o
vl do =b a( {
a a
en )
M Do )
ya(
}
ba ( {
en )
M Sr ie do )
y e vc (a ()
}
}

Notice functions!
Defining beans - lifecycle
c a s M s a e r k r o f g r t o e t n s F n t o a C n i u a i n{
l s e sg Bo eC ni u ai n xe d uc in l of gr to
ba (a e= "c i eq rk r) {
en n m
a tv mB o e"
v lb oe = nw Bo e Sr ie
a rk r
e r kr ev c
b oe .d Cn e tr "c :/ o ah s: 11 "
r k ra do nc o( t p/ lc lo t6 6 6)
b oe
rkr
}i i {
nt
_ sa t)
. t r(
}d sr y{
eto
_ so (
. t p)
}
}

We avoid hard-coding method names. We invoke them instead.
Accessing beans
v lc ne t= Fn t oa Cn iA p ia in ot x[ y cl Cn i]
a otx
u ci nl o fg pl ct oC n et MS aa o fg
v ls ri e= cn e tM Sr ie
a evc
o tx [y e vc ]
(Globally) Accessing beans
Config

o jc M Sa ao fg et n sF nt oa Cn i ua in{
b et y cl Cn i x ed u c in lo fg rt o
vl do =b a( ( ya ()
a a
en )M Do )
vl sr ie =b a (( ye vc ( a( )
a e vc
en )M S ri ed o) )
}

+ application bootstrap
o jc M Ap et ns Ap {
b et y p xe d p
nw Fn to aC n iA pi ai n ot x( .
e u ci nl of gp l ct oC ne t)
r gs eC ni u ai n( yc l Cn i)
e i tr of gr to s MS aa of g
}

= global access
M S a a o f g s r i e ) m S r i e e h d)
y cl C ni .e vc (. y ev cM to(

Or even global access on steroids!
i pr M Sa ao fg _
m ot y cl Cn i .
..
.
s ri e) mS ri e eh d)
e vc ( .y ev cM to (
Pimping your existing
contexts
v lx lo tx = nw Ca s ah mA pi ai n ot x( ca s ah ba sx l )
a m C ne t
e l sP tX l pl ct oC ne t "l sp t: en . m"
v ls aa ot x =
a c l Cn et
A pi ai no t xC ne so s tR cA pi ai n ot x( mC ne t
p l ct oC ne to v ri n. oi hp l ct oC ne t xl ot x)
v ls ri e= sa a ot x[ ye v c]
a evc
c lC ne t MS ri e

For those who aren't easily frightened by implicit conversions:
i pr o gs rn fa eo k sa ac ne t A p ia in ot x Cn es os _
m ot r .p ig r mw r. cl . ot x. pl ct o Cn et ov ri n.
v lx lo tx = nw Ca s ah mA pi ai n ot x(ca s ah ba sx l )
a m C ne t
e l sP tX l pl ct oC ne t"l sp t: en . m"
v ls ri e= xl o tx [y ev c ]
a evc
m Cn et M Sr ie
Scala friendly API #1
JmsTemplate

v lc ne to Fc o y: Cn et o Fc oy = ..
a o n ci na tr
o nc in at r
.
v lt ml t =n wJ se p ae cn et oF c oy
a e p ae
e mT ml t( o nc in at r)

Function callbacks instead of anonymous inner functions.
t ml t. ed"u u" {s si n Ss in =
e pa e sn(q ee)
e so : es o >
ss in ce tT x Ms ae "e l Wr d )
es o .r ae et es g (H lo o l"
}

Pattern matching friendly return types.
t ml t. ee v( q ee )m th {
e pa e rc ie "u u" ac
cs S m( :T xM sa e = pi tn mg t et
ae o em e t es g) > r nl (. eT x)
cs N n = p it n" o tx m sa er ci e"
ae o e > r n l( N et e sg e e vd)
}
Scala friendly API #2
JdbcTemplate

v lt ml t =n wJ bT m lt (a ao re
a e p ae
e dc ep ae d tS uc )

Functions instead of callbacks
v lt ml t. ur A da(S LC l gn FO U E" {
a e p ae qe yn Mp " EE T oi R M SR )
(e ut e, rw u )=
rs l St o Nm >
" d %"fr a (o Nm r sl St gt t ig 1)
%: s.o mt rw u , e u te .e Sr n ()
}

Scala collections instead of java.util API
v lu es :M pS r n, nR f =t ml t. u rF ra (S L C * FO U E"
a sr
a[ ti gA y e]
ep ae qe yo M p" EE T
R M SR )

Options instead of nulls
v lq ey =" EE T lg nF O UE W EE i =?
a ur
SL C oi RM S R H R d
"
v ll gn =t ml t .u rF rb e tS rn ]q ey , 1 m t h{
a oi
ep ae qe y oO jc [t ig ( ur
) ac
Sm (o i)
oe l gn
Nn = "e al L gn
oe > d fu to i"
}
Scala friendly API #3

Aspect Oriented Programming
Defining aspects as (anonymous inner) classes is overkill.
v ll ge Av c =
a o g rd ie
(e hd M to ,a g: A ry Ay e] t re :A y =
mt o : e hd rs r a[ n Rf , a g t n) >
l gd bg "x c tn m to { " m to . eN m)
o . eu (E eu ig e hd } , eh dg ta e
v ls vP it u =( :M t o, c Ca s_ )= m gt ae s at Wt (s v"
a a e on ct
m eh d : ls [] > . e Nm .t rs ih " ae )

What about wiring aspects into beans?
a vc t re (e M Sr i e o s vP it u ui g lg eA vc
d ie a gt n w ye vc ) n ae on ct s n og r di e
Integrating with non-Scala
Spring
You can mix your existing Spring Config file into functional
configuration.
c as Pr oC ni u ai ne tn sFn to aC ni u ai n{
l s e sn of gr to xe d uc in l of gr to
ip rC as Nm C ni ua in (
mo t ls [a eo fg r to ])
vl jh = ba ( {
a on
en )
n wP ro (e B a( fr ta e) g te n "a ta e )
e es ng te n" i sN m", eB a( ls N m" )
}
}

Mixing XML...
c as Pr oC ni u ai ne tn sFn to aC ni u ai n{
l s e sn of gr to xe d uc in l of gr to
ip rX l" ls p t: cf cn i .m "
mo t m( ca sa h/ x -o fg xl)
ba ( {
en )
C fx oe [e p ee vc ]
x E ps rP ol Sr i e
}
}
4. Why use Spring Scala

Your snippets were nice, but give me a real reason to use this
library.
Rant #1

I can use pure Java Config with Scala!
@ en ii Mt o =" hs S rn h sb e r f co e b a a cd n"
B a( n te hd
ti t ig a e n ea tr d y n ci et,
d sr ye hd = " l v t tp m to n ms so om c "+
e t oM to
I oe o y e e hd a e o o uh
" n dt ci gp ol m a rn ie +
a d ee tn rb es t u tm "
" nt a o i v kn m to si f nt os cl b cs +
i s ed f no ig e hd n u ci n a la k"
" n dt ci gp ol m a cm ia in t m"
a d ee tn rb es t o pl to i e)
B oe Sr ie at v mB oe ( {
r kr e vc c ie qr k r)
vl bo e =n wB oe S ri e
a r kr
e rk re vc
bo e. dC ne t r" c: /o a hs :1 1"
rk r ad on co (t p /l cl ot 66 6)
bo e
rk r
}
..
.
j se pa es n( u u, nw Ms a er ao ( {
m Tm l t. ed qe e e e sg Ce tr )
pb i Ms ae ce tM s ae Ss in ss i n t r w J S xe to {
ul c es g r ae es g( e so e so ) ho s ME cp in
r t r s s i n c e t T x M s a e " e b s t F W ";
e u n e so . ra ee te s g( Vr oi y T!)
}
}
)

Yes, you can...
Rant #2

Spring sucks! Cake/Dagger/MacWire FTW!
OK if you start greenfield project
Cake alone won't solve your problems
you can use Cake *and* Spring Scala
how likely is that your existing project uses Spring already?
Rant #3

Using Spring in Scala is stupid.
Hi Boss, I think that all the Spring trainings,
developers experience, knowHow, patterns,
practices we follow won't be needed anymore!
Scala is the next big thing, so we want to drop
all of these. BTW Will you send my team to
Scala Days? I'm aware that our budget is tight,
but you know, we need to educate...
Rant #4

But this is yet another jar in my classpath!
I don't know how to answer this in 2014...
use Maven/Ivy/Gradle/SBT?
don't deploy over Internet and watch YouTube
delete some porns from your HDD
Rant #5

Spring Scala is not 100% type safe. Spring is not type safe.
Indeed, but Spring Scala is safer than raw Spring.
Evolve, don't be a rebel #1

make yourself a favor, introduce Scala to your legacy project
pick a slice of your existing Spring application
rewrite that slice in Scala
Evolve, don't be a rebel #2

make yourself a favor, introduce Scala to your legacy project
need to implement new enhancement request for the
customer?
write it in Scala and integrate with the existing Spring
codebase
Evolve, don't be a rebel #3

make yourself a favor, introduce Scala to your legacy project
promote micro-services approach
write your micro-service module in Scala
wire it however you want
use Spring Scala to expose your service to the shared (nonScala) application context
Evolve, don't be a rebel #4
respect human factor
not everybody has to be a hacker
some people don't feel comfortable with Monads ;)
some people will learn and adapt slower than the others
create core logic in Scala, let the others to build on it in
Java/Spring
Links
Spring Scala project at GitHub
Spring Scala project forum
Introducing Spring Scala by Arjen Poutsma
Many thanks!

Más contenido relacionado

La actualidad más candente

Security of go modules lightning talk
Security of go modules  lightning talkSecurity of go modules  lightning talk
Security of go modules lightning talk
Deep Datta
 
Testing Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax ExamTesting Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax Exam
Henryk Konsek
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnit
Edorian
 
Bdd: Tdd and beyond the infinite
Bdd: Tdd and beyond the infiniteBdd: Tdd and beyond the infinite
Bdd: Tdd and beyond the infinite
Giordano Scalzo
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
Mattias Gees
 

La actualidad más candente (18)

Representing Material Culture Online: Historic Clothing in Omeka
Representing Material Culture Online: Historic Clothing in OmekaRepresenting Material Culture Online: Historic Clothing in Omeka
Representing Material Culture Online: Historic Clothing in Omeka
 
Profiling Web Archives IIPC GA 2015
Profiling Web Archives IIPC GA 2015Profiling Web Archives IIPC GA 2015
Profiling Web Archives IIPC GA 2015
 
Security of go modules lightning talk
Security of go modules  lightning talkSecurity of go modules  lightning talk
Security of go modules lightning talk
 
Top 10 pieges php afup limoges
Top 10 pieges php   afup limogesTop 10 pieges php   afup limoges
Top 10 pieges php afup limoges
 
Testing Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax ExamTesting Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax Exam
 
Testing TYPO3 Applications
Testing TYPO3 ApplicationsTesting TYPO3 Applications
Testing TYPO3 Applications
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnit
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnit
 
Bdd: Tdd and beyond the infinite
Bdd: Tdd and beyond the infiniteBdd: Tdd and beyond the infinite
Bdd: Tdd and beyond the infinite
 
Clojure made really really simple
Clojure made really really simpleClojure made really really simple
Clojure made really really simple
 
Fast api
Fast apiFast api
Fast api
 
GraphQL, l'avenir du REST ?
GraphQL, l'avenir du REST ?GraphQL, l'avenir du REST ?
GraphQL, l'avenir du REST ?
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Semantic Web & TYPO3
Semantic Web & TYPO3Semantic Web & TYPO3
Semantic Web & TYPO3
 
Auckland Programming Algorithms and Performance Meetup about Stacks & LeetCod...
Auckland Programming Algorithms and Performance Meetup about Stacks & LeetCod...Auckland Programming Algorithms and Performance Meetup about Stacks & LeetCod...
Auckland Programming Algorithms and Performance Meetup about Stacks & LeetCod...
 
PyLadies Talk: Learn to love the command line!
PyLadies Talk: Learn to love the command line!PyLadies Talk: Learn to love the command line!
PyLadies Talk: Learn to love the command line!
 
What is recursion?
What is recursion? What is recursion?
What is recursion?
 
Clojurescript up and running
Clojurescript up and runningClojurescript up and running
Clojurescript up and running
 

Destacado

Ana fariña galileo galilei 3ª a
Ana fariña galileo galilei 3ª aAna fariña galileo galilei 3ª a
Ana fariña galileo galilei 3ª a
anadena
 
2011インターンシップ_09N1144_横山大城
2011インターンシップ_09N1144_横山大城2011インターンシップ_09N1144_横山大城
2011インターンシップ_09N1144_横山大城
YokoyamaD
 
งานนำเสนอบทที่7
งานนำเสนอบทที่7งานนำเสนอบทที่7
งานนำเสนอบทที่7
sawitri555
 
Salespresentatie
SalespresentatieSalespresentatie
Salespresentatie
marieke1990
 
Statistical supplement june 2011 final[1]
Statistical supplement june 2011   final[1]Statistical supplement june 2011   final[1]
Statistical supplement june 2011 final[1]
Sammit Shukla
 
Magazine covers (1st draft & final draft)
Magazine covers (1st draft & final draft)Magazine covers (1st draft & final draft)
Magazine covers (1st draft & final draft)
LukaMedia
 
Ppt el alamein
Ppt el alameinPpt el alamein
Ppt el alamein
Riski W
 
2011 NLDS Wild Card Champions St. Louis Cardinals
2011 NLDS Wild Card Champions St. Louis Cardinals2011 NLDS Wild Card Champions St. Louis Cardinals
2011 NLDS Wild Card Champions St. Louis Cardinals
aesims
 

Destacado (20)

Ray
RayRay
Ray
 
Ana fariña galileo galilei 3ª a
Ana fariña galileo galilei 3ª aAna fariña galileo galilei 3ª a
Ana fariña galileo galilei 3ª a
 
2011インターンシップ_09N1144_横山大城
2011インターンシップ_09N1144_横山大城2011インターンシップ_09N1144_横山大城
2011インターンシップ_09N1144_横山大城
 
งานนำเสนอบทที่7
งานนำเสนอบทที่7งานนำเสนอบทที่7
งานนำเสนอบทที่7
 
Lynda Goldman Presentation For Expo East Sept 21 2011
Lynda Goldman Presentation For Expo East Sept 21 2011Lynda Goldman Presentation For Expo East Sept 21 2011
Lynda Goldman Presentation For Expo East Sept 21 2011
 
Slovak Consular Services in Belfast, 7 and 8 April_2014
Slovak Consular Services in Belfast, 7 and 8 April_2014Slovak Consular Services in Belfast, 7 and 8 April_2014
Slovak Consular Services in Belfast, 7 and 8 April_2014
 
Salespresentatie
SalespresentatieSalespresentatie
Salespresentatie
 
Statistical supplement june 2011 final[1]
Statistical supplement june 2011   final[1]Statistical supplement june 2011   final[1]
Statistical supplement june 2011 final[1]
 
Pdhpe ppt
Pdhpe pptPdhpe ppt
Pdhpe ppt
 
Stephen W. Hawking__Fakebook
Stephen W. Hawking__FakebookStephen W. Hawking__Fakebook
Stephen W. Hawking__Fakebook
 
Magazine covers (1st draft & final draft)
Magazine covers (1st draft & final draft)Magazine covers (1st draft & final draft)
Magazine covers (1st draft & final draft)
 
Ppt el alamein
Ppt el alameinPpt el alamein
Ppt el alamein
 
business globalization
business globalizationbusiness globalization
business globalization
 
Farsund digitalworkshop
Farsund digitalworkshopFarsund digitalworkshop
Farsund digitalworkshop
 
Media Music Video Pitch
Media Music Video PitchMedia Music Video Pitch
Media Music Video Pitch
 
Hughes getting in early 23.6 cp
Hughes getting in early 23.6 cpHughes getting in early 23.6 cp
Hughes getting in early 23.6 cp
 
Crisis Communications
Crisis CommunicationsCrisis Communications
Crisis Communications
 
Programa Curricular nivel-primaria-ebr
Programa Curricular nivel-primaria-ebrPrograma Curricular nivel-primaria-ebr
Programa Curricular nivel-primaria-ebr
 
2011 NLDS Wild Card Champions St. Louis Cardinals
2011 NLDS Wild Card Champions St. Louis Cardinals2011 NLDS Wild Card Champions St. Louis Cardinals
2011 NLDS Wild Card Champions St. Louis Cardinals
 
15º Boletín informativo fundación iter
15º Boletín informativo  fundación iter15º Boletín informativo  fundación iter
15º Boletín informativo fundación iter
 

Similar a Spring scala - Sneaking Scala into your corporation

Modeling avengers – open source technology mix for saving the world
Modeling avengers – open source technology mix for saving the worldModeling avengers – open source technology mix for saving the world
Modeling avengers – open source technology mix for saving the world
Cédric Brun
 
Modeling avengers – open source technology mix for saving the world econ fr
Modeling avengers – open source technology mix for saving the world econ frModeling avengers – open source technology mix for saving the world econ fr
Modeling avengers – open source technology mix for saving the world econ fr
Cédric Brun
 
Y o u r N a m e L S P 2 0 0 - 3 2 0 ( c o u r s e I .docx
Y o u r  N a m e   L S P  2 0 0 - 3 2 0  ( c o u r s e  I .docxY o u r  N a m e   L S P  2 0 0 - 3 2 0  ( c o u r s e  I .docx
Y o u r N a m e L S P 2 0 0 - 3 2 0 ( c o u r s e I .docx
herminaprocter
 
Y o u r N a m e L S P 2 0 0 - 3 2 0 ( c o u r s e I .docx
Y o u r  N a m e   L S P  2 0 0 - 3 2 0  ( c o u r s e  I .docxY o u r  N a m e   L S P  2 0 0 - 3 2 0  ( c o u r s e  I .docx
Y o u r N a m e L S P 2 0 0 - 3 2 0 ( c o u r s e I .docx
odiliagilby
 

Similar a Spring scala - Sneaking Scala into your corporation (20)

JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
 
Introduction to Compiler Development
Introduction to Compiler DevelopmentIntroduction to Compiler Development
Introduction to Compiler Development
 
Microservices With Spring Boot and Spring Cloud Netflix
Microservices With Spring Boot and Spring Cloud NetflixMicroservices With Spring Boot and Spring Cloud Netflix
Microservices With Spring Boot and Spring Cloud Netflix
 
Advanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit TestingAdvanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit Testing
 
Spring Roo 2.0 Preview at Spring I/O 2016
Spring Roo 2.0 Preview at Spring I/O 2016 Spring Roo 2.0 Preview at Spring I/O 2016
Spring Roo 2.0 Preview at Spring I/O 2016
 
Modeling avengers – open source technology mix for saving the world
Modeling avengers – open source technology mix for saving the worldModeling avengers – open source technology mix for saving the world
Modeling avengers – open source technology mix for saving the world
 
Modeling avengers – open source technology mix for saving the world econ fr
Modeling avengers – open source technology mix for saving the world econ frModeling avengers – open source technology mix for saving the world econ fr
Modeling avengers – open source technology mix for saving the world econ fr
 
Code GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limitersCode GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limiters
 
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
 
AWS Cloud Experience CA: Democratizando la Inteligencia Artificial
AWS Cloud Experience CA: Democratizando la Inteligencia ArtificialAWS Cloud Experience CA: Democratizando la Inteligencia Artificial
AWS Cloud Experience CA: Democratizando la Inteligencia Artificial
 
Apache Camel: rotas para as suas mensagens
Apache Camel: rotas para as suas mensagensApache Camel: rotas para as suas mensagens
Apache Camel: rotas para as suas mensagens
 
Open Source Systems Performance
Open Source Systems PerformanceOpen Source Systems Performance
Open Source Systems Performance
 
Improving Software Reliability via Mining Software Engineering Data
Improving Software Reliability via Mining Software Engineering DataImproving Software Reliability via Mining Software Engineering Data
Improving Software Reliability via Mining Software Engineering Data
 
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar PradhanAwesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
 
機械学習エンジニアを見せたAWSの再:発明とは? 〜re:Invent 2018 参加レポート〜
機械学習エンジニアを見せたAWSの再:発明とは? 〜re:Invent 2018 参加レポート〜機械学習エンジニアを見せたAWSの再:発明とは? 〜re:Invent 2018 参加レポート〜
機械学習エンジニアを見せたAWSの再:発明とは? 〜re:Invent 2018 参加レポート〜
 
Using TypeScript at Dashlane
Using TypeScript at DashlaneUsing TypeScript at Dashlane
Using TypeScript at Dashlane
 
Y o u r N a m e L S P 2 0 0 - 3 2 0 ( c o u r s e I .docx
Y o u r  N a m e   L S P  2 0 0 - 3 2 0  ( c o u r s e  I .docxY o u r  N a m e   L S P  2 0 0 - 3 2 0  ( c o u r s e  I .docx
Y o u r N a m e L S P 2 0 0 - 3 2 0 ( c o u r s e I .docx
 
Y o u r N a m e L S P 2 0 0 - 3 2 0 ( c o u r s e I .docx
Y o u r  N a m e   L S P  2 0 0 - 3 2 0  ( c o u r s e  I .docxY o u r  N a m e   L S P  2 0 0 - 3 2 0  ( c o u r s e  I .docx
Y o u r N a m e L S P 2 0 0 - 3 2 0 ( c o u r s e I .docx
 
OOP in Rust
OOP in RustOOP in Rust
OOP in Rust
 
Kamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, codeKamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, code
 

Más de Henryk Konsek

Más de Henryk Konsek (17)

How to cloud #1: Create Kafka cluster with Confluent Cloud
How to cloud #1:  Create Kafka cluster with Confluent CloudHow to cloud #1:  Create Kafka cluster with Confluent Cloud
How to cloud #1: Create Kafka cluster with Confluent Cloud
 
Eclipse Kapua messaging refactoring proposal
Eclipse Kapua messaging refactoring proposalEclipse Kapua messaging refactoring proposal
Eclipse Kapua messaging refactoring proposal
 
Containerize!
Containerize!Containerize!
Containerize!
 
Open source IoT gateway
Open source IoT gatewayOpen source IoT gateway
Open source IoT gateway
 
Open source IoT gateway: Tale of Eclipse Kura, Apache Camel and Rhiot
Open source IoT gateway: Tale of Eclipse Kura, Apache Camel and RhiotOpen source IoT gateway: Tale of Eclipse Kura, Apache Camel and Rhiot
Open source IoT gateway: Tale of Eclipse Kura, Apache Camel and Rhiot
 
Iot gateway dream team - Eclipse Kura and Apache Camel
Iot gateway dream team - Eclipse Kura and Apache CamelIot gateway dream team - Eclipse Kura and Apache Camel
Iot gateway dream team - Eclipse Kura and Apache Camel
 
Internet Of Things for mere mortals
Internet Of Things for mere mortalsInternet Of Things for mere mortals
Internet Of Things for mere mortals
 
(Ultra quick) Rhiot overview
(Ultra quick) Rhiot overview(Ultra quick) Rhiot overview
(Ultra quick) Rhiot overview
 
Internet Of Things for mere mortals
Internet Of Things for mere mortalsInternet Of Things for mere mortals
Internet Of Things for mere mortals
 
Docker for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortals
 
Iot and the back-end developers
Iot and the back-end developersIot and the back-end developers
Iot and the back-end developers
 
Containerize! Between Docker and Jube.
Containerize! Between Docker and Jube.Containerize! Between Docker and Jube.
Containerize! Between Docker and Jube.
 
IoT gateway dream team - Eclipse Kura and Apache Camel
IoT gateway dream team - Eclipse Kura and Apache CamelIoT gateway dream team - Eclipse Kura and Apache Camel
IoT gateway dream team - Eclipse Kura and Apache Camel
 
Apache Camel in the belly of the Docker whale
Apache Camel in the belly of the Docker whaleApache Camel in the belly of the Docker whale
Apache Camel in the belly of the Docker whale
 
Fabric8 - Being devOps doesn't suck anymore
Fabric8 - Being devOps doesn't suck anymoreFabric8 - Being devOps doesn't suck anymore
Fabric8 - Being devOps doesn't suck anymore
 
Messaging with the Docker
Messaging with the DockerMessaging with the Docker
Messaging with the Docker
 
Crash course to the Apache Camel
Crash course to the Apache CamelCrash course to the Apache Camel
Crash course to the Apache Camel
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
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...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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, ...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Spring scala - Sneaking Scala into your corporation

  • 1. Spring Scala Sneaking Scala into your corporation Brought to you by Henryk Konsek / @hekonsek
  • 2. About me open source committer, evangelist and adopter Apache Camel Spring Scala (Spring Source aka VMware aka Pivotal) 7 years of professional experience Artegence aka Filmweb Asseco Pitney Bowes Java Black Belt freelance consulting
  • 3. About me Hired by Red Hat (JBoss) to work with JBoss Fuse stack: Apache ServiceMix Apache ActiveMQ JBoss HornetQ Apache Camel Apache CXF http://jboss.org/jbossfuse
  • 4. 1. 2. 3. 4. This talk Some context What is Spring Scala How to use Spring Scala Why use Spring Scala
  • 5. 1. Some context Inversion Of Control (IoC) Dependency Injection (DI) Spring
  • 6. Spring guide for busy developers Defining dependency to be used in application: @ of gr to C ni u ai n p bi c as Iv ie aC n iu ai n { u lc l s no c Do of gr t o @e nI vi ea i vi e a( { Ba no cD o no cD o) r tr n wI vi ea ( ; e u n e n o cD o) } @e nI vi ee v c i v ie ev c( { Ba no cS ri e no cS r ie ) r tr n wI vi ee v c( no cD o) ; e u n e n o cS ri ei v ie a( ) } }
  • 7. Spring guide for busy developers Using the dependency in the application: p bi c as Iv ie eo t ee ao { u lc l s no c Rp rG nr t r @n et Ij c pi ae Iv ie e vc i vi ee vc ; rv t n oc Sr ie n oc S ri e pb i Ls <n oc >i v ie Fr ot (n y a, i tm nh { ul c it Iv i e no cs o Mn hi t er n o t) I vi eu r qe y= I vi eu re .e rya )m nh m nh ; n o cQ ey u r n oc Q ei sy a(er . ot(o t) r tr i vi ee vc . id no cs qe y ; e u n n oc S ri ef nI v ie (u r) } }
  • 8. 2. What is Spring Scala official project from Spring Source (aka VMware, aka Pivotal) portfolio API for defining beans in Scala wrappers for existing Spring API (aka Pimp My Spring)
  • 9. 3. How to use Spring Scala
  • 10. Defining beans c as MS aa of g et ns Fn t oa Cn iu ai n { l s y cl Cn i xe d u ci nl of g rt o vl do =b a( ( ya () a a en )M Do ) ba (( ye vc ( a( ) en ) MS ri ed o) ) } define bean of type MyDao and bean of type MyService MyDao is wired into MyService
  • 11. Defining beans c as MS aa of g et ns Fn t oa Cn iu ai n { l s y cl Cn i xe d u ci nl of g rt o vl do =b a( { a a en ) M Do ) ya( } ba ( { en ) M Sr ie do ) y e vc (a () } } Notice functions!
  • 12. Defining beans - lifecycle c a s M s a e r k r o f g r t o e t n s F n t o a C n i u a i n{ l s e sg Bo eC ni u ai n xe d uc in l of gr to ba (a e= "c i eq rk r) { en n m a tv mB o e" v lb oe = nw Bo e Sr ie a rk r e r kr ev c b oe .d Cn e tr "c :/ o ah s: 11 " r k ra do nc o( t p/ lc lo t6 6 6) b oe rkr }i i { nt _ sa t) . t r( }d sr y{ eto _ so ( . t p) } } We avoid hard-coding method names. We invoke them instead.
  • 13. Accessing beans v lc ne t= Fn t oa Cn iA p ia in ot x[ y cl Cn i] a otx u ci nl o fg pl ct oC n et MS aa o fg v ls ri e= cn e tM Sr ie a evc o tx [y e vc ]
  • 14. (Globally) Accessing beans Config o jc M Sa ao fg et n sF nt oa Cn i ua in{ b et y cl Cn i x ed u c in lo fg rt o vl do =b a( ( ya () a a en )M Do ) vl sr ie =b a (( ye vc ( a( ) a e vc en )M S ri ed o) ) } + application bootstrap o jc M Ap et ns Ap { b et y p xe d p nw Fn to aC n iA pi ai n ot x( . e u ci nl of gp l ct oC ne t) r gs eC ni u ai n( yc l Cn i) e i tr of gr to s MS aa of g } = global access M S a a o f g s r i e ) m S r i e e h d) y cl C ni .e vc (. y ev cM to( Or even global access on steroids! i pr M Sa ao fg _ m ot y cl Cn i . .. . s ri e) mS ri e eh d) e vc ( .y ev cM to (
  • 15. Pimping your existing contexts v lx lo tx = nw Ca s ah mA pi ai n ot x( ca s ah ba sx l ) a m C ne t e l sP tX l pl ct oC ne t "l sp t: en . m" v ls aa ot x = a c l Cn et A pi ai no t xC ne so s tR cA pi ai n ot x( mC ne t p l ct oC ne to v ri n. oi hp l ct oC ne t xl ot x) v ls ri e= sa a ot x[ ye v c] a evc c lC ne t MS ri e For those who aren't easily frightened by implicit conversions: i pr o gs rn fa eo k sa ac ne t A p ia in ot x Cn es os _ m ot r .p ig r mw r. cl . ot x. pl ct o Cn et ov ri n. v lx lo tx = nw Ca s ah mA pi ai n ot x(ca s ah ba sx l ) a m C ne t e l sP tX l pl ct oC ne t"l sp t: en . m" v ls ri e= xl o tx [y ev c ] a evc m Cn et M Sr ie
  • 16. Scala friendly API #1 JmsTemplate v lc ne to Fc o y: Cn et o Fc oy = .. a o n ci na tr o nc in at r . v lt ml t =n wJ se p ae cn et oF c oy a e p ae e mT ml t( o nc in at r) Function callbacks instead of anonymous inner functions. t ml t. ed"u u" {s si n Ss in = e pa e sn(q ee) e so : es o > ss in ce tT x Ms ae "e l Wr d ) es o .r ae et es g (H lo o l" } Pattern matching friendly return types. t ml t. ee v( q ee )m th { e pa e rc ie "u u" ac cs S m( :T xM sa e = pi tn mg t et ae o em e t es g) > r nl (. eT x) cs N n = p it n" o tx m sa er ci e" ae o e > r n l( N et e sg e e vd) }
  • 17. Scala friendly API #2 JdbcTemplate v lt ml t =n wJ bT m lt (a ao re a e p ae e dc ep ae d tS uc ) Functions instead of callbacks v lt ml t. ur A da(S LC l gn FO U E" { a e p ae qe yn Mp " EE T oi R M SR ) (e ut e, rw u )= rs l St o Nm > " d %"fr a (o Nm r sl St gt t ig 1) %: s.o mt rw u , e u te .e Sr n () } Scala collections instead of java.util API v lu es :M pS r n, nR f =t ml t. u rF ra (S L C * FO U E" a sr a[ ti gA y e] ep ae qe yo M p" EE T R M SR ) Options instead of nulls v lq ey =" EE T lg nF O UE W EE i =? a ur SL C oi RM S R H R d " v ll gn =t ml t .u rF rb e tS rn ]q ey , 1 m t h{ a oi ep ae qe y oO jc [t ig ( ur ) ac Sm (o i) oe l gn Nn = "e al L gn oe > d fu to i" }
  • 18. Scala friendly API #3 Aspect Oriented Programming Defining aspects as (anonymous inner) classes is overkill. v ll ge Av c = a o g rd ie (e hd M to ,a g: A ry Ay e] t re :A y = mt o : e hd rs r a[ n Rf , a g t n) > l gd bg "x c tn m to { " m to . eN m) o . eu (E eu ig e hd } , eh dg ta e v ls vP it u =( :M t o, c Ca s_ )= m gt ae s at Wt (s v" a a e on ct m eh d : ls [] > . e Nm .t rs ih " ae ) What about wiring aspects into beans? a vc t re (e M Sr i e o s vP it u ui g lg eA vc d ie a gt n w ye vc ) n ae on ct s n og r di e
  • 19. Integrating with non-Scala Spring You can mix your existing Spring Config file into functional configuration. c as Pr oC ni u ai ne tn sFn to aC ni u ai n{ l s e sn of gr to xe d uc in l of gr to ip rC as Nm C ni ua in ( mo t ls [a eo fg r to ]) vl jh = ba ( { a on en ) n wP ro (e B a( fr ta e) g te n "a ta e ) e es ng te n" i sN m", eB a( ls N m" ) } } Mixing XML... c as Pr oC ni u ai ne tn sFn to aC ni u ai n{ l s e sn of gr to xe d uc in l of gr to ip rX l" ls p t: cf cn i .m " mo t m( ca sa h/ x -o fg xl) ba ( { en ) C fx oe [e p ee vc ] x E ps rP ol Sr i e } }
  • 20. 4. Why use Spring Scala Your snippets were nice, but give me a real reason to use this library.
  • 21. Rant #1 I can use pure Java Config with Scala! @ en ii Mt o =" hs S rn h sb e r f co e b a a cd n" B a( n te hd ti t ig a e n ea tr d y n ci et, d sr ye hd = " l v t tp m to n ms so om c "+ e t oM to I oe o y e e hd a e o o uh " n dt ci gp ol m a rn ie + a d ee tn rb es t u tm " " nt a o i v kn m to si f nt os cl b cs + i s ed f no ig e hd n u ci n a la k" " n dt ci gp ol m a cm ia in t m" a d ee tn rb es t o pl to i e) B oe Sr ie at v mB oe ( { r kr e vc c ie qr k r) vl bo e =n wB oe S ri e a r kr e rk re vc bo e. dC ne t r" c: /o a hs :1 1" rk r ad on co (t p /l cl ot 66 6) bo e rk r } .. . j se pa es n( u u, nw Ms a er ao ( { m Tm l t. ed qe e e e sg Ce tr ) pb i Ms ae ce tM s ae Ss in ss i n t r w J S xe to { ul c es g r ae es g( e so e so ) ho s ME cp in r t r s s i n c e t T x M s a e " e b s t F W "; e u n e so . ra ee te s g( Vr oi y T!) } } ) Yes, you can...
  • 22. Rant #2 Spring sucks! Cake/Dagger/MacWire FTW! OK if you start greenfield project Cake alone won't solve your problems you can use Cake *and* Spring Scala how likely is that your existing project uses Spring already?
  • 23. Rant #3 Using Spring in Scala is stupid. Hi Boss, I think that all the Spring trainings, developers experience, knowHow, patterns, practices we follow won't be needed anymore! Scala is the next big thing, so we want to drop all of these. BTW Will you send my team to Scala Days? I'm aware that our budget is tight, but you know, we need to educate...
  • 24. Rant #4 But this is yet another jar in my classpath! I don't know how to answer this in 2014... use Maven/Ivy/Gradle/SBT? don't deploy over Internet and watch YouTube delete some porns from your HDD
  • 25. Rant #5 Spring Scala is not 100% type safe. Spring is not type safe. Indeed, but Spring Scala is safer than raw Spring.
  • 26. Evolve, don't be a rebel #1 make yourself a favor, introduce Scala to your legacy project pick a slice of your existing Spring application rewrite that slice in Scala
  • 27. Evolve, don't be a rebel #2 make yourself a favor, introduce Scala to your legacy project need to implement new enhancement request for the customer? write it in Scala and integrate with the existing Spring codebase
  • 28. Evolve, don't be a rebel #3 make yourself a favor, introduce Scala to your legacy project promote micro-services approach write your micro-service module in Scala wire it however you want use Spring Scala to expose your service to the shared (nonScala) application context
  • 29. Evolve, don't be a rebel #4 respect human factor not everybody has to be a hacker some people don't feel comfortable with Monads ;) some people will learn and adapt slower than the others create core logic in Scala, let the others to build on it in Java/Spring
  • 30. Links Spring Scala project at GitHub Spring Scala project forum Introducing Spring Scala by Arjen Poutsma