Presentation Using Spring in Scala

The Spring Framework is one of the most popular Java frameworks used today. While it is possible to use Spring in Scala, it does feel awkward in certain places, because of the "Javaism" peering through. For instance, using callback interfaces feels strange in Scala; functions would be a better match. In October 2012, I introduced the Spring Scala project, which solves this particular issue, and aims to make it easier to use Spring in Scala in general. In this session, we discuss the Spring Scala portfolio project and its feature set.

Speakers


PDF: slides.pdf

Slides

Using Spring in Scala

Using Spring in Scala Arjen Poutsma SpringSource by Pivotal

About me

About me • Twenty years of experience in Enterprise Software Development • Joined SpringSource in 2005 • Development lead of Spring Web Services • Development lead on Spring 3’s REST support • Dabbled into Scala in 2008 SpringSource Confidential. Do not distribute without express permission

Why Spring?

Why Spring?

Why Spring?

Why Spring? • • • • Why not? • 5 million developers (Gartner) Spring is more than DI Proven technology Over ten years of active development • • • Consistency Vested interest Solving todays practical problems • • NoSQL Social SpringSource Confidential. Do not distribute without express permission

Spring Scala

Spring Scala

Introducing Spring Scala

Introducing Spring Scala • New portfolio project • Goal: make it easier to use Spring in Scala • Built on top of the Spring Java Framework SpringSource Confidential. Do not distribute without express permission

Spring Scala Features

Spring Scala Features • Wiring up Scala Beans in XML • Wiring up Scala Beans in Scala • Support for Scala Collections • Scala-friendly versions of Spring Templates SpringSource Confidential. Do not distribute without express permission

Wiring up in XML

Wiring up in XML 1. Constructor injection 2. @BeanProperty 3. Spring Scala & Spring 3.2+ SpringSource Confidential. Do not distribute without express permission

Properties in Scala

Properties in Scala class  A(var  b:  String) public  class  A  { private  String  b; public  A(String  b)  { this.b  =  b; } public  String  b()  { return  b; } public  void  b_$eq(String  b)  { this.b  =  b; } }

Wiring up in Scala

Wiring up in Scala • FunctionalConfiguration (aka ScalaConfig) • Singletons and prototypes • Bean references • Configuration Composition • Importing XML and @Configuration • Init and destroy methods • Bean Profiles SpringSource Confidential. Do not distribute without express permission

                                                class  PersonConfiguration    extends  FunctionalConfiguration  {        bean()  {                new  Person("John",  "Doe")        } } SpringSource Confidential. Do not distribute without express permission

JmsTemplate

JmsTemplate val  connectionFactory  :  ConnectionFactory  =  ... val  template  =  new  JmsTemplate(connectionFactory) template.send("queue")  {        session:  Session  =>  session.            createTextMessage("Hello  World") } template.receive("queue")  match  {        case  Some(m:  TextMessage)=>  println(m.getText)        case  None  =>  println("No  text  message  received") } SpringSource Confidential. Do not distribute without express permission

Further info

Further info • Github repo opened October 2012 • First milestone released December 2012 • Second milestone released April 2013 • Community-driven https://github.com/SpringSource/spring-scala SpringSource Confidential. Do not distribute without express permission

SpringOne Giveaway

SpringOne Giveaway http://bit.ly/s2gx13_free

Q &A

Q &A