Spring 4.0 - Evolution
or Revolution
Dominique Bartholdi, Raffael Schmid 

Trivadis AG
“work with Java 8 and other JVM
languages (e.g. support Lambdas, …)”
“responding to, and setting trends in
(Developer Productivity), Big Data,
Cloud, REST and Micro Service
Architecture”
-Adrian Colyer, CTO Application Fabric at Pivotal
Agenda
INTRODUCTION
MODERNISATION
BIG DATA
MICRO SERVICE ARCHITECTURE
CONCLUSION
* not our focus
Introduction
INTRODUCTION
MODERNISATION
BIG DATA
MICRO SERVICE ARCHITECTURE
CONCLUSION
* not our focus
a bunch of history
2004
Spring 1.0:
“lightweight” container (DI)
AOP interception
Jdbc abstraction,
Transaction support
JPetStore, Petclinic
2006 2007
Spring 2.0:
bean configuration
dialects (make
common tasks
easier)
Spring 2.5:
reduce XML based
configuration
custom namespaces
Spring 3.0:
task scheduling, …
with annotation
support
REST web apps
JEE features
Spring 4.0 / Spring IO

(Yummy Noodle Bar)
20132009
Platform Overview
Core
Framework Security Groovy Reactor
Relational Non-Relational
Data
Integration Batch Big DataWeb
Workload

Types
Execution
Spring XD Spring Boot Grails
*
Modernisation Big Data
*
* *
Micro Services

