SlideShare a Scribd company logo
A RESTy-JSON API
with spray.io and maven
sponsored by special appearance
Ignasi Marimon-Clos i Sunyol
@ignasi35
#scalabcn
Sunday, June 16, 13
thanks!
Sunday, June 16, 13
special thank you’s
JPradel (@agile_jordi): review and organization
JCasadellà (@jcasadella): review
JRudolph for simplifying step 4
https://github.com/jrudolph/scala-meetup-spray/commit/
c4991938ec7b26b183d701aac73949e7822cf45e
Sunday, June 16, 13
about me
n. /iŋ'nazi/
1) problem solver, Garbage Collector, mostly
java, learning scala, some agile
2) kayaker
3) under construction
4) wears glasses
Sunday, June 16, 13
what we saw
• BDD (cucumber)
• TDD (scalatest)
• sbt (inifinite run)
• intelliJ
• JAX-RS
• Jetty
https://github.com/funcio/bdd-jaxrs-hands-on
Sunday, June 16, 13
what we’ll see
• BDD (cucumber)
• TDD (scalatest)
• sbt (inifinite run)
• intelliJ
• JAX-RS
• Jetty
• BDD (jbehave?)
• TDD (scalatest)
• mvn (infinite run)
• eclipse (worksheet)
• spray-can/https/...
• spray-json
https://github.com/ignasi35/scala-meetup-spray
Sunday, June 16, 13
why? (1/2)
• I’m comfy with eclipse
• I’m comfy with maven (I know that’s weird)
• (no more)Typesafe delivers a prepacked env
• still there s/where
• eclipse-maven integration is solid
• I needed infinite-test in maven at work
• I like trolling Jordi and Jose
Sunday, June 16, 13
why? (2/2)
• spray.io has akka
• spray 1.x has akka 2.x
• spray.io is modularized (that’s useful)
• I don’t need java API (@see play)
• spray-json is f*&[ing simple (via shapeless)
http://spray.io/project-info/current-versions/
Sunday, June 16, 13
why? (bonus)
• spray.io beats all other JVM stacks/fw (*)
http://www.techempower.com/benchmarks/
Sunday, June 16, 13
spray
modules
provided
provided
There’s more provided dep’s
than those labelled but we don’t
need that level of detail now.
credit: graphic made using yuml.me
http://yuml.me/diagram/scruffy/class/[A]->[B],[A]->[C],[B]->[C]
Sunday, June 16, 13
spray
• One thing done right
• spray-routing => simple entry point.
• @sirthias (Mathias Doenitz) in Akka 2.2
• magnet pattern
• alternate to method overload
• IOBridge, directives, Marshallers, ...???
Sunday, June 16, 13
Sunday, June 16, 13
step 1
• Given an HTTP server
• When I GET /hello
• Then I obtain “hello”
Sunday, June 16, 13
step 1 (tips)
• Edit a web.xml
• Create a mapping
• Provide a BeanConnectionBeanFactory
• Add a servers.xml
• Invoke the Olds Gods and the New
Sunday, June 16, 13
specially dedicated to @ch4lit
Sunday, June 16, 13
step 2
• Given an HTTP server
• When I GET /hello.json
• Then I obtain “{msg:‘world’}”
Sunday, June 16, 13
directives + complete
• path/pathPrefix/pathTest
• authenticate
• get/post/delete/...
• decodeRequest/encodeResponse/...
• cache/alwaysCache/...
• complete
http://spray.io/documentation/spray-routing/predefined-directives-alphabetically/
Sunday, June 16, 13
step 3
• Given an HTTP server
• When I GET /books.json
• Then I obtain the complete books stock
Sunday, June 16, 13
step 4
• Given an HTTP server
• And I POST a book.txt in /books
• When I GET /books.json
• Then I obtain the updated books stock
MEGA-KUDOS to
https://github.com/jrudolph
Sunday, June 16, 13
step 5
• Given an HTTP server
• And a programmatic HTTP client
• When I GET /hello.json
• Then I obtain “{msg:‘world’}”
Sunday, June 16, 13
conclusions
• scala in maven is tough
• mvn plugin lacks infini-run, infini-install,...
• scala worksheet rocks
• spray allows a quick entry point
• docs and examples still to be improved
• because I’m very dumb
• ...
Sunday, June 16, 13
thanks!
Sunday, June 16, 13

More Related Content

PPTX
Build 2017 - P4160 - Bot Analytics Dashboard
PDF
PDF
Intro scala for rubyists (ironhack)
PDF
Portfolio Full compressed_2
PDF
Spray Democamp Dresden 2011-11-08
PPTX
Motivation through total reward rbs- haleem sadrey 2010
PDF
Boiler calculations
PPT
Lecture07
Build 2017 - P4160 - Bot Analytics Dashboard
Intro scala for rubyists (ironhack)
Portfolio Full compressed_2
Spray Democamp Dresden 2011-11-08
Motivation through total reward rbs- haleem sadrey 2010
Boiler calculations
Lecture07

Viewers also liked (12)

PPT
Final Presentation
PPTX
Pesticide Training Course UC Davis, Safety. Part 5 of 5
PPTX
Ppt microencapsulation
PPTX
Tuna
PPTX
SPM Paper 2 Esei: FORCE AND PRESSURE
PPT
Hptlc (rajat)
PPT
Chemical Reactors
PPT
power-plant-basics
PPTX
Blood Bank Management System (including UML diagrams)
PPT
Ceramics
PPT
Bank Management System
PPTX
Flowchart Diagram Templates by Creately
Final Presentation
Pesticide Training Course UC Davis, Safety. Part 5 of 5
Ppt microencapsulation
Tuna
SPM Paper 2 Esei: FORCE AND PRESSURE
Hptlc (rajat)
Chemical Reactors
power-plant-basics
Blood Bank Management System (including UML diagrams)
Ceramics
Bank Management System
Flowchart Diagram Templates by Creately
Ad

Similar to Spray & Maven Intro for Scala Barcelona Developers Meetup (20)

PDF
Odnoklassniki.ru Architecture
PDF
The Diabolical Developer's Guide to Surviving Java 9
PDF
Ab(Using) the MetaCPAN API for Fun and Profit v2013
KEY
Back to the future with Java 7 (Geekout June/2011)
PDF
PDF
Red Dirt Ruby Conference
PPTX
Ljc conf open jdk betterrev bof
PDF
萬國之津梁
PDF
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
PDF
Java Advanced Features (TCF 2014)
PDF
Lessons from 4 years of driver develoment
PDF
“Webmapping Solutions: Technology & Tips” -- November 13, 2013
PPTX
How Build Infrastructure Powers the Node.js Foundation
PDF
Lessons Learned Setting Up the OSM Stack Workshop SotM US 2013
PDF
Apcug 2011 07-17-intro_to_drupal_jeff_schuler
PDF
Roll your own web crawler. RubyDay 2013
PDF
Laug comet intro july 2010
PDF
London Ajax User Group Meetup: Comet Panel
ODP
Open GeoData, Open GeoTools: An Introduction
PDF
Javantura v4 - CroDuke Indy and the Kingdom of Java Skills - Branko Mihaljevi...
Odnoklassniki.ru Architecture
The Diabolical Developer's Guide to Surviving Java 9
Ab(Using) the MetaCPAN API for Fun and Profit v2013
Back to the future with Java 7 (Geekout June/2011)
Red Dirt Ruby Conference
Ljc conf open jdk betterrev bof
萬國之津梁
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
Java Advanced Features (TCF 2014)
Lessons from 4 years of driver develoment
“Webmapping Solutions: Technology & Tips” -- November 13, 2013
How Build Infrastructure Powers the Node.js Foundation
Lessons Learned Setting Up the OSM Stack Workshop SotM US 2013
Apcug 2011 07-17-intro_to_drupal_jeff_schuler
Roll your own web crawler. RubyDay 2013
Laug comet intro july 2010
London Ajax User Group Meetup: Comet Panel
Open GeoData, Open GeoTools: An Introduction
Javantura v4 - CroDuke Indy and the Kingdom of Java Skills - Branko Mihaljevi...
Ad

More from Ignasi Marimon-Clos i Sunyol (9)

PDF
The Emperor Has No Docs (Geecon Oct'23)
PDF
Jeroglificos, Minotauros y la factura de la luz
PDF
Contributing to Akka (Hacktoberfest 2020)
PDF
Contributing to OSS (Scalator 2020-01-22)
PDF
Reactive Microsystems (Sw Crafters Barcelona 2018)
PDF
Lagom Workshop BarcelonaJUG 2017-06-08
PDF
Functional Programming in JAVA 8
PDF
Scala 101-bcndevcon
The Emperor Has No Docs (Geecon Oct'23)
Jeroglificos, Minotauros y la factura de la luz
Contributing to Akka (Hacktoberfest 2020)
Contributing to OSS (Scalator 2020-01-22)
Reactive Microsystems (Sw Crafters Barcelona 2018)
Lagom Workshop BarcelonaJUG 2017-06-08
Functional Programming in JAVA 8
Scala 101-bcndevcon

Recently uploaded (20)

PPTX
A Presentation on Touch Screen Technology
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
Approach and Philosophy of On baking technology
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
1. Introduction to Computer Programming.pptx
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
project resource management chapter-09.pdf
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
Enhancing emotion recognition model for a student engagement use case through...
A Presentation on Touch Screen Technology
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Unlocking AI with Model Context Protocol (MCP)
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
gpt5_lecture_notes_comprehensive_20250812015547.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Hindi spoken digit analysis for native and non-native speakers
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
SOPHOS-XG Firewall Administrator PPT.pptx
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Approach and Philosophy of On baking technology
Digital-Transformation-Roadmap-for-Companies.pptx
1. Introduction to Computer Programming.pptx
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
project resource management chapter-09.pdf
WOOl fibre morphology and structure.pdf for textiles
Enhancing emotion recognition model for a student engagement use case through...

Spray & Maven Intro for Scala Barcelona Developers Meetup

  • 1. A RESTy-JSON API with spray.io and maven sponsored by special appearance Ignasi Marimon-Clos i Sunyol @ignasi35 #scalabcn Sunday, June 16, 13
  • 3. special thank you’s JPradel (@agile_jordi): review and organization JCasadellà (@jcasadella): review JRudolph for simplifying step 4 https://github.com/jrudolph/scala-meetup-spray/commit/ c4991938ec7b26b183d701aac73949e7822cf45e Sunday, June 16, 13
  • 4. about me n. /iŋ'nazi/ 1) problem solver, Garbage Collector, mostly java, learning scala, some agile 2) kayaker 3) under construction 4) wears glasses Sunday, June 16, 13
  • 5. what we saw • BDD (cucumber) • TDD (scalatest) • sbt (inifinite run) • intelliJ • JAX-RS • Jetty https://github.com/funcio/bdd-jaxrs-hands-on Sunday, June 16, 13
  • 6. what we’ll see • BDD (cucumber) • TDD (scalatest) • sbt (inifinite run) • intelliJ • JAX-RS • Jetty • BDD (jbehave?) • TDD (scalatest) • mvn (infinite run) • eclipse (worksheet) • spray-can/https/... • spray-json https://github.com/ignasi35/scala-meetup-spray Sunday, June 16, 13
  • 7. why? (1/2) • I’m comfy with eclipse • I’m comfy with maven (I know that’s weird) • (no more)Typesafe delivers a prepacked env • still there s/where • eclipse-maven integration is solid • I needed infinite-test in maven at work • I like trolling Jordi and Jose Sunday, June 16, 13
  • 8. why? (2/2) • spray.io has akka • spray 1.x has akka 2.x • spray.io is modularized (that’s useful) • I don’t need java API (@see play) • spray-json is f*&[ing simple (via shapeless) http://spray.io/project-info/current-versions/ Sunday, June 16, 13
  • 9. why? (bonus) • spray.io beats all other JVM stacks/fw (*) http://www.techempower.com/benchmarks/ Sunday, June 16, 13
  • 10. spray modules provided provided There’s more provided dep’s than those labelled but we don’t need that level of detail now. credit: graphic made using yuml.me http://yuml.me/diagram/scruffy/class/[A]->[B],[A]->[C],[B]->[C] Sunday, June 16, 13
  • 11. spray • One thing done right • spray-routing => simple entry point. • @sirthias (Mathias Doenitz) in Akka 2.2 • magnet pattern • alternate to method overload • IOBridge, directives, Marshallers, ...??? Sunday, June 16, 13
  • 13. step 1 • Given an HTTP server • When I GET /hello • Then I obtain “hello” Sunday, June 16, 13
  • 14. step 1 (tips) • Edit a web.xml • Create a mapping • Provide a BeanConnectionBeanFactory • Add a servers.xml • Invoke the Olds Gods and the New Sunday, June 16, 13
  • 15. specially dedicated to @ch4lit Sunday, June 16, 13
  • 16. step 2 • Given an HTTP server • When I GET /hello.json • Then I obtain “{msg:‘world’}” Sunday, June 16, 13
  • 17. directives + complete • path/pathPrefix/pathTest • authenticate • get/post/delete/... • decodeRequest/encodeResponse/... • cache/alwaysCache/... • complete http://spray.io/documentation/spray-routing/predefined-directives-alphabetically/ Sunday, June 16, 13
  • 18. step 3 • Given an HTTP server • When I GET /books.json • Then I obtain the complete books stock Sunday, June 16, 13
  • 19. step 4 • Given an HTTP server • And I POST a book.txt in /books • When I GET /books.json • Then I obtain the updated books stock MEGA-KUDOS to https://github.com/jrudolph Sunday, June 16, 13
  • 20. step 5 • Given an HTTP server • And a programmatic HTTP client • When I GET /hello.json • Then I obtain “{msg:‘world’}” Sunday, June 16, 13
  • 21. conclusions • scala in maven is tough • mvn plugin lacks infini-run, infini-install,... • scala worksheet rocks • spray allows a quick entry point • docs and examples still to be improved • because I’m very dumb • ... Sunday, June 16, 13