spring mvc 4.2: new and noteworthy
TRANSCRIPT
SPRINGONE2GXWASHINGTON, DC
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring MVC 4.2:New and Noteworthy
Rossen Stoyanchev
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
About Me
• Spring Framework committer
• Spring MVC
• Spring WebSocket
2
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Demo Source
3
https://github.com/rstoyanchev/s2gx2015-spring-mvc-42
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
HTTP Streaming
4
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring 3.2: Async Request Handling
• The ability to get off the Servlet container thread
• Take any controller method • replace return value T with DeferredResult<T>
• Range of use cases• long polling -- chat, live events• processing with latency -- scatter-gather, microservices
• Easy to introduce into existing apps
5
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring 4.0: WebSocket Messaging
• Full duplex messaging with SockJS emulation
• STOMP for application messaging• simple or external broker• @MessagingMapping methods for application work
• More advanced messaging needs• collaboration, games
• Very different from REST -- messaging architecture
6
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
• Return ResponseBodyEmitter rather than @ResponseBody
• Or ResponseEntity<ResponseBodyEmitter>
• Stream of serialized Objects, emitted from any thread
• Objects serialized with HttpMessageConverter
Spring 4.2: HTTP Streaming
7
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Example@RequestMapping(path = "/stream", method = GET)public ResponseBodyEmitter startStream() { ResponseBodyEmitter emitter = new ResponseBodyEmitter();
... return emitter;}
// Later on emitter.send(foo, MediaType.APPLICATION_JSON);...emitter.send(bar, MediaType.APPLICATION_JSON);... emitter.complete();
8
MediaType usedto select a converter
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
• Store ResponseBodyEmitter instances• in controller• in another component where events received
• Use onCompletion callback (on emitter) to remove instance
• Manual pub-sub to connected users
• Compare to STOMP + WebSocket• messaging protocol with built-in pub-sub
Pub-Sub
9
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
• Return SseEmitter, an extension of ResponseBodyEmitter
• HTTP streaming with event markup
Spring 4.2: Server-Sent Events
10
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Example@RequestMapping(path = "/stream", method = GET)public SseEmitter startStream() { SseEmitter emitter = new SseEmitter();
... return emitter;}
// Later on emitter.send(event().event().id("id").name("type").data(foo));...emitter.complete();
11
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring 4.2: Direct Streaming• No serialization with HttpMessageConverter
• Stream directly to the response
• Return StreamingResponseBody instead of @ResponseBody
• ResponseEntity<StreamingResponseBody>
12
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Example@RequestMapping(path = "/stream", method = GET)public StreamingResponseBody handle() {
return new StreamingResponseBody() {
@Override public void writeTo(OutputStream os) throws IOException { os.write(...); os.flush(); } };}
13
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
HTTP Streaming vs WebSocket Messaging• HTTP Streaming / SSE -- suited for simple streaming needs
• metrics, feeds
• STOMP / WebSocket scales to more advanced needs• finance, collaboration, games
• SockJS has lots of built-in smarts• fallback to polling if network/proxy prevents streaming• the extra mile for extra range of browsers
14
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
CORS
15
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
CORS Overview• Browsers prohibit requests to a different domain
• e.g. evil.com → bank.com
• CORS is a W3C specification for cross-domain requests
• For “simple” methods (GET, HEAD, POST)• browser sets Origin header
• Otherwise “preflight” request to obtain permission• HTTP OPTIONS• Origin and Access-Control-Request-Method headers
16
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
CORS Support in Spring?• Tomcat, Jetty, others provide CORS Filter implementations
• First-class support within Spring however still beneficial
• More fine-grained control (based on request mappings)
• Layer central + local configuration
17
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Local Configuration for @Controller• New @CrossOrigin annotation
• Supported on individual @RequestMapping methods
• Inherited from the class level
• Easy to configure one method or entire controller class hierarchy
18
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Local Configuration for Simple Handlers• Implement CorsConfigurationSource
• Two built-in handlers that make use this contract• ResourceHttpRequestHandler • SockJsHttpRequestHandler
public interface CorsConfigurationSource { CorsConfiguration getCorsConfiguration(HttpServletRequest req);}
19
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Central Configuration• The MVC Java config and MVC namespace expose CORS configuration
• Centralized configuration alternative• URL patterns based
• Layer central + local configuration• e.g. define general policy (e.g. allow csrf-token header)• refine locally
20
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
More on CORS Configuration• AbstractHandlerMapping drives overall CORS handling
• It’s an internal feature that’s always on• cross-domain not allowed by default (as before)
• DispatcherServlet allows preflight requests in for handling• no need to set dispatchOptionsRequest
21
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring MVC CORS and Spring Security• DispatcherServlet now provides CORS handling
• Spring Security needs to open HTTP OPTIONS (for preflight requests)
• There is work planned to improve this• only allow preflight requests with Spring MVC
22
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
CorsFilter • Filter-based approach to CORS configuration
• Comparable to Tomcat, Jetty filters
• CORS handling strictly before DispatcherServlet
• CorsFilter can/should be ordered before Spring Security Filter chain
23
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
HTTP Caching
24
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Goals• Update default settings in line with current browsers/proxies
• Improve options local to @MVC controllers
• Provide use-case oriented + advanced config
• Various other improvements• Cache-Control directives, eTag/LastModified support
25
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
CacheControl• Convenient “Cache-Control” response header value builder
• Covers the common use cases• CacheControl.maxAge(...)# cache for...• CacheControl.noStore() # prevent cache• CacheControl.noCache() # conditional cache + eTag/lastModified
• And the advanced• CacheControl.maxAge(...).noTransform().cachePublic()
26
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
WebContentGenerator• Central HTTP cache configuration class
• WebContentInterceptor, ResourceHttpRequestHandler
• Defaults settings revised• no more HTTP 1.0 headers (“Expires” and “Pragma”)• cacheSeconds shortcut relies CacheControl
• Accepts CacheControl builder for its configuration
• Plus existing cacheSeconds shortcut (becomes CacheControl)
27
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
@MVC• ResponseEntity supports HTTP cache settings
ResponseEntity.ok().cacheControl(CacheControl.maxAge(30, TimeUnit.DAYS)).eTag(version) // lastModified also available.body(book);
• Sets response headers + checks client conditional headers
• Sends 304 (“not modified”) if eTag matches
28
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
@MVC Continued• Explicit eTag / lastModified checks also possible
@RequestMappingpublic Object handle(WebRequest request) { long lastModified = ... if (request.checkNotModified(lastModified)) { return null; } // ... }
• Possible to check both eTag + lastModified (per recommendation)• request.checkNotModified(eTag,lastModified)
29
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Resource Handling• Extended HTTP cache control for serving static resources
• MVC Java config• ResourceHandlerRegistry accepts CacheControl
• MVC XML namespace• <mvc:cache-control> element within <mvc:resources>
• eTag added when VersionResourceResolver is configured
30
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Additional Reading• HTTP Caching Tutorial by Mark Nottingham
• Reference documentation HTTP Caching Support
• Notes in Migration from earlier versions wiki page
31
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Composable@RequestMapping
32
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Custom @RequestMapping• For example:
@PostJson("/input")public Object handle() { return … ;}
• Given custom annotation:
@RequestMapping(method=GET, produces="application/json")public @interface PostJson { String value() default "";}
•
•
33
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Shortcut Annotations? • Proposal to provide built-in shortcut annotations
• The challenge is finding the right mix
• Feedback based on specific use cases would help greatly
• SPR-13442 and spring-composed project
34
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Jackson
35
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Selective Serialization with @JsonView• Supported on @RequestMapping methods (since 4.1)
@RequestMapping @JsonView(SummaryView.class)public ResponseEntity<Foo> handle() { // … }
• Now also with @RequestBody
@RequestMapping(method = POST)public void handle(@JsonView(SummaryView.class) @RequestBody Foo foo) { // ...}
36
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Jackson Modules• Jackson2ObjectMapperBuilder auto-registers Jackson modules
• jdk7, joda, jsr310, jdk8
• Conditional on classpath detection of target dependencies
• Both MVC Java config and XML namespace use Jackson2ObjectMapperBuilder
37
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
@MVC
38
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Programming Model • HandlerMethod argument for @ExceptionHandler methods
• could be handy with @ControllerAdvice
• CharSequence as controller method return value (alternative to String)• groovy.lang.GString, StringBuilder, StringBuffer
• @InitBinder methods can register Formatter for specific field(s)• otherwise typically global in ConversionService
39
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Async Return Value Types• Built-in support for
• org.springframework.util.concurrent.ListenableFuture (4.1)• java.util.concurrent.CompletionStage (4.2)
• Both adapted to DeferredResult
• Easy to adapt others• RxJava Observable, Reactor Stream, …
• Follow example of built-in types
40
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
JavaScript Templating
41
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Why?• Traditionally HTML served then enhanced with JavaScript
• Trend towards generating the UI with JavaScript
• Address challenges for single-page apps
• As well as mobile devices
42
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
React JavaScript Library• Developed at Facebook and Instagram
• Virtual DOM with automatic DOM updates, fast, efficient
• Supports server-side rendering (outside of DOM)
• Fast adoption by major Internet players• Facebook/Instagram, Yahoo!, Netflix, Airbnb, etc.
43
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Server-Side Rendering• For React adopters, server-side rendering has significant benefits
• Faster load time, pre-generated HTML for web apps
• Search-engine friendly
• Client-centric UI still possible (e.g. Phonegap)
44
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring 4.2 and React• New view templating choice for JSR-223 scripting engines
• ScriptTemplateView , ViewResolver, and Configurer
• Configuration very similar to the alternatives (e.g. FreeMarker)
• Use with Nashorn JavaScript engine from JDK 8
45
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Additional Talks
Isomorphic Templating With Spring Boot, Nashorn and React
by Sebastien Deleuze
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js by Matt Raible
46
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
HTTP Byte Ranges
47
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Byte Ranges• HTTP 1.1 supports ability to download partial content
• RFC 7233
• Server advertises willingness via Accept-Ranges response header
• Client can then send a Range request header• e.g. Range: bytes=500-999
• Large media files, request any part / resume …
48
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Byte Range Support in Spring 4.2• HttpRange to create and parse ranges
• Accept-Range and Range exposed in HttpHeaders
• ResourceHttpRequestHandler supports byte ranges• e.g. server video files to iOS devices
49
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
$ curl -v --range 0-99 \ http://localhost:8080/assets/jquery-2.1.4.js
> GET /assets/jquery-2.1.4.js HTTP/1.1> Range: bytes=0-99...< HTTP/1.1 206 Partial Content< ...< Accept-Ranges: bytes< Content-Range: bytes 0-99/247597< Content-Length: 100< ...
50
Example
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Client Side
51
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
RestTemplate with OkHttp• RestTemplate + AsyncRestTemplate can be used with OkHttp
• lightweight HTTP library
• HTTP library support• JDK• Apache HttpComponents• Netty • OkHttp
52
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Flexible URI Template Handling• UriTemplateHandler for use with RestTemplate
• Default implementation delegates to UriComponentsBuilder
• Can be configured to• insert prefix in all URI templates• switch from path to path segment encoding by default
• Potential to plug in 3rd party URI template library• e.g. full RFC 6570 syntax
53
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
WebSocket Messaging
54
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Simple Broker: Heartbeats@Configuration@EnableWebSocketMessageBrokerstatic class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
// …
@Overridepublic void configureMessageBroker(MessageBrokerRegistry registry) { registry.enableSimpleBroker("/topic").setTaskScheduler(scheduler());}
@Bean @Primarypublic TaskScheduler scheduler() { return new ThreadPoolTaskScheduler();}
}
55
Enable
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Simple Broker: Selector Expression
56
• Add selector header on subscribe
client.subscribe("/topic/interval", function(message) { // ... }, {'selector' : 'headers.parity == \'even\''});
• SpEL expression evaluated against messages
• Only matching messages received
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Multi-Server User Destinations
57
• Spring supported special STOMP destination
• /user/{username}/…
• User receives message if connected
• User can be connected to any application server (since 4.2)
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Multi-Server User Destinations
58
Spring App
RabbitMQ
Browser
Sergi
/user/sergi/…
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Connected User Information• SimpUserRegistry bean
• Expose information about connected users and subscriptions
• Supported in multi-server scenarios• via UserRegistryMessageHandler
• Broadcast local user registry to other servers (via broker relay)• every 10 seconds• remote registry info expires after 20 seconds
59
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
STOMP Client• Supported over WebSocket + over TCP
• Plug in any Spring WebSocketClient implementation
• SockJsClient allows using STOMP over WebSocket/SockJS
• Support for heartbeats, receipts
60
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Programming Model• Property placeholders for @MessageMapping methods
• @JsonView on @Payload arguments
• Destination template variables in @SendTo annotation
• Async return value types• org.springframework.util.concurrent.ListenableFuture • CompletableFuture/CompletionStage (JDK 8)
61
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Programming Model• @ControllerAdvice + @MessageExceptionHandler methods
• HandlerMethod arguments for @MessageExceptionHandler
• Spring OXM Marshaller based MessageConverter
62
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Related Talk
From Zero to Hero with Spring WebSocket
by Sergi Almar
63
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 64
Thank You for Listening!
@rstoya05
Learn More. Stay Connected.
@springcentral Spring.io/video