SlideShare a Scribd company logo
1 of 28
Download to read offline
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/1
Modern Java Component Design
with Spring Framework 4.3
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Juergen Hoeller
Spring Framework Lead
Pivotal
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/2
The State of the Art: Component Classes
@Service
@Lazy
public class MyBookAdminService implements BookAdminService {
// @Autowired
public MyBookAdminService(AccountRepository repo) {
...
}
@Transactional
public BookUpdate updateBook(Addendum addendum) {
...
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/3
Composable Annotations
@Service
@Scope("session")
@Primary
@Transactional(rollbackFor=Exception.class)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyService {}
@MyService
public class MyBookAdminService {
...
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/4
Composable Annotations with Overridable Attributes
@Scope(scopeName="session")
@Retention(RetentionPolicy.RUNTIME)
public @interface MySessionScoped {
@AliasFor(annotation=Scope.class, attribute="proxyMode")
ScopedProxyMode mode() default ScopedProxyMode.NO;
}
@Transactional(rollbackFor=Exception.class)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyTransactional {
@AliasFor(annotation=Transactional.class)
boolean readOnly();
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/5
Convenient Scoping Annotations (out of the box)
■ Web scoping annotations coming with Spring Framework 4.3
● @RequestScope
● @SessionScope
● @ApplicationScope
■ Special-purpose scoping annotations across the Spring portfolio
● @RefreshScope
● @JobScope
● @StepScope
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/6
The State of the Art: Configuration Classes
@Configuration
@Profile("standalone")
@EnableTransactionManagement
public class MyBookAdminConfig {
@Bean
public BookAdminService myBookAdminService() {
MyBookAdminService service = new MyBookAdminService();
service.setDataSource(bookAdminDataSource());
return service;
}
@Bean
public BookAdminService bookAdminDataSource() {
...
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/7
Configuration Classes with Autowired Bean Methods
@Configuration
@Profile("standalone")
@EnableTransactionManagement
public class MyBookAdminConfig {
@Bean
public BookAdminService myBookAdminService(
DataSource bookAdminDataSource) {
MyBookAdminService service = new MyBookAdminService();
service.setDataSource(bookAdminDataSource);
return service;
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/8
Configuration Classes with Autowired Constructors
@Configuration
public class MyBookAdminConfig {
private final DataSource bookAdminDataSource;
// @Autowired
public MyBookAdminService(DataSource bookAdminDataSource) {
this.bookAdminDataSource = bookAdminDataSource;
}
@Bean
public BookAdminService myBookAdminService() {
MyBookAdminService service = new MyBookAdminService();
service.setDataSource(this.bookAdminDataSource);
return service;
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/9
Configuration Classes with Base Classes
@Configuration
public class MyApplicationConfig extends MyBookAdminConfig {
...
}
public class MyBookAdminConfig {
@Bean
public BookAdminService myBookAdminService() {
MyBookAdminService service = new MyBookAdminService();
service.setDataSource(bookAdminDataSource());
return service;
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/10
Configuration Classes with Java 8 Default Methods
@Configuration
public class MyApplicationConfig implements MyBookAdminConfig {
...
}
public interface MyBookAdminConfig {
@Bean
default BookAdminService myBookAdminService() {
MyBookAdminService service = new MyBookAdminService();
service.setDataSource(bookAdminDataSource());
return service;
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/11
Generics-based Injection Matching
@Bean
public MyRepository<Account> myAccountRepository() { ... }
@Bean
public MyRepository<Product> myProductRepository() { ... }
@Service
public class MyBookAdminService implements BookAdminService {
@Autowired
public MyBookAdminService(MyRepository<Account> repo) {
// specific match, even with other MyRepository beans around
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/12
Ordered Collection Injection
@Bean @Order(2)
public MyRepository<Account> myAccountRepositoryX() { ... }
@Bean @Order(1)
public MyRepository<Account> myAccountRepositoryY() { ... }
@Service
public class MyBookAdminService implements BookAdminService {
@Autowired
public MyBookAdminService(List<MyRepository<Account>> repos) {
// 'repos' List with two entries: repository Y first, then X
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/13
Injection of Collection Beans
@Bean
public List<Account> myAccountList() { ... }
@Service
public class MyBookAdminService implements BookAdminService {
@Autowired
public MyBookAdminService(List<Account> repos) {
// if no raw Account beans found, looking for a
// bean which is a List of Account itself
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/14
Lazy Injection Points
@Bean @Lazy
public MyRepository<Account> myAccountRepository() {
return new MyAccountRepositoryImpl();
}
@Service
public class MyBookAdminService implements BookAdminService {
@Autowired
public MyBookAdminService(@Lazy MyRepository<Account> repo) {
// 'repo' will be a lazy-initializing proxy
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/15
Component Declarations with JSR-250 & JSR-330
import javax.annotation.*;
import javax.inject.*;
@ManagedBean
public class MyBookAdminService implements BookAdminService {
@Inject
public MyBookAdminService(Provider<MyRepository<Account>> repo) {
// 'repo' will be a lazy handle, allowing for .get() access
}
@PreDestroy
public void shutdown() {
...
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/16
Optional Injection Points on Java 8
import java.util.*;
import javax.annotation.*;
import javax.inject.*;
@ManagedBean
public class MyBookAdminService implements BookAdminService {
@Inject
public MyBookAdminService(Optional<MyRepository<Account>> repo) {
if (repo.isPresent()) { ... }
}
@PreDestroy
public void shutdown() {
...
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/17
Declarative Formatting with Java 8 Date-Time
import java.time.*;
import javax.validation.constraints.*;
import org.springframework.format.annotation.*;
public class Customer {
// @DateTimeFormat(iso=ISO.DATE)
private LocalDate birthDate;
@DateTimeFormat(pattern="M/d/yy h:mm")
@NotNull @Past
private LocalDateTime lastContact;
...
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/18
Declarative Formatting with JSR-354 Money & Currency
import javax.money.*;
import org.springframework.format.annotation.*;
public class Product {
private MonetaryAmount basePrice;
@NumberFormat(pattern="¤¤ #000.000#")
private MonetaryAmount netPrice;
private CurrencyUnit originalCurrency;
...
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/19
Declarative Scheduling (with two Java 8 twists)
@Async
public Future<Integer> sendEmailNotifications() {
return new AsyncResult<Integer>(...);
}
@Async
public CompletableFuture<Integer> sendEmailNotifications() {
return CompletableFuture.completedFuture(...);
}
@Scheduled(cron="0 0 12 * * ?")
@Scheduled(cron="0 0 18 * * ?")
public void performTempFileCleanup() {
...
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/20
Annotated MVC Controllers
@RestController
@CrossOrigin
public class MyRestController {
@RequestMapping(path="/books/{id}", method=GET)
public Book findBook(@PathVariable long id) {
return this.bookAdminService.findBook(id);
}
@RequestMapping("/books/new")
public void newBook(@Valid Book book) {
this.bookAdminService.storeBook(book);
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/21
Precomposed Annotations for MVC Controllers
@RestController
@CrossOrigin
public class MyRestController {
@GetMapping("/books/{id}")
public Book findBook(@PathVariable long id) {
return this.bookAdminService.findBook(id);
}
@PostMapping("/books/new")
public void newBook(@Valid Book book) {
this.bookAdminService.storeBook(book);
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/22
STOMP on WebSocket
@Controller
public class MyStompController {
@SubscribeMapping("/positions")
public List<PortfolioPosition> getPortfolios(Principal user) {
...
}
@MessageMapping("/trade")
public void executeTrade(Trade trade, Principal user) {
...
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/23
Annotated JMS Endpoints
@JmsListener(destination="order")
public OrderStatus processOrder(Order order) {
...
}
@JmsListener(id="orderListener", containerFactory="myJmsFactory",
destination="order", selector="type='sell'", concurrency="2-10")
@SendTo("orderStatus")
public OrderStatus processOrder(Order order, @Header String type) {
...
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/24
Annotated Event Listeners
@EventListener
public void processEvent(MyApplicationEvent event) {
...
}
@EventListener
public void processEvent(String payload) {
...
}
@EventListener(condition="#payload.startsWith('OK')")
public void processEvent(String payload) {
...
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/25
Declarative Cache Interaction
@CacheConfig("books")
public class BookRepository {
@Cacheable(sync=true)
public Book findById(String id) {
}
@CachePut(key="#book.id")
public void updateBook(Book book) {
}
@CacheEvict
public void delete(String id) {
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/26
JCache (JSR-107) Support
import javax.cache.annotation.*;
@CacheDefaults(cacheName="books")
public class BookRepository {
@CacheResult
public Book findById(String id) {
}
@CachePut
public void updateBook(String id, @CacheValue Book book) {
}
@CacheRemove
public void delete(String id) {
}
}
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/27
Spring Framework 4.3 Roadmap
■ Last 4.x feature release!
■ 4.3 RC1: March 2016
■ 4.3 GA: May 2016
■ Extended support life until 2020
● on JDK 6, 7, 8 and 9
● on Tomcat 6, 7, 8 and 9
● on WebSphere 7, 8.0, 8.5 and 9
■ Spring Framework 5.0 coming in 2017
● on JDK 8+, Tomcat 7+, WebSphere 8.5+
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/28
Learn More. Stay Connected.
■ Current: Spring Framework 4.2.5
(February 2016)
■ Coming up: Spring Framework 4.3
(May 2016)
■ Check out Spring Boot!
http://projects.spring.io/spring-boot/
Twitter: twitter.com/springcentral
YouTube: spring.io/video
LinkedIn: spring.io/linkedin
Google Plus: spring.io/gplus

More Related Content

What's hot

Jsp and Servlets
Jsp and ServletsJsp and Servlets
Jsp and ServletsRaghu nath
 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depthVinay Kumar
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - CoreDzmitry Naskou
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVCDzmitry Naskou
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsKaml Sah
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892Tuna Tore
 
Spring MVC
Spring MVCSpring MVC
Spring MVCyuvalb
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with SpringJoshua Long
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC frameworkMohit Gupta
 
Multi client Development with Spring
Multi client Development with SpringMulti client Development with Spring
Multi client Development with SpringJoshua Long
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVCGuy Nir
 
Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC Naresh Chintalcheru
 
JEE Course - The Web Tier
JEE Course - The Web TierJEE Course - The Web Tier
JEE Course - The Web Tierodedns
 

What's hot (20)

Jsp and Servlets
Jsp and ServletsJsp and Servlets
Jsp and Servlets
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depth
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVC
 
Spring MVC Basics
Spring MVC BasicsSpring MVC Basics
Spring MVC Basics
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - Components
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with Spring
 
SpringMVC
SpringMVCSpringMVC
SpringMVC
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC framework
 
Spring Framework - III
Spring Framework - IIISpring Framework - III
Spring Framework - III
 
Weblogic
WeblogicWeblogic
Weblogic
 
Spring MVC 3.0 Framework
Spring MVC 3.0 FrameworkSpring MVC 3.0 Framework
Spring MVC 3.0 Framework
 
Multi client Development with Spring
Multi client Development with SpringMulti client Development with Spring
Multi client Development with Spring
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
 
Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC
 
JEE Course - The Web Tier
JEE Course - The Web TierJEE Course - The Web Tier
JEE Course - The Web Tier
 

Viewers also liked

Voxxed berlin2016profilers|
Voxxed berlin2016profilers|Voxxed berlin2016profilers|
Voxxed berlin2016profilers|Grzegorz Duda
 
Paolucci voxxed-days-berlin-2016-age-of-orchestration
Paolucci voxxed-days-berlin-2016-age-of-orchestrationPaolucci voxxed-days-berlin-2016-age-of-orchestration
Paolucci voxxed-days-berlin-2016-age-of-orchestrationGrzegorz Duda
 
Docker orchestration voxxed days berlin 2016
Docker orchestration   voxxed days berlin 2016Docker orchestration   voxxed days berlin 2016
Docker orchestration voxxed days berlin 2016Grzegorz Duda
 
The internet of (lego) trains
The internet of (lego) trainsThe internet of (lego) trains
The internet of (lego) trainsGrzegorz Duda
 
Cassandra and materialized views
Cassandra and materialized viewsCassandra and materialized views
Cassandra and materialized viewsGrzegorz Duda
 
Advanced akka features
Advanced akka featuresAdvanced akka features
Advanced akka featuresGrzegorz Duda
 
OrientDB - Voxxed Days Berlin 2016
OrientDB - Voxxed Days Berlin 2016OrientDB - Voxxed Days Berlin 2016
OrientDB - Voxxed Days Berlin 2016Luigi Dell'Aquila
 
Size does matter - How to cut (micro-)services correctly
Size does matter - How to cut (micro-)services correctlySize does matter - How to cut (micro-)services correctly
Size does matter - How to cut (micro-)services correctlyOPEN KNOWLEDGE GmbH
 
Rise of the Machines - Automate your Development
Rise of the Machines - Automate your DevelopmentRise of the Machines - Automate your Development
Rise of the Machines - Automate your DevelopmentSven Peters
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudEberhard Wolff
 
House style - Ashley Tonks
House style - Ashley TonksHouse style - Ashley Tonks
House style - Ashley Tonksnctcmedia12
 
Cambridge practice tests for ielts 6
Cambridge practice tests for ielts 6Cambridge practice tests for ielts 6
Cambridge practice tests for ielts 6Black Dragon
 
Informe ciudad
Informe ciudadInforme ciudad
Informe ciudadkode99
 
العزو السببي لدى الفرق الرياضية لمدارسة تربية محافظة نينوى
العزو السببي لدى الفرق الرياضية لمدارسة تربية محافظة نينوىالعزو السببي لدى الفرق الرياضية لمدارسة تربية محافظة نينوى
العزو السببي لدى الفرق الرياضية لمدارسة تربية محافظة نينوىMukhalad Hamza
 

Viewers also liked (20)

Voxxed berlin2016profilers|
Voxxed berlin2016profilers|Voxxed berlin2016profilers|
Voxxed berlin2016profilers|
 
Paolucci voxxed-days-berlin-2016-age-of-orchestration
Paolucci voxxed-days-berlin-2016-age-of-orchestrationPaolucci voxxed-days-berlin-2016-age-of-orchestration
Paolucci voxxed-days-berlin-2016-age-of-orchestration
 
Docker orchestration voxxed days berlin 2016
Docker orchestration   voxxed days berlin 2016Docker orchestration   voxxed days berlin 2016
Docker orchestration voxxed days berlin 2016
 
The internet of (lego) trains
The internet of (lego) trainsThe internet of (lego) trains
The internet of (lego) trains
 
Cassandra and materialized views
Cassandra and materialized viewsCassandra and materialized views
Cassandra and materialized views
 
Advanced akka features
Advanced akka featuresAdvanced akka features
Advanced akka features
 
OrientDB - Voxxed Days Berlin 2016
OrientDB - Voxxed Days Berlin 2016OrientDB - Voxxed Days Berlin 2016
OrientDB - Voxxed Days Berlin 2016
 
Size does matter - How to cut (micro-)services correctly
Size does matter - How to cut (micro-)services correctlySize does matter - How to cut (micro-)services correctly
Size does matter - How to cut (micro-)services correctly
 
Rise of the Machines - Automate your Development
Rise of the Machines - Automate your DevelopmentRise of the Machines - Automate your Development
Rise of the Machines - Automate your Development
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring Cloud
 
House style - Ashley Tonks
House style - Ashley TonksHouse style - Ashley Tonks
House style - Ashley Tonks
 
Chapter6 36pages
Chapter6 36pagesChapter6 36pages
Chapter6 36pages
 
Cambridge practice tests for ielts 6
Cambridge practice tests for ielts 6Cambridge practice tests for ielts 6
Cambridge practice tests for ielts 6
 
Redação científica i afonso
Redação científica i   afonsoRedação científica i   afonso
Redação científica i afonso
 
O ingilizce
O ingilizceO ingilizce
O ingilizce
 
Informe ciudad
Informe ciudadInforme ciudad
Informe ciudad
 
Organisation
OrganisationOrganisation
Organisation
 
Injury Prevention Programs
Injury Prevention ProgramsInjury Prevention Programs
Injury Prevention Programs
 
العزو السببي لدى الفرق الرياضية لمدارسة تربية محافظة نينوى
العزو السببي لدى الفرق الرياضية لمدارسة تربية محافظة نينوىالعزو السببي لدى الفرق الرياضية لمدارسة تربية محافظة نينوى
العزو السببي لدى الفرق الرياضية لمدارسة تربية محافظة نينوى
 
Tarifas x Planes
Tarifas x PlanesTarifas x Planes
Tarifas x Planes
 

Similar to Modern Java Component Design with Spring Framework 4.3

Cloud Native Java with Spring Cloud Services
Cloud Native Java with Spring Cloud ServicesCloud Native Java with Spring Cloud Services
Cloud Native Java with Spring Cloud ServicesVMware Tanzu
 
High Performance Cloud Native APIs Using Apache Geode
High Performance Cloud Native APIs Using Apache Geode High Performance Cloud Native APIs Using Apache Geode
High Performance Cloud Native APIs Using Apache Geode VMware Tanzu
 
Cloud-Native Streaming and Event-Driven Microservices
Cloud-Native Streaming and Event-Driven MicroservicesCloud-Native Streaming and Event-Driven Microservices
Cloud-Native Streaming and Event-Driven MicroservicesVMware Tanzu
 
Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache Calcite
Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache CalciteEnable SQL/JDBC Access to Apache Geode/GemFire Using Apache Calcite
Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache CalciteChristian Tzolov
 
Simplifying Apache Geode with Spring Data
Simplifying Apache Geode with Spring DataSimplifying Apache Geode with Spring Data
Simplifying Apache Geode with Spring DataVMware Tanzu
 
Lessons learned from upgrading Thymeleaf
Lessons learned from upgrading ThymeleafLessons learned from upgrading Thymeleaf
Lessons learned from upgrading ThymeleafVMware Tanzu
 
Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache Calcite
Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache CalciteEnable SQL/JDBC Access to Apache Geode/GemFire Using Apache Calcite
Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache CalciteVMware Tanzu
 
Under the Hood of Reactive Data Access (2/2)
Under the Hood of Reactive Data Access (2/2)Under the Hood of Reactive Data Access (2/2)
Under the Hood of Reactive Data Access (2/2)VMware Tanzu
 
Extending the Platform with Spring Boot and Cloud Foundry
Extending the Platform with Spring Boot and Cloud FoundryExtending the Platform with Spring Boot and Cloud Foundry
Extending the Platform with Spring Boot and Cloud FoundryKenny Bastani
 
Extending the Platform
Extending the PlatformExtending the Platform
Extending the PlatformVMware Tanzu
 
Kafka Summit NYC 2017 - Cloud Native Data Streaming Microservices with Spring...
Kafka Summit NYC 2017 - Cloud Native Data Streaming Microservices with Spring...Kafka Summit NYC 2017 - Cloud Native Data Streaming Microservices with Spring...
Kafka Summit NYC 2017 - Cloud Native Data Streaming Microservices with Spring...confluent
 
Quickly Build Spring Boot Applications to Consume Public Cloud Services
Quickly Build Spring Boot Applications to Consume Public Cloud ServicesQuickly Build Spring Boot Applications to Consume Public Cloud Services
Quickly Build Spring Boot Applications to Consume Public Cloud ServicesVMware Tanzu
 
SpringOnePlatform2017 recap
SpringOnePlatform2017 recapSpringOnePlatform2017 recap
SpringOnePlatform2017 recapminseok kim
 
12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...VMware Tanzu
 
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...cornelia davis
 
Resource Handling in Spring MVC 4.1
Resource Handling in Spring MVC 4.1Resource Handling in Spring MVC 4.1
Resource Handling in Spring MVC 4.1Rossen Stoyanchev
 
Under the Hood of Reactive Data Access (1/2)
Under the Hood of Reactive Data Access (1/2)Under the Hood of Reactive Data Access (1/2)
Under the Hood of Reactive Data Access (1/2)VMware Tanzu
 
Cloud-Native Streaming Platform: Running Apache Kafka on PKS (Pivotal Contain...
Cloud-Native Streaming Platform: Running Apache Kafka on PKS (Pivotal Contain...Cloud-Native Streaming Platform: Running Apache Kafka on PKS (Pivotal Contain...
Cloud-Native Streaming Platform: Running Apache Kafka on PKS (Pivotal Contain...VMware Tanzu
 
Caching for Microservives - Introduction to Pivotal Cloud Cache
Caching for Microservives - Introduction to Pivotal Cloud CacheCaching for Microservives - Introduction to Pivotal Cloud Cache
Caching for Microservives - Introduction to Pivotal Cloud CacheVMware Tanzu
 
What's new in Spring Boot 2.0
What's new in Spring Boot 2.0What's new in Spring Boot 2.0
What's new in Spring Boot 2.0VMware Tanzu
 

Similar to Modern Java Component Design with Spring Framework 4.3 (20)

Cloud Native Java with Spring Cloud Services
Cloud Native Java with Spring Cloud ServicesCloud Native Java with Spring Cloud Services
Cloud Native Java with Spring Cloud Services
 
High Performance Cloud Native APIs Using Apache Geode
High Performance Cloud Native APIs Using Apache Geode High Performance Cloud Native APIs Using Apache Geode
High Performance Cloud Native APIs Using Apache Geode
 
Cloud-Native Streaming and Event-Driven Microservices
Cloud-Native Streaming and Event-Driven MicroservicesCloud-Native Streaming and Event-Driven Microservices
Cloud-Native Streaming and Event-Driven Microservices
 
Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache Calcite
Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache CalciteEnable SQL/JDBC Access to Apache Geode/GemFire Using Apache Calcite
Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache Calcite
 
Simplifying Apache Geode with Spring Data
Simplifying Apache Geode with Spring DataSimplifying Apache Geode with Spring Data
Simplifying Apache Geode with Spring Data
 
Lessons learned from upgrading Thymeleaf
Lessons learned from upgrading ThymeleafLessons learned from upgrading Thymeleaf
Lessons learned from upgrading Thymeleaf
 
Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache Calcite
Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache CalciteEnable SQL/JDBC Access to Apache Geode/GemFire Using Apache Calcite
Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache Calcite
 
Under the Hood of Reactive Data Access (2/2)
Under the Hood of Reactive Data Access (2/2)Under the Hood of Reactive Data Access (2/2)
Under the Hood of Reactive Data Access (2/2)
 
Extending the Platform with Spring Boot and Cloud Foundry
Extending the Platform with Spring Boot and Cloud FoundryExtending the Platform with Spring Boot and Cloud Foundry
Extending the Platform with Spring Boot and Cloud Foundry
 
Extending the Platform
Extending the PlatformExtending the Platform
Extending the Platform
 
Kafka Summit NYC 2017 - Cloud Native Data Streaming Microservices with Spring...
Kafka Summit NYC 2017 - Cloud Native Data Streaming Microservices with Spring...Kafka Summit NYC 2017 - Cloud Native Data Streaming Microservices with Spring...
Kafka Summit NYC 2017 - Cloud Native Data Streaming Microservices with Spring...
 
Quickly Build Spring Boot Applications to Consume Public Cloud Services
Quickly Build Spring Boot Applications to Consume Public Cloud ServicesQuickly Build Spring Boot Applications to Consume Public Cloud Services
Quickly Build Spring Boot Applications to Consume Public Cloud Services
 
SpringOnePlatform2017 recap
SpringOnePlatform2017 recapSpringOnePlatform2017 recap
SpringOnePlatform2017 recap
 
12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...
 
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
 
Resource Handling in Spring MVC 4.1
Resource Handling in Spring MVC 4.1Resource Handling in Spring MVC 4.1
Resource Handling in Spring MVC 4.1
 
Under the Hood of Reactive Data Access (1/2)
Under the Hood of Reactive Data Access (1/2)Under the Hood of Reactive Data Access (1/2)
Under the Hood of Reactive Data Access (1/2)
 
Cloud-Native Streaming Platform: Running Apache Kafka on PKS (Pivotal Contain...
Cloud-Native Streaming Platform: Running Apache Kafka on PKS (Pivotal Contain...Cloud-Native Streaming Platform: Running Apache Kafka on PKS (Pivotal Contain...
Cloud-Native Streaming Platform: Running Apache Kafka on PKS (Pivotal Contain...
 
Caching for Microservives - Introduction to Pivotal Cloud Cache
Caching for Microservives - Introduction to Pivotal Cloud CacheCaching for Microservives - Introduction to Pivotal Cloud Cache
Caching for Microservives - Introduction to Pivotal Cloud Cache
 
What's new in Spring Boot 2.0
What's new in Spring Boot 2.0What's new in Spring Boot 2.0
What's new in Spring Boot 2.0
 

Recently uploaded

Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 

Recently uploaded (20)

Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 

Modern Java Component Design with Spring Framework 4.3

  • 1. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/1 Modern Java Component Design with Spring Framework 4.3 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Juergen Hoeller Spring Framework Lead Pivotal
  • 2. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/2 The State of the Art: Component Classes @Service @Lazy public class MyBookAdminService implements BookAdminService { // @Autowired public MyBookAdminService(AccountRepository repo) { ... } @Transactional public BookUpdate updateBook(Addendum addendum) { ... } }
  • 3. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/3 Composable Annotations @Service @Scope("session") @Primary @Transactional(rollbackFor=Exception.class) @Retention(RetentionPolicy.RUNTIME) public @interface MyService {} @MyService public class MyBookAdminService { ... }
  • 4. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/4 Composable Annotations with Overridable Attributes @Scope(scopeName="session") @Retention(RetentionPolicy.RUNTIME) public @interface MySessionScoped { @AliasFor(annotation=Scope.class, attribute="proxyMode") ScopedProxyMode mode() default ScopedProxyMode.NO; } @Transactional(rollbackFor=Exception.class) @Retention(RetentionPolicy.RUNTIME) public @interface MyTransactional { @AliasFor(annotation=Transactional.class) boolean readOnly(); }
  • 5. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/5 Convenient Scoping Annotations (out of the box) ■ Web scoping annotations coming with Spring Framework 4.3 ● @RequestScope ● @SessionScope ● @ApplicationScope ■ Special-purpose scoping annotations across the Spring portfolio ● @RefreshScope ● @JobScope ● @StepScope
  • 6. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/6 The State of the Art: Configuration Classes @Configuration @Profile("standalone") @EnableTransactionManagement public class MyBookAdminConfig { @Bean public BookAdminService myBookAdminService() { MyBookAdminService service = new MyBookAdminService(); service.setDataSource(bookAdminDataSource()); return service; } @Bean public BookAdminService bookAdminDataSource() { ... } }
  • 7. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/7 Configuration Classes with Autowired Bean Methods @Configuration @Profile("standalone") @EnableTransactionManagement public class MyBookAdminConfig { @Bean public BookAdminService myBookAdminService( DataSource bookAdminDataSource) { MyBookAdminService service = new MyBookAdminService(); service.setDataSource(bookAdminDataSource); return service; } }
  • 8. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/8 Configuration Classes with Autowired Constructors @Configuration public class MyBookAdminConfig { private final DataSource bookAdminDataSource; // @Autowired public MyBookAdminService(DataSource bookAdminDataSource) { this.bookAdminDataSource = bookAdminDataSource; } @Bean public BookAdminService myBookAdminService() { MyBookAdminService service = new MyBookAdminService(); service.setDataSource(this.bookAdminDataSource); return service; } }
  • 9. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/9 Configuration Classes with Base Classes @Configuration public class MyApplicationConfig extends MyBookAdminConfig { ... } public class MyBookAdminConfig { @Bean public BookAdminService myBookAdminService() { MyBookAdminService service = new MyBookAdminService(); service.setDataSource(bookAdminDataSource()); return service; } }
  • 10. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/10 Configuration Classes with Java 8 Default Methods @Configuration public class MyApplicationConfig implements MyBookAdminConfig { ... } public interface MyBookAdminConfig { @Bean default BookAdminService myBookAdminService() { MyBookAdminService service = new MyBookAdminService(); service.setDataSource(bookAdminDataSource()); return service; } }
  • 11. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/11 Generics-based Injection Matching @Bean public MyRepository<Account> myAccountRepository() { ... } @Bean public MyRepository<Product> myProductRepository() { ... } @Service public class MyBookAdminService implements BookAdminService { @Autowired public MyBookAdminService(MyRepository<Account> repo) { // specific match, even with other MyRepository beans around } }
  • 12. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/12 Ordered Collection Injection @Bean @Order(2) public MyRepository<Account> myAccountRepositoryX() { ... } @Bean @Order(1) public MyRepository<Account> myAccountRepositoryY() { ... } @Service public class MyBookAdminService implements BookAdminService { @Autowired public MyBookAdminService(List<MyRepository<Account>> repos) { // 'repos' List with two entries: repository Y first, then X } }
  • 13. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/13 Injection of Collection Beans @Bean public List<Account> myAccountList() { ... } @Service public class MyBookAdminService implements BookAdminService { @Autowired public MyBookAdminService(List<Account> repos) { // if no raw Account beans found, looking for a // bean which is a List of Account itself } }
  • 14. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/14 Lazy Injection Points @Bean @Lazy public MyRepository<Account> myAccountRepository() { return new MyAccountRepositoryImpl(); } @Service public class MyBookAdminService implements BookAdminService { @Autowired public MyBookAdminService(@Lazy MyRepository<Account> repo) { // 'repo' will be a lazy-initializing proxy } }
  • 15. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/15 Component Declarations with JSR-250 & JSR-330 import javax.annotation.*; import javax.inject.*; @ManagedBean public class MyBookAdminService implements BookAdminService { @Inject public MyBookAdminService(Provider<MyRepository<Account>> repo) { // 'repo' will be a lazy handle, allowing for .get() access } @PreDestroy public void shutdown() { ... } }
  • 16. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/16 Optional Injection Points on Java 8 import java.util.*; import javax.annotation.*; import javax.inject.*; @ManagedBean public class MyBookAdminService implements BookAdminService { @Inject public MyBookAdminService(Optional<MyRepository<Account>> repo) { if (repo.isPresent()) { ... } } @PreDestroy public void shutdown() { ... } }
  • 17. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/17 Declarative Formatting with Java 8 Date-Time import java.time.*; import javax.validation.constraints.*; import org.springframework.format.annotation.*; public class Customer { // @DateTimeFormat(iso=ISO.DATE) private LocalDate birthDate; @DateTimeFormat(pattern="M/d/yy h:mm") @NotNull @Past private LocalDateTime lastContact; ... }
  • 18. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/18 Declarative Formatting with JSR-354 Money & Currency import javax.money.*; import org.springframework.format.annotation.*; public class Product { private MonetaryAmount basePrice; @NumberFormat(pattern="¤¤ #000.000#") private MonetaryAmount netPrice; private CurrencyUnit originalCurrency; ... }
  • 19. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/19 Declarative Scheduling (with two Java 8 twists) @Async public Future<Integer> sendEmailNotifications() { return new AsyncResult<Integer>(...); } @Async public CompletableFuture<Integer> sendEmailNotifications() { return CompletableFuture.completedFuture(...); } @Scheduled(cron="0 0 12 * * ?") @Scheduled(cron="0 0 18 * * ?") public void performTempFileCleanup() { ... }
  • 20. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/20 Annotated MVC Controllers @RestController @CrossOrigin public class MyRestController { @RequestMapping(path="/books/{id}", method=GET) public Book findBook(@PathVariable long id) { return this.bookAdminService.findBook(id); } @RequestMapping("/books/new") public void newBook(@Valid Book book) { this.bookAdminService.storeBook(book); } }
  • 21. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/21 Precomposed Annotations for MVC Controllers @RestController @CrossOrigin public class MyRestController { @GetMapping("/books/{id}") public Book findBook(@PathVariable long id) { return this.bookAdminService.findBook(id); } @PostMapping("/books/new") public void newBook(@Valid Book book) { this.bookAdminService.storeBook(book); } }
  • 22. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/22 STOMP on WebSocket @Controller public class MyStompController { @SubscribeMapping("/positions") public List<PortfolioPosition> getPortfolios(Principal user) { ... } @MessageMapping("/trade") public void executeTrade(Trade trade, Principal user) { ... } }
  • 23. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/23 Annotated JMS Endpoints @JmsListener(destination="order") public OrderStatus processOrder(Order order) { ... } @JmsListener(id="orderListener", containerFactory="myJmsFactory", destination="order", selector="type='sell'", concurrency="2-10") @SendTo("orderStatus") public OrderStatus processOrder(Order order, @Header String type) { ... }
  • 24. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/24 Annotated Event Listeners @EventListener public void processEvent(MyApplicationEvent event) { ... } @EventListener public void processEvent(String payload) { ... } @EventListener(condition="#payload.startsWith('OK')") public void processEvent(String payload) { ... }
  • 25. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/25 Declarative Cache Interaction @CacheConfig("books") public class BookRepository { @Cacheable(sync=true) public Book findById(String id) { } @CachePut(key="#book.id") public void updateBook(Book book) { } @CacheEvict public void delete(String id) { } }
  • 26. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/26 JCache (JSR-107) Support import javax.cache.annotation.*; @CacheDefaults(cacheName="books") public class BookRepository { @CacheResult public Book findById(String id) { } @CachePut public void updateBook(String id, @CacheValue Book book) { } @CacheRemove public void delete(String id) { } }
  • 27. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/27 Spring Framework 4.3 Roadmap ■ Last 4.x feature release! ■ 4.3 RC1: March 2016 ■ 4.3 GA: May 2016 ■ Extended support life until 2020 ● on JDK 6, 7, 8 and 9 ● on Tomcat 6, 7, 8 and 9 ● on WebSphere 7, 8.0, 8.5 and 9 ■ Spring Framework 5.0 coming in 2017 ● on JDK 8+, Tomcat 7+, WebSphere 8.5+
  • 28. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/28 Learn More. Stay Connected. ■ Current: Spring Framework 4.2.5 (February 2016) ■ Coming up: Spring Framework 4.3 (May 2016) ■ Check out Spring Boot! http://projects.spring.io/spring-boot/ Twitter: twitter.com/springcentral YouTube: spring.io/video LinkedIn: spring.io/linkedin Google Plus: spring.io/gplus