(Developer Productivity)
Spring 4.0
Spring 4.0
INTRODUCTION
MODERNISATION
BIG DATA
MICRO SERVICE ARCHITECTURE
CONCLUSION
* not our focus
Java 8 Lambdas
with Spring's JdbcTemplate
JdbcTemplate jt = new JdbcTemplate();
jt.query(QUERY, new PreparedStatementSetter() {
@Override

public void setValues(PreparedStatement ps) throws SQLException {
ps.setString(1, “Sales");

}
}, new RowMapper<Person>() {
@Override

public Person mapRow(ResultSet rs, int rowNum) throws SQLException {

return new Person(rs.getString(1), rs.getInt(2));

}

});
Java 8 Lambdas
with Spring's JdbcTemplate
JdbcTemplate jt = new JdbcTemplate(dataSource);
jt.query( QUERY, 

ps -> ps.setString(1, “Sales"), 

(rs, row) -> new Person(rs.getString(1), rs.getInt(2))

);
JSR 310: 

Date & Time
public class Customer {
@DateTimeFormat(iso=ISO.DATE) //default

private LocalDate birthDate;
@DateTimeFormat(pattern="M/d/yy h:mm")

private LocalDateTime lastContact;

…

}
Generics-based
Injection Matching
@Service

public class BookService {
@Autowired

public BookService(Repository<Book> repo) {
...
}
}
Generics-based
Injection Matching
@Bean

public Repository<Book> bookRepository() {
return new BookRepositoryImpl();
}
Web Sockets
@Configuration

@EnableWebSocket

public class MyWebSocketConfig implements WebSocketConfigurer {
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
WebSocketHandler echoHandler = new EchoHandler();

registry.addHandler(echoHandler, "/echo").withSockJS();
}
}
public interface WebSocketHandler {
void handleMessage(WebSocketSession s, WebSocketMessage<?> m);
}
and many more…
Conditional Bean definitions
@Conditional
@Autowired @Lazy on injection
points
@Order injection of arrays and lists
Groovy style Spring configs
BIG DATA
INTRODUCTION
MODERNISATION
BIG DATA
MICRO SERVICE ARCHITECTURE
CONCLUSION
-Pivotal
“Spring XD (Extreme Data) is a
unified, distributed, and extensible
service for data ingestion, real
time analytics, batch

processing, and data export.”
Spring XD
Spring XD
Combining established Spring
Technology: Spring Integration, Spring
Batch and Spring Data
Providing a scalable container
architecture
Domain Specific Language (DSL) for
configuration
Single vs
Distributed
XD Admin
XD Container
Module
Module
XD Admin
XD Container
Module
Module
XD Container
Module
Module
single node distributed nodes
in-memory
rabbit or redis
from source to sink
Sources
TAP Real time
analytics
Processor Sink Storage
Batch Jobs
STREAM
JOBS
Sources
- HTTP
- Tail
- File
- Mail
- Twitter Search
- Twitter Stream
- Gemfire
- Gemfire CQ
- Syslog
- TCP
- TCP Client
- JMS
- RabbitMQ
- Time
- MQTT
Stream Config
Create the stream

xd:> stream create --definition "HTTP | file"
--name mystream
use pipe (|) to connect source “HTTP” to
sink “file”
set name of stream to “mystream”
Remove the stream

xd:> stream destroy —name mystream
Spring XD Demo
twitter
stream
log
language
counter
tweet counter
stream create tweets --definition

"twitterstream | log”
stream create tweetcount --definition

"tap:stream:tweets > aggregatecounter”
stream create tweetlang --definition 

"tap:stream:tweets > field-value-counter --fieldName=lang"
MICRO SERVICE
ARCHITECTURE
INTRODUCTION
MODERNISATION
BIG DATA
MICRO SERVICE ARCHITECTURE
CONCLUSION
What’s exactly a MICRO
SERVICE ARCHITECTURE?
Develop a single application as suite of
small services
Organise services around business
capabilities (not technologies)
Smart endpoints, dumb pipes (less BPEL,
more REST)
Services do one thing (small enough to
throw away, fit into the head)
* http://martinfowler.com/articles/microservices.html
MICRO SERVICE vs.
monolithic architecture
* http://martinfowler.com/articles/microservices.html
functionality in one
single process
scaling by
replicating the
monolith
a micro architecture puts
each functionality into a
service
scaling by
distributing
services
Objectives for
MICRO SERVICES
simple packaging (executable jar) ->
embedded web containers
monitoring, expose insights
fast instantiation
polyglot persistence (SQL, NoSQL)
…
Spring Boot comes into
play
Spring Boot makes it easy to create stand-alone (Spring
based) applications that you can “just run”
Radically faster getting started experience
Well defined set of dependencies
Auto-configuration
“Non-functional” features out of the box
Metrics, Counters, Monitoring with Actuator
SSH access through remote shell
Spring Boot by
Example
Spring Boot
Conclusion
Not production-ready yet (version 1.0.0
still RC 5), but surprisingly stable
Packaging not only JAR
Will influence a bunch of other Spring
Projects (e.g. Spring XD, Roo, etc.)
Perfect tool for quickly building Spring
based applications
CONCLUSION
INTRODUCTION
MODERNISATION
BIG DATA
MICRO SERVICE ARCHITECTURE
CONCLUSION
* not our focus
Overall
Spring 4.0 evolved over the last
years
Spring IO most probably a
revolutionary approach (not only in
terms of marketing)
Questions
Dominique Bartholdi

emaiL: dominique.bartholdi@trivadis.com
!
Raffael Schmid

emaiL: raffael.schmid@trivadis.com

Spring 4.0 - Evolution or Revolution

  • 1.
    Spring 4.0 -Evolution or Revolution Dominique Bartholdi, Raffael Schmid 
 Trivadis AG
  • 2.
    “work with Java8 and other JVM languages (e.g. support Lambdas, …)” “responding to, and setting trends in (Developer Productivity), Big Data, Cloud, REST and Micro Service Architecture” -Adrian Colyer, CTO Application Fabric at Pivotal
  • 3.
    Agenda INTRODUCTION MODERNISATION BIG DATA MICRO SERVICEARCHITECTURE CONCLUSION * not our focus
  • 4.
  • 5.
    a bunch ofhistory 2004 Spring 1.0: “lightweight” container (DI) AOP interception Jdbc abstraction, Transaction support JPetStore, Petclinic 2006 2007 Spring 2.0: bean configuration dialects (make common tasks easier) Spring 2.5: reduce XML based configuration custom namespaces Spring 3.0: task scheduling, … with annotation support REST web apps JEE features Spring 4.0 / Spring IO
 (Yummy Noodle Bar) 20132009
  • 6.
    Platform Overview Core Framework SecurityGroovy Reactor Relational Non-Relational Data Integration Batch Big DataWeb Workload
 Types Execution Spring XD Spring Boot Grails * Modernisation Big Data * * * Micro Services
 (Developer Productivity) Spring 4.0
  • 7.
    Spring 4.0 INTRODUCTION MODERNISATION BIG DATA MICROSERVICE ARCHITECTURE CONCLUSION * not our focus
  • 8.
    Java 8 Lambdas withSpring's JdbcTemplate JdbcTemplate jt = new JdbcTemplate(); jt.query(QUERY, new PreparedStatementSetter() { @Override
 public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, “Sales");
 } }, new RowMapper<Person>() { @Override
 public Person mapRow(ResultSet rs, int rowNum) throws SQLException {
 return new Person(rs.getString(1), rs.getInt(2));
 }
 });
  • 9.
    Java 8 Lambdas withSpring's JdbcTemplate JdbcTemplate jt = new JdbcTemplate(dataSource); jt.query( QUERY, 
 ps -> ps.setString(1, “Sales"), 
 (rs, row) -> new Person(rs.getString(1), rs.getInt(2))
 );
  • 10.
    JSR 310: 
 Date& Time public class Customer { @DateTimeFormat(iso=ISO.DATE) //default
 private LocalDate birthDate; @DateTimeFormat(pattern="M/d/yy h:mm")
 private LocalDateTime lastContact;
 …
 }
  • 11.
    Generics-based Injection Matching @Service
 public classBookService { @Autowired
 public BookService(Repository<Book> repo) { ... } }
  • 12.
    Generics-based Injection Matching @Bean
 public Repository<Book>bookRepository() { return new BookRepositoryImpl(); }
  • 13.
    Web Sockets @Configuration
 @EnableWebSocket
 public classMyWebSocketConfig implements WebSocketConfigurer { public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { WebSocketHandler echoHandler = new EchoHandler();
 registry.addHandler(echoHandler, "/echo").withSockJS(); } } public interface WebSocketHandler { void handleMessage(WebSocketSession s, WebSocketMessage<?> m); }
  • 14.
    and many more… ConditionalBean definitions @Conditional @Autowired @Lazy on injection points @Order injection of arrays and lists Groovy style Spring configs
  • 15.
  • 16.
    -Pivotal “Spring XD (ExtremeData) is a unified, distributed, and extensible service for data ingestion, real time analytics, batch
 processing, and data export.” Spring XD
  • 17.
    Spring XD Combining establishedSpring Technology: Spring Integration, Spring Batch and Spring Data Providing a scalable container architecture Domain Specific Language (DSL) for configuration
  • 18.
    Single vs Distributed XD Admin XDContainer Module Module XD Admin XD Container Module Module XD Container Module Module single node distributed nodes in-memory rabbit or redis
  • 19.
    from source tosink Sources TAP Real time analytics Processor Sink Storage Batch Jobs STREAM JOBS
  • 20.
    Sources - HTTP - Tail -File - Mail - Twitter Search - Twitter Stream - Gemfire - Gemfire CQ - Syslog - TCP - TCP Client - JMS - RabbitMQ - Time - MQTT
  • 21.
    Stream Config Create thestream
 xd:> stream create --definition "HTTP | file" --name mystream use pipe (|) to connect source “HTTP” to sink “file” set name of stream to “mystream” Remove the stream
 xd:> stream destroy —name mystream
  • 22.
    Spring XD Demo twitter stream log language counter tweetcounter stream create tweets --definition
 "twitterstream | log” stream create tweetcount --definition
 "tap:stream:tweets > aggregatecounter” stream create tweetlang --definition 
 "tap:stream:tweets > field-value-counter --fieldName=lang"
  • 23.
  • 24.
    What’s exactly aMICRO SERVICE ARCHITECTURE? Develop a single application as suite of small services Organise services around business capabilities (not technologies) Smart endpoints, dumb pipes (less BPEL, more REST) Services do one thing (small enough to throw away, fit into the head) * http://martinfowler.com/articles/microservices.html
  • 25.
    MICRO SERVICE vs. monolithicarchitecture * http://martinfowler.com/articles/microservices.html functionality in one single process scaling by replicating the monolith a micro architecture puts each functionality into a service scaling by distributing services
  • 26.
    Objectives for MICRO SERVICES simplepackaging (executable jar) -> embedded web containers monitoring, expose insights fast instantiation polyglot persistence (SQL, NoSQL) …
  • 27.
    Spring Boot comesinto play Spring Boot makes it easy to create stand-alone (Spring based) applications that you can “just run” Radically faster getting started experience Well defined set of dependencies Auto-configuration “Non-functional” features out of the box Metrics, Counters, Monitoring with Actuator SSH access through remote shell
  • 28.
  • 29.
    Spring Boot Conclusion Not production-readyyet (version 1.0.0 still RC 5), but surprisingly stable Packaging not only JAR Will influence a bunch of other Spring Projects (e.g. Spring XD, Roo, etc.) Perfect tool for quickly building Spring based applications
  • 30.
    CONCLUSION INTRODUCTION MODERNISATION BIG DATA MICRO SERVICEARCHITECTURE CONCLUSION * not our focus
  • 31.
    Overall Spring 4.0 evolvedover the last years Spring IO most probably a revolutionary approach (not only in terms of marketing)
  • 32.