SlideShare a Scribd company logo
1 of 100
Download to read offline
Spring 4
Ken Coenen, Dieter Hubau, Tim De Grande, Steve De Zitter,
Serguei Storojenko, Andreas Evers
Agenda
Steve De Zitter
Java SDK & EE support
Tim De Grande
Spring Core
Serguei Storojenko
Spring WebMVC
Ken Coenen
WebSockets and Messaging
Dieter Hubau
Testing improvements
Andreas Evers
Spring Core
Java 8 support
Java 8 features in Spring 4/4.1
▪ Lambda expressions
▪ Method references
▪ JSR-310 Date/Time Support
▪ Repeatable annotations
▪ Parameter name discovery
▪ Java.util.Optional
▪ Related new injection features
▪ Ordering, @Priority, Generic types
Java 8 lamda conventions
▪ Functional interfaces
▪ Typically callback interfaces such as Runnable/Callable
▪ Common functional interfaces in java.util.function
▪ Function, Predicate, Supplier
▪ Used extensively in Java8 Streams Api
Lambda conventions in Spring api’s
▪ TransactionTemplate with TransactionCallback
▪ JdbcTemplate/JdbcOperations with PreparedStatementSetter
▪ JdbcTemplate/JdbcOperations with RowMapper
▪ TaskExecutor
▪ ListenableFuture
Lambdas JdbcOperations example
▪ PreparedStatementSetter and RowMapper pre Java 8
List<Beer> beers = jdbcOperations.query(SELECT_BEER_BY_NAME_AND_ALCOHOL_PERCENTAGE,
new PreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps) throws SQLException{
ps.setString(1, "%" + name + "%");
ps.setBigDecimal(2, alcoholPercentage);
}
},
new RowMapper<Beer>() {
@Override
public Beer mapRow(ResultSet rs, int rowNum) throws SQLException{
return new Beer(rs.getLong("id"), rs.getString("name"),
rs.getString("description"),
rs.getBigDecimal("alcoholPercentage"),
rs.getTimestamp("modifiedTimestamp”));
}
}
);
Lambdas JdbcOperations example
▪ PreparedStatementSetter and RowMapper with lambdas
List<Beer> beers = jdbcOperations.query(
SELECT_BEER_BY_NAME_AND_ALCOHOL_PERCENTAGE,
ps -> {
ps.setString(1, "%" + name + "%");
ps.setBigDecimal( 2, alcoholPercentage);
},
(rs, rowNum) -> new Beer(rs.getLong( "id"),
rs.getString("name"),
rs.getString("description"),
rs.getBigDecimal( "alcoholPercentage”))
);
Lambdas TaskExecutor example
▪ TaskExecutor (ThreadPoolTaskExecutor) pre Java 8
return threadPoolTaskExecutor.submitListenable( new Callable<List<Beer>>() {
@Override
public List<Beer> call() throws Exception {
return beerRepository.getAllBeers();
}
});
▪ TaskExecutor with lambdas
return threadPoolTaskExecutor.submitListenable(
() -> beerRepository.getAllBeers()
);
ListenableFuture example
▪ ListenableFuture pre Java 8 with ListenableFutureCallback
ListenableFuture<List<Beer>> future =
taskExecutorService.getBeersAsyncUsingTaskExecutor();
future.addCallback( new ListenableFutureCallback<List<Beer>>() {
@Override
public void onFailure(Throwable throwable) {
//Handle Failure
}
@Override
public void onSuccess(List<Beer> beers) {
//Handle success
}
});
ListenableFuture example
▪ ListenableFuture pre Java 8 with success and failure callback
ListenableFuture<List<Beer>> future =
taskExecutorService.getBeersAsyncUsingTaskExecutor();
future.addCallback( new SuccessCallback<List<Beer>>() {
@Override
public void onSuccess(List<Beer> beers) {
//Handle success
}
}, new FailureCallback() {
@Override
public void onFailure(Throwable throwable) {
//Handle Failure
}
});
Lambdas ListenableFuture examples
▪ ListenableFuture with Lambdas
ListenableFuture<List<Beer>> listenableFuture = taskExecutorService.
getBeersAsyncUsingAnnotationsAndListenableFuture();
listenableFuture.addCallback((beers) -> {
beers.stream().forEach(System. out::println);
},
(throwable) -> {
//Handle failure
}
);
Method references
▪ PreparedStatementSetter and RowMapper method reference example
List<Beer> beers = jdbcOperations.query(
SELECT_BEER_BY_NAME_AND_ALCOHOL_PERCENTAGE,
ps -> {
ps.setString(1, "%" + name + "%");
ps.setBigDecimal( 2, alcoholPercentage);
},
this::mapRow
);
JSR-310 Date/Time Api
▪ Support for Java8 LocalDate, LocalDateTime, …
▪ @DateTimeFormat annotation is also applicable to Java8 Date/Time
types.
▪ Bind String to JSR-310 Date/Time objects
▪ Render JSR-310 objects to Strings
JSR-310 Date/Time Api support example
▪ Mapping incoming @PathVariable to LocalDateTime
@RequestMapping (value = "/modified/{modifiedDate}",method = RequestMethod.
GET)
public List<Beer> getBeersModifiedAfterDate(
@PathVariable @DateTimeFormat(pattern="ddMMyyyyHHmm”)
LocalDateTime modifiedDate){
return beerRepository.getBeersLastModifiedTimestampGreaterThan(
Timestamp.valueOf(modifiedDate));
}
▪ /modified/110320151930
JSR-310 Date/Time Api support example
▪ Domain object
public class Beer {
private Long id;
private String name;
private String description;
private BigDecimal alcoholPercentage;
// @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
private LocalDate since;
@DateTimeFormat (pattern = "ddMMyyyyHHmm")
private LocalDateTime modifiedTimestamp;
Rendering out the LocalDateTime property
▪ Jsp Snippet
Beer modified timestamp: <form:input path="modifiedTimestamp" />
▪ Renders:
Repeatable annotations
▪ @Scheduled
▪ @PropertySource
▪ …
@PropertySource
▪ Java 8 Repeatable annotations
@Configuration
@PropertySource ("classpath:/someProperties.properties")
@PropertySource ("classpath:/someProperties2.properties")
public class SpringConfiguration {
▪ Pre-java8
@Configuration
@PropertySources (value = {
@PropertySource ("classpath:/someProperties.properties"),
@PropertySource ("classpath:/someProperties2.properties")
})
public class SpringConfiguration {
@Scheduled
▪ Java 8 Repeatable annotations
@Scheduled(cron = "0 0 12 * * ?"),
@Scheduled(cron = "0 0 18 * * ?")
public void scheduledTask() {
System.out.println(message + LocalDateTime. now());
}
▪ Pre Java-8
@Schedules({
@Scheduled(cron = "0 0 12 * * ?"),
@Scheduled(cron = "0 0 18 * * ?")
})
public void scheduledTask() {
System.out.println(message + LocalDateTime. now());
}
Spring 4 Parameter discovery
▪ As of Spring 4.0 aware of Java8’s parameter reflection
▪ Parameter names now available in Spring through common Java8
reflection methods.
▪ Java8
▪ ‘-parameters’ compiler flag
▪ Java 6 and 7: via asm
▪ ‘-debug’ compiler flag
Spring 4 parameter discovery
▪ Without parameter discovery (no –debug or –parameters compilation flag)
@RequestMapping (value = "/{id}", method = RequestMethod. GET)
public Beer getBeerById( @PathVariable("id") Long id) {
return beerRepository.getBeerById(id);
}
▪ With Parameter discovery
@RequestMapping (value = "/{id}", method = RequestMethod. GET)
public Beer getBeerById( @PathVariable Long id) {
return beerRepository.getBeerById(id);
}
Spring data custom query parameter discovery
▪ Custom query in Spring data JPA without parameter name discovery
▪ Custom query in Spring data JPA with parameter name discovery
Java 8 Optional
▪ Java.util.Optional as method parameter type with annotations that have
required attribute
▪ @RequestParam
▪ @RequestHeader
▪ @MatrixVariable
▪ …
▪ Optional on Autowired dependencies
Optional MVC Handler method parameters
▪ Using required=false
@RequestMapping (value = "/{id}", method = RequestMethod. GET)
public Beer getBeerById(
@PathVariable Long id,
@RequestHeader(required=false) String country) {
if(country!=null)
System.out.println(country);
return beerRepository.getBeerById(id);
}
Optional on MVC handler method parameter
▪ Usage of Optional on @RequestHeader parameter
@RequestMapping (value = "/{id}", method = RequestMethod. GET)
public Beer getBeerById(
@PathVariable Long id,
@RequestHeader Optional<String> country) {
country.ifPresent(System.out::println);
return beerRepository.getBeerById(id);
}
Optional on Injected dependencies
▪ Required=false on dependency
@RestController
@RequestMapping ("/beers")
public class BeerController {
@Autowired(required = false)
private NotificationService notificationService;
▪ Using the dependency
@RequestMapping (value = "/{id}", method = RequestMethod. GET)
public Beer getBeerById(
@PathVariable Long id,
@RequestHeader Optional<String> country) {
if(notificationService != null)
notificationService.sendNotification("getBeerForId: " + id);
Optional on Injected dependencies
▪ Optional dependency
@RestController
@RequestMapping ("/beers")
public class BeerController {
@Autowired
private Optional<NotificationService> notificationService;
▪ Using the dependency
@RequestMapping (value = "/{id}", method = RequestMethod. GET)
public Beer getBeerById( @PathVariable Long id,
@RequestHeader Optional<String> country) {
notificationService.ifPresent(
service -> service.sendNotification( "getBeerForId: " + id)
);
return beerRepository.getBeerById(id);
}
Injection of Ordered Lists (Spring 4.0)
▪ Injection point or Ordered List
@RestController @RequestMapping ("/beers")
public class BeerController {
@Autowired
private List<MyService> services;
▪ MyService dependency with @Order(1)
@Service @Order (1)
public class MyServiceImpl implements MyService {
▪ MyService dependency with @Order(2)
@Service @Order (2)
public class MyOtherServiceImpl implements MyService {
▪ Injection point for Ordered List
@RestController @RequestMapping ("/beers")
public class BeerController {
@Autowired
private List<MyService> services;
▪ MyService dependency with @Order(1)
@Bean @Order(1)
public MyService service1() {
return new MyServiceImpl();
}
▪ MyService dependency with @Order(3)
@Bean @Order(3)
public MyService service2() {
return new MyOtherServiceImpl();
}
@Order on @Bean methods (Spring 4.1)
@javax.annotation.Priotity
▪ Injection point for Ordered List
@RestController
@RequestMapping ("/beers")
public class BeerController {
@Autowired
private List<MyService> services;
▪ MyService dependency with @Priority(1)
@Service @Priority (1)
public class MyServiceImpl implements MyService {
▪ MyService dependency with @Priority(2)
@Service @Priority (2)
public class MyOtherServiceImpl implements MyService {
@Priority for primary candidate selection
▪ Inject 1 Bean with multiple @Priority beans
@RestController @RequestMapping ("/beers")
public class BeerController {
@Autowired
private MyService service; //Injects MyServiceImpl
▪ Inject 1 Bean with multiple @Order beans
▪ Fails! Causes: org.springframework.beans.factory.
NoUniqueBeanDefinitionException
▪ This can be solved however!
▪ By Electing 1 of the @Order beans with @Primary (Spring 3 annotation)
@Service
@Order(1) @Primary
public class MyServiceImpl implements MyService {
@Qualifier for candidate selection
@Service @Qualifier ("myServiceImpl")
public class MyServiceImpl implements MyService {
@Service @Qualifier("myOtherServiceImpl")
public class MyOtherServiceImpl implements MyService {
@RestController @RequestMapping ("/beers")
public class BeerController {
@Autowired @Qualifier ("myServiceImpl")
private MyService service; //Injects MyServiceImpl
Generic type for candidate selection (Spring 4.0)
@Service
public class BeerServiceImpl implements MyService<Beer> {
@Service
public class MyOtherServiceImpl implements MyService<OtherEntity> {
@RestController @RequestMapping ("/beers")
public class BeerController {
@Autowired
private MyService<Beer> service; //Injects BeerServiceImpl
Sources and code
▪ Sources
▪ http://spring.io/blog/2015/01/14/springone2gx-2014-replay-spring-framework-on-java-8
▪ http://www.infoq.com/articles/spring-4-java-8
▪ http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#new-in-4.0
▪ http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#new-in-4.1
▪ Code
▪ GitHub: https://github.com/Turbots/spring4_workshop
▪ Maven module: spring4-java8-features
Core Spring
In the beginning there was… XML
In the beginning there was… XML
▪ Spring 3 made it possible to get rid of XML configuration for Spring (mostly)
@Configuration
But what about descriptions?
Spring 4 adds the @Description annotation
But what about descriptions? (2)
Spring 4 allows you to use all information to decide which beans to inject
through @Conditional
Different strokes for different folks
Different strokes for different folks (2)
Conditions have access to:
Different strokes for different folks (3)
Annotated object Condition Context
Annotations
Meta annotations
Class hierarchy
...
Bean definition registry
Scopes
Beans that are created
Classloader
Environment
Resources
...
One step further
In Spring 3
▪ Only at the class level
▪ @Lazy components get created
when they need to be injected.
Laziness
Spring 4
▪ Also at injection point
Laziness (2)
Web Improvements
48
General Web Improvements Spring 4.0
▪ Focused primarily on Servlet 3.0+ environments.
▪ WebSocket support
▪ New @RestController annotation
▪ New AsyncRestTemplate class
▪ Comprehensive time zone support
49
Focus on Servlet 3.0 + environments
▪ Deployment to Servlet 2.5 servers
remains an option
▪ Keep in mind: If you are using the
Spring MVC Test Framework you
will need to ensure that a Servlet
3.0 compatible JAR is in your test
classpath.
▪ Main practical implication: web.xml
is no longer needed (still
supported, though)
50
Interface WebApplicationInitializer
▪ WebApplicationInitializer must be used, if web.xml is not used
▪ DEMO
51
@RestController annotation
▪ Before spring 4.0
▪ Spring 4.0
52
AsyncRestTemplate
▪ Web applications often need to
query external REST services these
days. The very nature of HTTP and
synchronous calls can lead up to
challenges when scaling
applications for those needs:
multiple threads may be blocked,
waiting for remote HTTP responses.
53
AsyncRestTemplate (2)
▪ AsyncRestTemplate returns ListenableFuture wrapper instead of
concrete results as RestTemplate does.
▪ ListenableFuture accepts completion callbacks
54
ListenableFuture
▪ DEMO
55
Comprehensive time zone support
▪ Before Spring 4.0
56
Comprehensive time zone support (2)
▪ Spring 4.0: the new extension of LocaleContext provides TimeZone support
57
Comprehensive time zone support (3)
▪ Spring 4.0: new LocalContextResolver
58
Comprehensive time zone support (4)
▪ Out of box, there is a bunch of classes implementing
LocalContextResolver interface.
▪ Some of them support setting default TimeZone
▪ Some of them also support fall back to the server TimeZone
59
Comprehensive time zone support (5)
▪ When available, the user’s TimeZone can be obtained using the
RequestContext.getTimeZone() method.
▪ Time zone information will automatically be used by Date/Time Converter and
Formatter objects registered with Spring’s ConversionService.
60
Comprehensive time zone support (6)
Question
How to pass time zone info from the client to LocaleContext?
61
Comprehensive time zone support (7)
▪ Old good Locale scenario:
- Locale info passed as a request parameter (ex: user chooses language)
- Out-of-box LocaleChangeInterceptor would intercept the request and
set the required Locale in LocaleResolver
62
Comprehensive time zone support (8)
▪ Possible TimeZone scenario:
- TimeZone info passed as a request parameter (ex: JavaScript function
returning TimeZone)
- Extending LocaleChangeInterceptor (writing own interceptor) to
handle TimeZone info and setting the correct LocaleContext in
LocaleContextResolver
63
Spring 4.1 web improvement
▪ There is a number of small and bigger improvements. Further, in this
presentation some of them will be highlighted.
▪ For the complete and comprehensive list of the improvements, please, consult
the Spring documentation
64
JDK 1.8’s java.util.Optional support
▪ Optional is now supported for @RequestParam, @RequestHeader, and
@MatrixVariable controller method arguments.
▪ DEMO
65
@JsonView
▪ Jackson’s @JsonView is supported directly on @ResponseBody and
ResponseEntity controller methods for serializing different amounts of detail
for the same POJO (e.g. summary vs. detail page).
▪ Also supported with View-based rendering by adding the serialization view type
as a model attribute under a special key.
▪ DEMO
66
New type: RequestEntity
▪ Provides a builder-style API to guide client-side REST code towards the
preparation of HTTP requests.
▪ For example:
67
ResponseEntity provides builder-style API
▪ Example:
68
Full list of improvements
▪ Full list of improvements to be found here:
http://docs.spring.io/spring/docs/current/spring-framework-reference/html/new-in-
4.1.html
WebSockets
In the beginning there was… polling
Do you have
new data?
In the beginning there was… polling (2)
Do you have
new data?
No
In the beginning there was… polling (3)
In the beginning there was… polling (4)
Do you have
new data?
In the beginning there was… polling (5)
Do you have
new data?
No
In the beginning there was… polling (6)
In the beginning there was… polling (7)
Long polling
Do you have
new data?
Long polling (2)
Do you have
new data?
Long polling (3)
Do you have
new data?
Here is your
data
Polling disadvantages
● Client initiates a request (even with long polling mechanism)
● Traffic and overhead (even if there is no data!)
● Big delay between event and notification
● Consider server loads
And with HTML5 came… WebSockets!
What do you think about a
protocol upgrade?
And with HTML5 came… WebSockets! (2)
What do you think about a
protocol upgrade?
Sure, why not!
HTTP 101 Switching Protocols
And with HTML5 came… WebSockets! (3)
Open TCP socket
What about AJAX? Can I still use it?
AJAX
High latency (HTTP req/res for each
roundtrip)
Small to medium messages
WebSockets
Low latency (TCP socket remains
open)
Large and frequent messages
Realtime applications (stocks,
games, …)
● Not every project needs WebSockets!
WebSockets in Spring
● New Spring WebSocket module
● Fallback option with SockJS
● as underlying sub-protocol (https://stomp.github.io/)
○ Simple interoperable protocol for asynchronous messaging
○ Client actions: SEND, SUBSCRIBE / UNSUBSCRIBE, ACK / NACK
○ Server actions: MESSAGE, RECEIPT, ERROR
WebSockets in Spring (2)
● Generic Spring Messaging Module
○ Some Spring integration types promoted to Core (eg. Message,
@MessageMapping, …)
○ Also usable when using JMS
WebSockets in Spring (3)
@EnableWebSocket @EnableWebSocketMessageBroker
Raw WebSocket handler support
Extend TextWebSocketHandler or
BinaryWebSocketHandler and
implement handleTextMessage
WebSocket using a higher-level
messaging sub-protocol (eg. STOMP)
Raw example
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.TextMessage;
public class MyHandler extends TextWebSocketHandler {
@Override
public void handleTextMessage(WebSocketSession session, TextMessage msg) {
// ...
}
}
Raw example (2)
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(myHandler(), "/myHandler");
}
@Bean
public WebSocketHandler myHandler() {
return new MyHandler();
}
}
Demo application
● AngularJS application
● Spring WebMVC backend
● SockJS with higher-level STOMP protocol and Jackson serialization
Testing improvements
Cleaning up after Spring 3.x
Cleaning up after Spring 3.x (2)
● Many packages/classes/methods were marked as deprecated in the Spring 3.x version
● In Spring 4.x:
○ All deprecated packages have been removed
○ Many deprecated methods and fields have been removed
● Before upgrading from 3.x to 4.x → Look at the deprecation warnings!
Pruning in Spring 4.0
● Several things have been pruned to improve the testing experience
< 4.0 4.0+
No more JUnit 3.8 support Use JUnit 4 or TestNG
@ExpectedException Use @Test(expected = MyEx.class) or @Rule
@NotTransactional Use @Transactional(propagation = NOT_SUPPORTED)
SimpleJdbcTestUtils Use JdbcTestUtils or ScriptUtils or @Sql
Changes in dependencies in Spring 4.0
● Servlet API mocks → upgraded to Servlet 3.0 API
○ Servlet 3.0 API is easier, more powerful and more versatile
○ Servlet 2.5 API is still supported
● JUnit
○ minimum version 4.8
○ recommended version 4.11
● TestNG → Use version 6.8.5
Changes in dependencies in Spring 4.1
● Servlet API mocks → upgraded to Servlet 3.0 API
○ Servlet 3.0 API is easier, more powerful and more versatile
○ Servlet 2.5 API is still supported
● JUnit
○ minimum version 4.9 is supported
○ version 4.11 is recommended
● TestNG
○ version 6.8.8 is recommended
New in Spring 4.0
● SocketUtils
○ Used to scan for available UDP and TCP ports
○ Handy for setting up different containers / servers during integration tests
● ActiveProfilesResolver API
○ Programmatic alternative to static profile strings (like in Spring 3.x)
○ Use the resolver attribute in @ActiveProfiles annotation
● Meta-annotation support for tests
○ Easy to create annotations for your annotations
New in Spring 4.1
● Groovy scripts can be used to configure your Spring context
● Programmatically start/stop/commit your test transaction with
TestTransaction
● Default & Custom TestExecutionListeners can now be automatically
discovered
● Custom TestExecutionListeners can be merged with the default ones
● @Sql and @SqlConfig allow you to configure execution of SQL scripts
declaratively:
○ before/after a test class
○ before/after a test method
Demo
Questions

More Related Content

What's hot

JavaScript
JavaScriptJavaScript
JavaScriptSunil OS
 
Lecture 5 JSTL, custom tags, maven
Lecture 5   JSTL, custom tags, mavenLecture 5   JSTL, custom tags, maven
Lecture 5 JSTL, custom tags, mavenFahad Golra
 
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rulesSrijan Technologies
 
Getting Into Drupal 8 Configuration
Getting Into Drupal 8 ConfigurationGetting Into Drupal 8 Configuration
Getting Into Drupal 8 ConfigurationPhilip Norton
 
Java Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJava Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJoshua Long
 
Developing application for Windows Phone 7 in TDD
Developing application for Windows Phone 7 in TDDDeveloping application for Windows Phone 7 in TDD
Developing application for Windows Phone 7 in TDDMichele Capra
 
CQ5 QueryBuilder - .adaptTo(Berlin) 2011
CQ5 QueryBuilder - .adaptTo(Berlin) 2011CQ5 QueryBuilder - .adaptTo(Berlin) 2011
CQ5 QueryBuilder - .adaptTo(Berlin) 2011Alexander Klimetschek
 
HTML5 JavaScript APIs
HTML5 JavaScript APIsHTML5 JavaScript APIs
HTML5 JavaScript APIsRemy Sharp
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Andres Almiray
 
Spring & Hibernate
Spring & HibernateSpring & Hibernate
Spring & HibernateJiayun Zhou
 
Java EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSFJava EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSFJiayun Zhou
 
Java Unit Testing with Unitils
Java Unit Testing with UnitilsJava Unit Testing with Unitils
Java Unit Testing with UnitilsMikalai Alimenkou
 
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
Custom deployments with sbt-native-packager
Custom deployments with sbt-native-packagerCustom deployments with sbt-native-packager
Custom deployments with sbt-native-packagerGaryCoady
 
Top5 scalabilityissues withappendix
Top5 scalabilityissues withappendixTop5 scalabilityissues withappendix
Top5 scalabilityissues withappendixColdFusionConference
 
Commons Pool and DBCP
Commons Pool and DBCPCommons Pool and DBCP
Commons Pool and DBCPPhil Steitz
 
Spring Framework Petclinic sample application
Spring Framework Petclinic sample applicationSpring Framework Petclinic sample application
Spring Framework Petclinic sample applicationAntoine Rey
 

What's hot (20)

JavaScript
JavaScriptJavaScript
JavaScript
 
Lecture 5 JSTL, custom tags, maven
Lecture 5   JSTL, custom tags, mavenLecture 5   JSTL, custom tags, maven
Lecture 5 JSTL, custom tags, maven
 
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
 
Getting Into Drupal 8 Configuration
Getting Into Drupal 8 ConfigurationGetting Into Drupal 8 Configuration
Getting Into Drupal 8 Configuration
 
Java Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJava Configuration Deep Dive with Spring
Java Configuration Deep Dive with Spring
 
Developing application for Windows Phone 7 in TDD
Developing application for Windows Phone 7 in TDDDeveloping application for Windows Phone 7 in TDD
Developing application for Windows Phone 7 in TDD
 
CQ5 QueryBuilder - .adaptTo(Berlin) 2011
CQ5 QueryBuilder - .adaptTo(Berlin) 2011CQ5 QueryBuilder - .adaptTo(Berlin) 2011
CQ5 QueryBuilder - .adaptTo(Berlin) 2011
 
Nancy + rest mow2012
Nancy + rest   mow2012Nancy + rest   mow2012
Nancy + rest mow2012
 
HTML5 JavaScript APIs
HTML5 JavaScript APIsHTML5 JavaScript APIs
HTML5 JavaScript APIs
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
 
Spring & Hibernate
Spring & HibernateSpring & Hibernate
Spring & Hibernate
 
Java EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSFJava EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSF
 
Struts2 - 101
Struts2 - 101Struts2 - 101
Struts2 - 101
 
Java Unit Testing with Unitils
Java Unit Testing with UnitilsJava Unit Testing with Unitils
Java Unit Testing with Unitils
 
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
 
Custom deployments with sbt-native-packager
Custom deployments with sbt-native-packagerCustom deployments with sbt-native-packager
Custom deployments with sbt-native-packager
 
Top5 scalabilityissues withappendix
Top5 scalabilityissues withappendixTop5 scalabilityissues withappendix
Top5 scalabilityissues withappendix
 
Commons Pool and DBCP
Commons Pool and DBCPCommons Pool and DBCP
Commons Pool and DBCP
 
Spring Framework Petclinic sample application
Spring Framework Petclinic sample applicationSpring Framework Petclinic sample application
Spring Framework Petclinic sample application
 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
 

Viewers also liked

Spring 4 final xtr_presentation
Spring 4 final xtr_presentationSpring 4 final xtr_presentation
Spring 4 final xtr_presentationsourabh aggarwal
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring FrameworkDineesha Suraweera
 
Quartz: What is it?
Quartz: What is it?Quartz: What is it?
Quartz: What is it?alesialucy14
 
Getting Started with Spring Boot
Getting Started with Spring BootGetting Started with Spring Boot
Getting Started with Spring BootDavid Kiss
 
The Spring Framework: A brief introduction to Inversion of Control
The Spring Framework:A brief introduction toInversion of ControlThe Spring Framework:A brief introduction toInversion of Control
The Spring Framework: A brief introduction to Inversion of ControlVisualBee.com
 
Spring mvc my Faviourite Slide
Spring mvc my Faviourite SlideSpring mvc my Faviourite Slide
Spring mvc my Faviourite SlideDaniel Adenew
 
02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questions02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questionsDhiraj Champawat
 
Spring 3 Annotated Development
Spring 3 Annotated DevelopmentSpring 3 Annotated Development
Spring 3 Annotated Developmentkensipe
 
Spring Web Service, Spring JMS, Eclipse & Maven tutorials
Spring Web Service, Spring JMS, Eclipse & Maven tutorialsSpring Web Service, Spring JMS, Eclipse & Maven tutorials
Spring Web Service, Spring JMS, Eclipse & Maven tutorialsRaghavan Mohan
 
What's new in Spring 3?
What's new in Spring 3?What's new in Spring 3?
What's new in Spring 3?Craig Walls
 
Spring @Transactional Explained
Spring @Transactional ExplainedSpring @Transactional Explained
Spring @Transactional ExplainedSmita Prasad
 
Spring MVC Architecture Tutorial
Spring MVC Architecture TutorialSpring MVC Architecture Tutorial
Spring MVC Architecture TutorialJava Success Point
 

Viewers also liked (18)

Spring 4 final xtr_presentation
Spring 4 final xtr_presentationSpring 4 final xtr_presentation
Spring 4 final xtr_presentation
 
Spring framework core
Spring framework coreSpring framework core
Spring framework core
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
 
Next stop: Spring 4
Next stop: Spring 4Next stop: Spring 4
Next stop: Spring 4
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Quartz: What is it?
Quartz: What is it?Quartz: What is it?
Quartz: What is it?
 
Spring 3 to 4
Spring 3 to 4Spring 3 to 4
Spring 3 to 4
 
Getting Started with Spring Boot
Getting Started with Spring BootGetting Started with Spring Boot
Getting Started with Spring Boot
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring Mvc
Spring MvcSpring Mvc
Spring Mvc
 
The Spring Framework: A brief introduction to Inversion of Control
The Spring Framework:A brief introduction toInversion of ControlThe Spring Framework:A brief introduction toInversion of Control
The Spring Framework: A brief introduction to Inversion of Control
 
Spring mvc my Faviourite Slide
Spring mvc my Faviourite SlideSpring mvc my Faviourite Slide
Spring mvc my Faviourite Slide
 
02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questions02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questions
 
Spring 3 Annotated Development
Spring 3 Annotated DevelopmentSpring 3 Annotated Development
Spring 3 Annotated Development
 
Spring Web Service, Spring JMS, Eclipse & Maven tutorials
Spring Web Service, Spring JMS, Eclipse & Maven tutorialsSpring Web Service, Spring JMS, Eclipse & Maven tutorials
Spring Web Service, Spring JMS, Eclipse & Maven tutorials
 
What's new in Spring 3?
What's new in Spring 3?What's new in Spring 3?
What's new in Spring 3?
 
Spring @Transactional Explained
Spring @Transactional ExplainedSpring @Transactional Explained
Spring @Transactional Explained
 
Spring MVC Architecture Tutorial
Spring MVC Architecture TutorialSpring MVC Architecture Tutorial
Spring MVC Architecture Tutorial
 

Similar to Spring 4 - A&BP CC

03 form-data
03 form-data03 form-data
03 form-datasnopteck
 
Altitude NY 2018: Programming the edge workshop
Altitude NY 2018: Programming the edge workshopAltitude NY 2018: Programming the edge workshop
Altitude NY 2018: Programming the edge workshopFastly
 
Protocol-Oriented Networking
Protocol-Oriented NetworkingProtocol-Oriented Networking
Protocol-Oriented NetworkingMostafa Amer
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話Takehito Tanabe
 
Mock Servers - Fake All the Things!
Mock Servers - Fake All the Things!Mock Servers - Fake All the Things!
Mock Servers - Fake All the Things!Atlassian
 
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fastHow Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fastAtlassian
 
DWR, Hibernate and Dojo.E - A Tutorial
DWR, Hibernate and Dojo.E - A TutorialDWR, Hibernate and Dojo.E - A Tutorial
DWR, Hibernate and Dojo.E - A Tutorialjbarciauskas
 
Android Automated Testing
Android Automated TestingAndroid Automated Testing
Android Automated Testingroisagiv
 
Annotation processing and code gen
Annotation processing and code genAnnotation processing and code gen
Annotation processing and code genkoji lin
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐいHisateru Tanaka
 
What's Coming in Spring 3.0
What's Coming in Spring 3.0What's Coming in Spring 3.0
What's Coming in Spring 3.0Matt Raible
 
Top 10 F5 iRules to migrate to a modern load balancing platform
Top 10 F5 iRules to migrate to a modern load balancing platformTop 10 F5 iRules to migrate to a modern load balancing platform
Top 10 F5 iRules to migrate to a modern load balancing platformAvi Networks
 
ApacheCon: Abdera A Java Atom Pub Implementation
ApacheCon: Abdera A Java Atom Pub ImplementationApacheCon: Abdera A Java Atom Pub Implementation
ApacheCon: Abdera A Java Atom Pub ImplementationDavid Calavera
 
Lightning fast with Varnish
Lightning fast with VarnishLightning fast with Varnish
Lightning fast with VarnishVarnish Software
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API07.pallav
 

Similar to Spring 4 - A&BP CC (20)

03 form-data
03 form-data03 form-data
03 form-data
 
Altitude NY 2018: Programming the edge workshop
Altitude NY 2018: Programming the edge workshopAltitude NY 2018: Programming the edge workshop
Altitude NY 2018: Programming the edge workshop
 
Protocol-Oriented Networking
Protocol-Oriented NetworkingProtocol-Oriented Networking
Protocol-Oriented Networking
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
 
Mock Servers - Fake All the Things!
Mock Servers - Fake All the Things!Mock Servers - Fake All the Things!
Mock Servers - Fake All the Things!
 
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fastHow Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
 
RxSwift to Combine
RxSwift to CombineRxSwift to Combine
RxSwift to Combine
 
DWR, Hibernate and Dojo.E - A Tutorial
DWR, Hibernate and Dojo.E - A TutorialDWR, Hibernate and Dojo.E - A Tutorial
DWR, Hibernate and Dojo.E - A Tutorial
 
Android Automated Testing
Android Automated TestingAndroid Automated Testing
Android Automated Testing
 
Annotation processing and code gen
Annotation processing and code genAnnotation processing and code gen
Annotation processing and code gen
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
JSON and the APInauts
JSON and the APInautsJSON and the APInauts
JSON and the APInauts
 
What's Coming in Spring 3.0
What's Coming in Spring 3.0What's Coming in Spring 3.0
What's Coming in Spring 3.0
 
Top 10 F5 iRules to migrate to a modern load balancing platform
Top 10 F5 iRules to migrate to a modern load balancing platformTop 10 F5 iRules to migrate to a modern load balancing platform
Top 10 F5 iRules to migrate to a modern load balancing platform
 
RxSwift to Combine
RxSwift to CombineRxSwift to Combine
RxSwift to Combine
 
ApacheCon: Abdera A Java Atom Pub Implementation
ApacheCon: Abdera A Java Atom Pub ImplementationApacheCon: Abdera A Java Atom Pub Implementation
ApacheCon: Abdera A Java Atom Pub Implementation
 
Lightning fast with Varnish
Lightning fast with VarnishLightning fast with Varnish
Lightning fast with Varnish
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
Perl Dancer, FPW 2010
Perl Dancer, FPW 2010Perl Dancer, FPW 2010
Perl Dancer, FPW 2010
 

More from JWORKS powered by Ordina

Introduction to Webpack - Ordina JWorks - CC JS & Web
Introduction to Webpack - Ordina JWorks - CC JS & WebIntroduction to Webpack - Ordina JWorks - CC JS & Web
Introduction to Webpack - Ordina JWorks - CC JS & WebJWORKS powered by Ordina
 
Netflix OSS and HATEOAS deployed on production - JavaLand
Netflix OSS and HATEOAS deployed on production - JavaLandNetflix OSS and HATEOAS deployed on production - JavaLand
Netflix OSS and HATEOAS deployed on production - JavaLandJWORKS powered by Ordina
 
Cc internet of things LoRa and IoT - Innovation Enablers
Cc internet of things   LoRa and IoT - Innovation Enablers Cc internet of things   LoRa and IoT - Innovation Enablers
Cc internet of things LoRa and IoT - Innovation Enablers JWORKS powered by Ordina
 
Big data document and graph d bs - couch-db and orientdb
Big data  document and graph d bs - couch-db and orientdbBig data  document and graph d bs - couch-db and orientdb
Big data document and graph d bs - couch-db and orientdbJWORKS powered by Ordina
 
Big data key-value and column stores redis - cassandra
Big data  key-value and column stores redis - cassandraBig data  key-value and column stores redis - cassandra
Big data key-value and column stores redis - cassandraJWORKS powered by Ordina
 
Documenting your REST API with Swagger - JOIN 2014
Documenting your REST API with Swagger - JOIN 2014Documenting your REST API with Swagger - JOIN 2014
Documenting your REST API with Swagger - JOIN 2014JWORKS powered by Ordina
 
Android secure offline storage - CC Mobile
Android secure offline storage - CC MobileAndroid secure offline storage - CC Mobile
Android secure offline storage - CC MobileJWORKS powered by Ordina
 

More from JWORKS powered by Ordina (20)

Introduction to Webpack - Ordina JWorks - CC JS & Web
Introduction to Webpack - Ordina JWorks - CC JS & WebIntroduction to Webpack - Ordina JWorks - CC JS & Web
Introduction to Webpack - Ordina JWorks - CC JS & Web
 
Lagom in Practice
Lagom in PracticeLagom in Practice
Lagom in Practice
 
Netflix OSS and HATEOAS deployed on production - JavaLand
Netflix OSS and HATEOAS deployed on production - JavaLandNetflix OSS and HATEOAS deployed on production - JavaLand
Netflix OSS and HATEOAS deployed on production - JavaLand
 
Cc internet of things @ Thomas More
Cc internet of things @ Thomas MoreCc internet of things @ Thomas More
Cc internet of things @ Thomas More
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
An introduction to Cloud Foundry
An introduction to Cloud FoundryAn introduction to Cloud Foundry
An introduction to Cloud Foundry
 
Cc internet of things LoRa and IoT - Innovation Enablers
Cc internet of things   LoRa and IoT - Innovation Enablers Cc internet of things   LoRa and IoT - Innovation Enablers
Cc internet of things LoRa and IoT - Innovation Enablers
 
Mongodb @ vrt
Mongodb @ vrtMongodb @ vrt
Mongodb @ vrt
 
Mongo db intro.pptx
Mongo db intro.pptxMongo db intro.pptx
Mongo db intro.pptx
 
Big data document and graph d bs - couch-db and orientdb
Big data  document and graph d bs - couch-db and orientdbBig data  document and graph d bs - couch-db and orientdb
Big data document and graph d bs - couch-db and orientdb
 
Big data key-value and column stores redis - cassandra
Big data  key-value and column stores redis - cassandraBig data  key-value and column stores redis - cassandra
Big data key-value and column stores redis - cassandra
 
Hadoop bootcamp getting started
Hadoop bootcamp getting startedHadoop bootcamp getting started
Hadoop bootcamp getting started
 
Big data elasticsearch practical
Big data  elasticsearch practicalBig data  elasticsearch practical
Big data elasticsearch practical
 
Intro to cassandra
Intro to cassandraIntro to cassandra
Intro to cassandra
 
Android wear - CC Mobile
Android wear - CC MobileAndroid wear - CC Mobile
Android wear - CC Mobile
 
Clean Code - A&BP CC
Clean Code - A&BP CCClean Code - A&BP CC
Clean Code - A&BP CC
 
Unit testing - A&BP CC
Unit testing - A&BP CCUnit testing - A&BP CC
Unit testing - A&BP CC
 
Integration testing - A&BP CC
Integration testing - A&BP CCIntegration testing - A&BP CC
Integration testing - A&BP CC
 
Documenting your REST API with Swagger - JOIN 2014
Documenting your REST API with Swagger - JOIN 2014Documenting your REST API with Swagger - JOIN 2014
Documenting your REST API with Swagger - JOIN 2014
 
Android secure offline storage - CC Mobile
Android secure offline storage - CC MobileAndroid secure offline storage - CC Mobile
Android secure offline storage - CC Mobile
 

Recently uploaded

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 

Recently uploaded (20)

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 

Spring 4 - A&BP CC

  • 1. Spring 4 Ken Coenen, Dieter Hubau, Tim De Grande, Steve De Zitter, Serguei Storojenko, Andreas Evers
  • 2. Agenda Steve De Zitter Java SDK & EE support Tim De Grande Spring Core Serguei Storojenko Spring WebMVC Ken Coenen WebSockets and Messaging Dieter Hubau Testing improvements Andreas Evers Spring Core
  • 4. Java 8 features in Spring 4/4.1 ▪ Lambda expressions ▪ Method references ▪ JSR-310 Date/Time Support ▪ Repeatable annotations ▪ Parameter name discovery ▪ Java.util.Optional ▪ Related new injection features ▪ Ordering, @Priority, Generic types
  • 5. Java 8 lamda conventions ▪ Functional interfaces ▪ Typically callback interfaces such as Runnable/Callable ▪ Common functional interfaces in java.util.function ▪ Function, Predicate, Supplier ▪ Used extensively in Java8 Streams Api
  • 6. Lambda conventions in Spring api’s ▪ TransactionTemplate with TransactionCallback ▪ JdbcTemplate/JdbcOperations with PreparedStatementSetter ▪ JdbcTemplate/JdbcOperations with RowMapper ▪ TaskExecutor ▪ ListenableFuture
  • 7. Lambdas JdbcOperations example ▪ PreparedStatementSetter and RowMapper pre Java 8 List<Beer> beers = jdbcOperations.query(SELECT_BEER_BY_NAME_AND_ALCOHOL_PERCENTAGE, new PreparedStatementSetter() { @Override public void setValues(PreparedStatement ps) throws SQLException{ ps.setString(1, "%" + name + "%"); ps.setBigDecimal(2, alcoholPercentage); } }, new RowMapper<Beer>() { @Override public Beer mapRow(ResultSet rs, int rowNum) throws SQLException{ return new Beer(rs.getLong("id"), rs.getString("name"), rs.getString("description"), rs.getBigDecimal("alcoholPercentage"), rs.getTimestamp("modifiedTimestamp”)); } } );
  • 8. Lambdas JdbcOperations example ▪ PreparedStatementSetter and RowMapper with lambdas List<Beer> beers = jdbcOperations.query( SELECT_BEER_BY_NAME_AND_ALCOHOL_PERCENTAGE, ps -> { ps.setString(1, "%" + name + "%"); ps.setBigDecimal( 2, alcoholPercentage); }, (rs, rowNum) -> new Beer(rs.getLong( "id"), rs.getString("name"), rs.getString("description"), rs.getBigDecimal( "alcoholPercentage”)) );
  • 9. Lambdas TaskExecutor example ▪ TaskExecutor (ThreadPoolTaskExecutor) pre Java 8 return threadPoolTaskExecutor.submitListenable( new Callable<List<Beer>>() { @Override public List<Beer> call() throws Exception { return beerRepository.getAllBeers(); } }); ▪ TaskExecutor with lambdas return threadPoolTaskExecutor.submitListenable( () -> beerRepository.getAllBeers() );
  • 10. ListenableFuture example ▪ ListenableFuture pre Java 8 with ListenableFutureCallback ListenableFuture<List<Beer>> future = taskExecutorService.getBeersAsyncUsingTaskExecutor(); future.addCallback( new ListenableFutureCallback<List<Beer>>() { @Override public void onFailure(Throwable throwable) { //Handle Failure } @Override public void onSuccess(List<Beer> beers) { //Handle success } });
  • 11. ListenableFuture example ▪ ListenableFuture pre Java 8 with success and failure callback ListenableFuture<List<Beer>> future = taskExecutorService.getBeersAsyncUsingTaskExecutor(); future.addCallback( new SuccessCallback<List<Beer>>() { @Override public void onSuccess(List<Beer> beers) { //Handle success } }, new FailureCallback() { @Override public void onFailure(Throwable throwable) { //Handle Failure } });
  • 12. Lambdas ListenableFuture examples ▪ ListenableFuture with Lambdas ListenableFuture<List<Beer>> listenableFuture = taskExecutorService. getBeersAsyncUsingAnnotationsAndListenableFuture(); listenableFuture.addCallback((beers) -> { beers.stream().forEach(System. out::println); }, (throwable) -> { //Handle failure } );
  • 13. Method references ▪ PreparedStatementSetter and RowMapper method reference example List<Beer> beers = jdbcOperations.query( SELECT_BEER_BY_NAME_AND_ALCOHOL_PERCENTAGE, ps -> { ps.setString(1, "%" + name + "%"); ps.setBigDecimal( 2, alcoholPercentage); }, this::mapRow );
  • 14. JSR-310 Date/Time Api ▪ Support for Java8 LocalDate, LocalDateTime, … ▪ @DateTimeFormat annotation is also applicable to Java8 Date/Time types. ▪ Bind String to JSR-310 Date/Time objects ▪ Render JSR-310 objects to Strings
  • 15. JSR-310 Date/Time Api support example ▪ Mapping incoming @PathVariable to LocalDateTime @RequestMapping (value = "/modified/{modifiedDate}",method = RequestMethod. GET) public List<Beer> getBeersModifiedAfterDate( @PathVariable @DateTimeFormat(pattern="ddMMyyyyHHmm”) LocalDateTime modifiedDate){ return beerRepository.getBeersLastModifiedTimestampGreaterThan( Timestamp.valueOf(modifiedDate)); } ▪ /modified/110320151930
  • 16. JSR-310 Date/Time Api support example ▪ Domain object public class Beer { private Long id; private String name; private String description; private BigDecimal alcoholPercentage; // @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) private LocalDate since; @DateTimeFormat (pattern = "ddMMyyyyHHmm") private LocalDateTime modifiedTimestamp;
  • 17. Rendering out the LocalDateTime property ▪ Jsp Snippet Beer modified timestamp: <form:input path="modifiedTimestamp" /> ▪ Renders:
  • 18. Repeatable annotations ▪ @Scheduled ▪ @PropertySource ▪ …
  • 19. @PropertySource ▪ Java 8 Repeatable annotations @Configuration @PropertySource ("classpath:/someProperties.properties") @PropertySource ("classpath:/someProperties2.properties") public class SpringConfiguration { ▪ Pre-java8 @Configuration @PropertySources (value = { @PropertySource ("classpath:/someProperties.properties"), @PropertySource ("classpath:/someProperties2.properties") }) public class SpringConfiguration {
  • 20. @Scheduled ▪ Java 8 Repeatable annotations @Scheduled(cron = "0 0 12 * * ?"), @Scheduled(cron = "0 0 18 * * ?") public void scheduledTask() { System.out.println(message + LocalDateTime. now()); } ▪ Pre Java-8 @Schedules({ @Scheduled(cron = "0 0 12 * * ?"), @Scheduled(cron = "0 0 18 * * ?") }) public void scheduledTask() { System.out.println(message + LocalDateTime. now()); }
  • 21. Spring 4 Parameter discovery ▪ As of Spring 4.0 aware of Java8’s parameter reflection ▪ Parameter names now available in Spring through common Java8 reflection methods. ▪ Java8 ▪ ‘-parameters’ compiler flag ▪ Java 6 and 7: via asm ▪ ‘-debug’ compiler flag
  • 22. Spring 4 parameter discovery ▪ Without parameter discovery (no –debug or –parameters compilation flag) @RequestMapping (value = "/{id}", method = RequestMethod. GET) public Beer getBeerById( @PathVariable("id") Long id) { return beerRepository.getBeerById(id); } ▪ With Parameter discovery @RequestMapping (value = "/{id}", method = RequestMethod. GET) public Beer getBeerById( @PathVariable Long id) { return beerRepository.getBeerById(id); }
  • 23. Spring data custom query parameter discovery ▪ Custom query in Spring data JPA without parameter name discovery ▪ Custom query in Spring data JPA with parameter name discovery
  • 24. Java 8 Optional ▪ Java.util.Optional as method parameter type with annotations that have required attribute ▪ @RequestParam ▪ @RequestHeader ▪ @MatrixVariable ▪ … ▪ Optional on Autowired dependencies
  • 25. Optional MVC Handler method parameters ▪ Using required=false @RequestMapping (value = "/{id}", method = RequestMethod. GET) public Beer getBeerById( @PathVariable Long id, @RequestHeader(required=false) String country) { if(country!=null) System.out.println(country); return beerRepository.getBeerById(id); }
  • 26. Optional on MVC handler method parameter ▪ Usage of Optional on @RequestHeader parameter @RequestMapping (value = "/{id}", method = RequestMethod. GET) public Beer getBeerById( @PathVariable Long id, @RequestHeader Optional<String> country) { country.ifPresent(System.out::println); return beerRepository.getBeerById(id); }
  • 27. Optional on Injected dependencies ▪ Required=false on dependency @RestController @RequestMapping ("/beers") public class BeerController { @Autowired(required = false) private NotificationService notificationService; ▪ Using the dependency @RequestMapping (value = "/{id}", method = RequestMethod. GET) public Beer getBeerById( @PathVariable Long id, @RequestHeader Optional<String> country) { if(notificationService != null) notificationService.sendNotification("getBeerForId: " + id);
  • 28. Optional on Injected dependencies ▪ Optional dependency @RestController @RequestMapping ("/beers") public class BeerController { @Autowired private Optional<NotificationService> notificationService; ▪ Using the dependency @RequestMapping (value = "/{id}", method = RequestMethod. GET) public Beer getBeerById( @PathVariable Long id, @RequestHeader Optional<String> country) { notificationService.ifPresent( service -> service.sendNotification( "getBeerForId: " + id) ); return beerRepository.getBeerById(id); }
  • 29. Injection of Ordered Lists (Spring 4.0) ▪ Injection point or Ordered List @RestController @RequestMapping ("/beers") public class BeerController { @Autowired private List<MyService> services; ▪ MyService dependency with @Order(1) @Service @Order (1) public class MyServiceImpl implements MyService { ▪ MyService dependency with @Order(2) @Service @Order (2) public class MyOtherServiceImpl implements MyService {
  • 30. ▪ Injection point for Ordered List @RestController @RequestMapping ("/beers") public class BeerController { @Autowired private List<MyService> services; ▪ MyService dependency with @Order(1) @Bean @Order(1) public MyService service1() { return new MyServiceImpl(); } ▪ MyService dependency with @Order(3) @Bean @Order(3) public MyService service2() { return new MyOtherServiceImpl(); } @Order on @Bean methods (Spring 4.1)
  • 31. @javax.annotation.Priotity ▪ Injection point for Ordered List @RestController @RequestMapping ("/beers") public class BeerController { @Autowired private List<MyService> services; ▪ MyService dependency with @Priority(1) @Service @Priority (1) public class MyServiceImpl implements MyService { ▪ MyService dependency with @Priority(2) @Service @Priority (2) public class MyOtherServiceImpl implements MyService {
  • 32. @Priority for primary candidate selection ▪ Inject 1 Bean with multiple @Priority beans @RestController @RequestMapping ("/beers") public class BeerController { @Autowired private MyService service; //Injects MyServiceImpl ▪ Inject 1 Bean with multiple @Order beans ▪ Fails! Causes: org.springframework.beans.factory. NoUniqueBeanDefinitionException ▪ This can be solved however! ▪ By Electing 1 of the @Order beans with @Primary (Spring 3 annotation) @Service @Order(1) @Primary public class MyServiceImpl implements MyService {
  • 33. @Qualifier for candidate selection @Service @Qualifier ("myServiceImpl") public class MyServiceImpl implements MyService { @Service @Qualifier("myOtherServiceImpl") public class MyOtherServiceImpl implements MyService { @RestController @RequestMapping ("/beers") public class BeerController { @Autowired @Qualifier ("myServiceImpl") private MyService service; //Injects MyServiceImpl
  • 34. Generic type for candidate selection (Spring 4.0) @Service public class BeerServiceImpl implements MyService<Beer> { @Service public class MyOtherServiceImpl implements MyService<OtherEntity> { @RestController @RequestMapping ("/beers") public class BeerController { @Autowired private MyService<Beer> service; //Injects BeerServiceImpl
  • 35. Sources and code ▪ Sources ▪ http://spring.io/blog/2015/01/14/springone2gx-2014-replay-spring-framework-on-java-8 ▪ http://www.infoq.com/articles/spring-4-java-8 ▪ http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#new-in-4.0 ▪ http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#new-in-4.1 ▪ Code ▪ GitHub: https://github.com/Turbots/spring4_workshop ▪ Maven module: spring4-java8-features
  • 37. In the beginning there was… XML
  • 38. In the beginning there was… XML ▪ Spring 3 made it possible to get rid of XML configuration for Spring (mostly) @Configuration
  • 39. But what about descriptions?
  • 40. Spring 4 adds the @Description annotation But what about descriptions? (2)
  • 41. Spring 4 allows you to use all information to decide which beans to inject through @Conditional Different strokes for different folks
  • 42. Different strokes for different folks (2)
  • 43. Conditions have access to: Different strokes for different folks (3) Annotated object Condition Context Annotations Meta annotations Class hierarchy ... Bean definition registry Scopes Beans that are created Classloader Environment Resources ...
  • 45. In Spring 3 ▪ Only at the class level ▪ @Lazy components get created when they need to be injected. Laziness
  • 46. Spring 4 ▪ Also at injection point Laziness (2)
  • 48. 48 General Web Improvements Spring 4.0 ▪ Focused primarily on Servlet 3.0+ environments. ▪ WebSocket support ▪ New @RestController annotation ▪ New AsyncRestTemplate class ▪ Comprehensive time zone support
  • 49. 49 Focus on Servlet 3.0 + environments ▪ Deployment to Servlet 2.5 servers remains an option ▪ Keep in mind: If you are using the Spring MVC Test Framework you will need to ensure that a Servlet 3.0 compatible JAR is in your test classpath. ▪ Main practical implication: web.xml is no longer needed (still supported, though)
  • 50. 50 Interface WebApplicationInitializer ▪ WebApplicationInitializer must be used, if web.xml is not used ▪ DEMO
  • 51. 51 @RestController annotation ▪ Before spring 4.0 ▪ Spring 4.0
  • 52. 52 AsyncRestTemplate ▪ Web applications often need to query external REST services these days. The very nature of HTTP and synchronous calls can lead up to challenges when scaling applications for those needs: multiple threads may be blocked, waiting for remote HTTP responses.
  • 53. 53 AsyncRestTemplate (2) ▪ AsyncRestTemplate returns ListenableFuture wrapper instead of concrete results as RestTemplate does. ▪ ListenableFuture accepts completion callbacks
  • 55. 55 Comprehensive time zone support ▪ Before Spring 4.0
  • 56. 56 Comprehensive time zone support (2) ▪ Spring 4.0: the new extension of LocaleContext provides TimeZone support
  • 57. 57 Comprehensive time zone support (3) ▪ Spring 4.0: new LocalContextResolver
  • 58. 58 Comprehensive time zone support (4) ▪ Out of box, there is a bunch of classes implementing LocalContextResolver interface. ▪ Some of them support setting default TimeZone ▪ Some of them also support fall back to the server TimeZone
  • 59. 59 Comprehensive time zone support (5) ▪ When available, the user’s TimeZone can be obtained using the RequestContext.getTimeZone() method. ▪ Time zone information will automatically be used by Date/Time Converter and Formatter objects registered with Spring’s ConversionService.
  • 60. 60 Comprehensive time zone support (6) Question How to pass time zone info from the client to LocaleContext?
  • 61. 61 Comprehensive time zone support (7) ▪ Old good Locale scenario: - Locale info passed as a request parameter (ex: user chooses language) - Out-of-box LocaleChangeInterceptor would intercept the request and set the required Locale in LocaleResolver
  • 62. 62 Comprehensive time zone support (8) ▪ Possible TimeZone scenario: - TimeZone info passed as a request parameter (ex: JavaScript function returning TimeZone) - Extending LocaleChangeInterceptor (writing own interceptor) to handle TimeZone info and setting the correct LocaleContext in LocaleContextResolver
  • 63. 63 Spring 4.1 web improvement ▪ There is a number of small and bigger improvements. Further, in this presentation some of them will be highlighted. ▪ For the complete and comprehensive list of the improvements, please, consult the Spring documentation
  • 64. 64 JDK 1.8’s java.util.Optional support ▪ Optional is now supported for @RequestParam, @RequestHeader, and @MatrixVariable controller method arguments. ▪ DEMO
  • 65. 65 @JsonView ▪ Jackson’s @JsonView is supported directly on @ResponseBody and ResponseEntity controller methods for serializing different amounts of detail for the same POJO (e.g. summary vs. detail page). ▪ Also supported with View-based rendering by adding the serialization view type as a model attribute under a special key. ▪ DEMO
  • 66. 66 New type: RequestEntity ▪ Provides a builder-style API to guide client-side REST code towards the preparation of HTTP requests. ▪ For example:
  • 68. 68 Full list of improvements ▪ Full list of improvements to be found here: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/new-in- 4.1.html
  • 70. In the beginning there was… polling Do you have new data?
  • 71. In the beginning there was… polling (2) Do you have new data? No
  • 72. In the beginning there was… polling (3)
  • 73. In the beginning there was… polling (4) Do you have new data?
  • 74. In the beginning there was… polling (5) Do you have new data? No
  • 75. In the beginning there was… polling (6)
  • 76. In the beginning there was… polling (7)
  • 77. Long polling Do you have new data?
  • 78. Long polling (2) Do you have new data?
  • 79. Long polling (3) Do you have new data? Here is your data
  • 80. Polling disadvantages ● Client initiates a request (even with long polling mechanism) ● Traffic and overhead (even if there is no data!) ● Big delay between event and notification ● Consider server loads
  • 81. And with HTML5 came… WebSockets! What do you think about a protocol upgrade?
  • 82. And with HTML5 came… WebSockets! (2) What do you think about a protocol upgrade? Sure, why not! HTTP 101 Switching Protocols
  • 83. And with HTML5 came… WebSockets! (3) Open TCP socket
  • 84. What about AJAX? Can I still use it? AJAX High latency (HTTP req/res for each roundtrip) Small to medium messages WebSockets Low latency (TCP socket remains open) Large and frequent messages Realtime applications (stocks, games, …) ● Not every project needs WebSockets!
  • 85. WebSockets in Spring ● New Spring WebSocket module ● Fallback option with SockJS ● as underlying sub-protocol (https://stomp.github.io/) ○ Simple interoperable protocol for asynchronous messaging ○ Client actions: SEND, SUBSCRIBE / UNSUBSCRIBE, ACK / NACK ○ Server actions: MESSAGE, RECEIPT, ERROR
  • 86. WebSockets in Spring (2) ● Generic Spring Messaging Module ○ Some Spring integration types promoted to Core (eg. Message, @MessageMapping, …) ○ Also usable when using JMS
  • 87. WebSockets in Spring (3) @EnableWebSocket @EnableWebSocketMessageBroker Raw WebSocket handler support Extend TextWebSocketHandler or BinaryWebSocketHandler and implement handleTextMessage WebSocket using a higher-level messaging sub-protocol (eg. STOMP)
  • 88. Raw example import org.springframework.web.socket.WebSocketHandler; import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.TextMessage; public class MyHandler extends TextWebSocketHandler { @Override public void handleTextMessage(WebSocketSession session, TextMessage msg) { // ... } }
  • 89. Raw example (2) @Configuration @EnableWebSocket public class WebSocketConfig implements WebSocketConfigurer { @Override public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { registry.addHandler(myHandler(), "/myHandler"); } @Bean public WebSocketHandler myHandler() { return new MyHandler(); } }
  • 90. Demo application ● AngularJS application ● Spring WebMVC backend ● SockJS with higher-level STOMP protocol and Jackson serialization
  • 92. Cleaning up after Spring 3.x
  • 93. Cleaning up after Spring 3.x (2) ● Many packages/classes/methods were marked as deprecated in the Spring 3.x version ● In Spring 4.x: ○ All deprecated packages have been removed ○ Many deprecated methods and fields have been removed ● Before upgrading from 3.x to 4.x → Look at the deprecation warnings!
  • 94. Pruning in Spring 4.0 ● Several things have been pruned to improve the testing experience < 4.0 4.0+ No more JUnit 3.8 support Use JUnit 4 or TestNG @ExpectedException Use @Test(expected = MyEx.class) or @Rule @NotTransactional Use @Transactional(propagation = NOT_SUPPORTED) SimpleJdbcTestUtils Use JdbcTestUtils or ScriptUtils or @Sql
  • 95. Changes in dependencies in Spring 4.0 ● Servlet API mocks → upgraded to Servlet 3.0 API ○ Servlet 3.0 API is easier, more powerful and more versatile ○ Servlet 2.5 API is still supported ● JUnit ○ minimum version 4.8 ○ recommended version 4.11 ● TestNG → Use version 6.8.5
  • 96. Changes in dependencies in Spring 4.1 ● Servlet API mocks → upgraded to Servlet 3.0 API ○ Servlet 3.0 API is easier, more powerful and more versatile ○ Servlet 2.5 API is still supported ● JUnit ○ minimum version 4.9 is supported ○ version 4.11 is recommended ● TestNG ○ version 6.8.8 is recommended
  • 97. New in Spring 4.0 ● SocketUtils ○ Used to scan for available UDP and TCP ports ○ Handy for setting up different containers / servers during integration tests ● ActiveProfilesResolver API ○ Programmatic alternative to static profile strings (like in Spring 3.x) ○ Use the resolver attribute in @ActiveProfiles annotation ● Meta-annotation support for tests ○ Easy to create annotations for your annotations
  • 98. New in Spring 4.1 ● Groovy scripts can be used to configure your Spring context ● Programmatically start/stop/commit your test transaction with TestTransaction ● Default & Custom TestExecutionListeners can now be automatically discovered ● Custom TestExecutionListeners can be merged with the default ones ● @Sql and @SqlConfig allow you to configure execution of SQL scripts declaratively: ○ before/after a test class ○ before/after a test method
  • 99. Demo