Want to dive even deeper?

Take the course Java Spring Part: 1 by Bruce E. Hilton and become an expert!
Java Spring Part: 1
by Bruce E. Hilton

Check it out!
You're watching a preview of this video, click the button on the left to puchase the full version from Devoxx'09.

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.

Published on
  • 1.776
  • 14
  • 0
  • 0
  • 0
  • Using Spring in Scala Arjen Poutsma SpringSource by Pivotal
  • 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 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
  • 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 • 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 1. Constructor injection 2. @BeanProperty 3. Spring Scala & Spring 3.2+ SpringSource Confidential. Do not distribute without express permission
  • 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 • 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
  • <beans>        <bean  class="Person">                <constructor-­‐arg  value="John"/>                <constructor-­‐arg  value="Doe"/>        </bean> </beans> class  PersonConfiguration    extends  FunctionalConfiguration  {        bean()  {                new  Person("John",  "Doe")        } } SpringSource Confidential. Do not distribute without express permission
  • 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 • 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 http://bit.ly/s2gx13_free
  • Q &A

Comments

Be the first one to add a comment