Spring, now part of Pivotal, continues to innovate and support next generation workloads. In this talk, I introduce some of the exciting new Spring technologies supporting websockets, Java 8, Java EE 7, data ingestion and stream processing, NoSQL and Hadoop, and production-ready REST, _and_ I introduce tools designed to expedite ramp-up time for teams who want to deliver, quickly.
2. ABOUT ME
interested in big data, the open
web, cloud and all things Spring.
About Josh Long @Starbuxman
josh@joshlong.com
josh.long@springsource.com
Developer Advocate
3. SPRING IS.. SPRING.IO
WEB
Controllers, REST,
WebSocket
INTEGRATION
Channels, Adapters,
Filters, Transformers
BATCH
Jobs, Steps,
Readers, Writers
BIG DATA
Ingestion, Export,
Orchestration, Hadoop
DATA
NON-RELATIONALRELATIONAL
CORE
GROOVYFRAMEWORK SECURITY REACTOR
GRAILS
Full-stack, Web
XD
Stream, Taps, Jobs
BOOT
Bootable, Minimal, Ops-Ready
12. SPRING WORKS IN MANY LANGUAGES
Spring loves the JVM:
Java (5,6,7, and 8), Groovy, Scala, etc.
13. SPRING WORKS IN MANY LANGUAGES
val applicationContext =
new FunctionalConfigApplicationContext( classOf[ServiceConfiguration])
// ServiceConfiguration.scala
class ServiceConfiguration extends FunctionalConfiguration {
importClass(classOf[DataSourceConfiguration])
val dataSource : DataSource = getBean(“dataSource”)
val jdbcTemplate = bean() {
new JdbcTemplate( dataSource )
}
val jdbcTransactionManager = bean(“txManager”) {
new JdbcTransactionManager(dataSource)
}
}
Scala
14. SPRING WORKS IN MANY LANGUAGES
def bb = new BeanBuilder()
bb.loadBeans("classpath:*SpringBeans.groovy")
def applicationContext = bb.createApplicationContext()
// MySpringBeans.groovy
import o.sf.jdbc.core.JdbcTemplate
import o.sf.jdbc.datasource.DataSourceTransactionManager
beans {
jdbcTemplate(JdbcTemplate) {
dataSource = dataSource
}
transactionManager(DataSourceTransactionManager) {
dataSource = dataSource
}
}
Groovy
15. SPRING WORKS IN MANY LANGUAGES
ApplicationContext applicationContext =
new AnnotationConfigApplicationContext( ServiceConfiguration.class);
// ServiceConfiguration.java
@Configuration
@ComponentScan
@Import(DataSourceConfiguration.class)
@EnableTransactionManagement
class ServiceConfiguration {
@Bean
public JdbcTemplate jdbcTemplate(DataSource dataSource) throws Exception {
return new JdbcTemplate( dataSource );
}
@Bean
public PlatformTransactionManager jdbcTransactionManager(DataSource dataSource){
return new JdbcTransactionManager (dataSource );
}
}
Java
16. SPRING WORKS IN MANY LANGUAGES
Java 8
a quick note on
Delayed again! from 09/2013 to as late as 03/2014!
Meanwhile, even has lambas...
...
C++
17. SPRING WORKS IN MANY LANGUAGES
Java 8
a quick note on
IDE Support:
IntelliJ IDEA has had Java 8 support for a year
Eclipse won’t have any until June 2014 (..!!)
Eclipse-based Spring Tool Suite (STS) has beta Java 8 support.
18. SPRING WORKS IN MANY LANGUAGES
Java 8
a quick note on
Spring 4.0 to be GA against Developer Preview by end of 2013.
Method references are a great fit for Spring!
JdbcTemplate jdbcTemplate;
// method references
private Customer map(ResultSet rs, int rowNum)
throws SQLException {
return new Customer( rs.getString("name"), rs.getInt("age") );
}
// let it satisfy the `RowMapper` functional interface
Customer customer = jdbcTemplate.queryForObject(
"select name, age from customers ",
this::map);
19. SPRING WORKS IN MANY LANGUAGES
Java 8
a quick note on
Spring 4.0 to be GA against Developer Preview by end of 2014.
lambas are a great fit for Spring!
JdbcTemplate jdbc;
Customer customer = jdbc.queryForObject(sql,
(rs, rowNum) -> new Customer(rs.getLong("id")));
20. SPRING WORKS IN MANY LANGUAGES
Java 8
a quick note on
Spring 4.0 to be GA against Developer Preview by end of 2014.
lambas are a great fit for Spring and Twitter!
21. SPRING WORKS IN MANY LANGUAGES
Java 8
a quick note on
JSR-310 - Date and Time
// declarative date format
import java.time.*;
import org.springframework.format.annotation.*;
public class Customer {
@DateTimeFormat(iso=ISO.DATE)
private LocalDate birthDate;
@DateTimeFormat(pattern="M/d/yy h:mm")
private LocalDateTime lastContact;
}
22. SPRING WORKS IN MANY LANGUAGES
Java 8
a quick note on
Repeatable Annotations
@Scheduled(cron = "0 0 12 * * ?")
@Scheduled(cron = "0 0 18 * * ?")
public void performTempFileCleanup() {
...
}
23. SPRING WORKS IN MANY LANGUAGES
Java 8
a quick note on
Spring 4.0
JDK 6 -> JDK 8
Java EE 5 (with JPA 2.0 feature pack) -> Java EE 7
24. SPRING RUNS WELL ON JAVA EE 7
Spring works well in Java EE environments
Supports Java EE 7: Date/Time API, JTA 1.2, JMS 2.0, JPA 2.1, Bean
Validation 1.1, the new concurrency API in JSR-236, Servlet 3.1, and
WebSockets (JSR 356)
Even participated in a few JSRs: the websocket JSR (356) and the
Batch JSR (352)
43. S P R I N G B O O T TO M C AT S A M P L E
Demo
44. SPRING IS.. MESSAGING AND INTEGRATION FRIENDLY
Spring gets (and sends!) websockets
WebSockets delegating to implementations on app servers like GlassFish,
Tomcat, and Jetty
Supports Sock.js server, superset of WS.
higher level STOMP supported on WS
supports JSR 356 (javax.websocket.*) support.