Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
What's  new  in  
Spring  Framework  4.3/Boot  1.4  
+
Pivotal's Cloud  Native Approach
2016/05/21  JJUG  CCC  2016  Sprin...
Who  am  I  ?
•Toshiaki  Maki  (@making)
•https://blog.ik.am
•Sr.  Solutions  Architect
•Spring  Framework  enthusiast
Spr...
Agenda
•Spring  Boot  1.4  /  Spring  Framework  4.3
•Spring  Framework  5.0
•Spring  Cloud
•Go  to  Cloud  Native
Spring  Boot
https://twitter.com/phillip_̲webb/status/641444531867680768
Spring  Initializr https://start.spring.io/
Spring  Initializr https://start.spring.io/
Spring  Initializr https://start.spring.io/
Spring  Boot  Adoption
Roadmap
Spring  Framework
Spring  Boot
2016  JUN 2017〜~
4.3	
  GA
1.4	
  GA
5.0	
  RC1
2.0	
  GA
5.0	
  M1 5.0	
  GA
Spring  Boot  1.4
•Banner  Update
•Test  Improvements
•Spring  Framework  4.3  Support
•Misc
https://github.com/spring-‐‑‒...
Spring  Boot  1.4
•Banner  Update
•Test  Improvements
•Spring  Framework  4.3  Support
•Misc
https://github.com/spring-‐‑‒...
Spring  Boot  with  Banner
👈
Spring  Boot  with  Banner
src/main/resrouces/banner.txt
•1.1  supported  Custom  Text  Banner  
Spring  Boot  with  Banner
•1.3  supported  ANSI  Color  Banner  
${AnsiColor.BRIGHT_GREEN}My Application
${AnsiColor.BRIG...
IntelliJ IDEA's  Support
Nyan Cat!
https://github.com/snicoll-‐‑‒demos/spring-‐‑‒boot-‐‑‒4tw-‐‑‒uni/blob/master/spring-‐‑‒boot-‐‑‒4tw-‐‑‒web/src/ma...
Spring  Boot  with  Banner
•1.4  supports  Image  Banner!!
Spring  Boot  with  Banner
•1.4  supports  Image  Banner!!
src/main/resrouces/banner.png
Spring  Boot  with  Banner
•1.4  supports  Image  Banner!!
src/main/resrouces/banner.png
Tweet
your  banner
#tweetbootbanner
Spring  Boot  1.4
•Banner  Update
•Test  Improvements
•Spring  Framework  4.3  Support
•Misc
https://github.com/spring-‐‑‒...
Test  Improvements
•Test  simplifications
•Mocking  and  spying
•Testing  application  slices
Test  simplifications
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(MyApp.class)
@WebIntegration...
Test  simplifications
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)
public class...
Test  simplifications
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)
public class...
Test  simplifications
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)
public class...
Mocking  and  spying
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(MyApp.class)
@WebIntegrationT...
Mocking  and  spying
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(MyApp.class)
@WebIntegrationT...
Testing  application  slices
•Testing  the  JPA  slice
•Testing  the  Spring  MVC  slice
•Testing  the  JSON  slice
for  f...
Testing  the  JPA  slice
@RunWith(SpringRunner.class)
@DataJpaTest
public class UserRepositoryTests {
@Autowired TestEntit...
Testing  the  Spring  MVC  slice
@RunWith(SpringRunner.class)
@WebMvcTest(FooController.class)
public class FooControllerT...
Testing  the  Spring  MVC  slice
@RunWith(SpringRunner.class)
@WebMvcTest(FooController.class)
public class FooControllerT...
Testing  the  Spring  MVC  slice
@RunWith(SpringRunner.class)
@WebMvcTest(FooController.class)
public class FooControllerT...
Testing  the  JSON  slice
@RunWith(SpringRunner.class)
@JsonTest
public class MyJsonTests {
JacksonTester<VehicleDetails> ...
Testing  the  JSON  slice
@RunWith(SpringRunner.class)
@JsonTest
public class MyJsonTests {
JacksonTester<VehicleDetails> ...
Spring  Boot  1.4
•Banner  Update
•Test  Improvements
•Spring  Framework  4.3  Support
•Misc
https://github.com/spring-‐‑‒...
Spring  Framework  4.3
• Last  4.x  feature  release!
• 4.3  RC1:  April  6th
• 4.3  GA:  June  1st,  2016
• DI  &  MVC  r...
Spring  Framework  4.3
• Implicit  constructor  injection
• InjectionPoint like  CDI
• ....
• Composed  annotations  for  ...
Implicit  constructor  injection
@RestController
public class FooController {
private final FooService fooService;
@Autowi...
Implicit  constructor  injection
@RestController
public class FooController {
private final FooService fooService;
public ...
Implicit  constructor  injection
@RestController
@AllArgsConstructor(onConstructor = @_(@Autowired))
public class FooContr...
Implicit  constructor  injection
@RestController
@AllArgsConstructor
public class FooController {
private final FooService...
InjectionPoint like  CDI
@RestController
public class FooController {
@Autowired
@Xyz("bar")
FooService service;
}
InjectionPoint like  CDI
@Configuration
public class FooConfig {
@Bean
FooService foo(InjectionPoint ip) {
AnnotatedElemen...
Composed  annotations  for
@RequestMapping
•@GetMapping
•@PostMapping
•@PutMapping
•@DeleteMapping
•@PatchMapping
@RestController
public class FooController {
@RequestMapping(path = "foo", method = GET)
String getFoo() {/* ... */}
@Requ...
@RestController
public class FooController {
@GetMapping(path = "foo")
String getFoo() {/* ... */}
@PostMapping(path = "fo...
@RestController
public class FooController {
@GetMapping("foo")
String getFoo() {/* ... */}
@PostMapping("foo")
String pos...
Composed  annotations  for
web  @Scope s
•@RequestScope
•@SessionScope
•@ApplicationScope
@Scope("request", proxyMode=TARGET_CLASS)
public class RequestScopeBean {}
@Scope("session", proxyMode=TARGET_CLASS)
publi...
@RequestScope
public class RequestScopeBean {}
@SessionScope
public class SessionScopeBean {}
@ApplicationScope
public cla...
@GetMapping("foo")
String foo(@SessionAttribute("foo")String foo) {
// equals to sessiong.getAttribute("foo")
}
@GetMappin...
Spring  Boot  1.4
•Banner  Update
•Test  Improvements
•Spring  Framework  4.3  Support
•Misc
https://github.com/spring-‐‑‒...
Miscellaneous
• Spring  Boot  1.4
• Startup  error  improvements
• Couchbase 2.0  /  Neo4J  Support
• @JsonComponent
• Spr...
Enjoy  Spring  4.3  /  Boot  1.4  !!
Spring  5.0
•A  new  framework  generation  for  2017+
•5.0  M1  July  2016
•5.0  RC1  December  2016
from  Keynote  @  Sp...
Spring  5.0
•Major baseline upgrade
•JDK  8+,  Servlet 3.0+,  JMS  2.0+,  
JPA  2.1+,  JUnit 5
•JDK  9,  Jigsaw
•HTTP/2
•R...
Reactor
•Yet  Another  Rx  library  on  the  JVM
•Natively  built  on  top  of  Reactive  Streams
•Developed  by  Pivotal
...
Spring  Reactive
• Embeds  Reactor
• Experimental  project  on  Spring  5  reactive  support
• Runs  on
• Reactor  Net
• R...
Spring  Reactive
@RestController
public class TodosController {
@GetMapping("todos")
Flux<Todo> list() {
return this.repos...
Spring Web Reactive
@MVC
HTTP
Reactive Streams
Servlet 3.1 Reactor I/O RxNetty
from  Keynote  @  Spring  IO  2016
from  Keynote  @  Spring  IO  2016
Boot Security Data Cloud Integration
Spring  Cloud
Spring  Cloud http://projects.spring.io/spring-‐‑‒cloud/
Spring  Cloud  provides
•Service  Discovery
•API  Gateway
•Client-‐‑‒side  Load  Balancing
•Config Server
•Circuit  Breake...
Spring  Cloud  provides
•Service  Discovery
•API  Gateway
•Client-‐‑‒side  Load  Balancing
•Circuit  Breakers
•Distributed...
Microservices with  Spring  Cloud
Go  to  Cloud  Native
Cloud  Native?
•"Software  designed  to  run  and  scale  
reliably  and  predictably  on  top  of  
potentially  unreliab...
Cloud  Native
Cloud  Native  
DevOps Continuous
Delivery
ContainersMicroservices
Continuous  
Delivery
Release  once  every  6  
months
More  Bugs  in  production
Release  early  and  often
Higher  Quali...
Continuous  
Delivery
Release  once  every  6  
months
More  Bugs  in  production
Release  early  and  often
Higher  Quali...
Why  Microservices?
•Speed and  Safety
• They  enable  faster  innovation.
Monolith
Service  Oriented  Architecture
Microservices
http://www.kennybastani.com/2016/04/event-‐‑‒sourcing-‐‑‒microservices-‐‑‒spring-‐‑‒cloud.html
Monolith  to  Microservices
Monolith  to  Microservices
Chotto-‐‑‒Matte
✋
Start  from  12  Factors  App
http://12factor.net/
I.  Codebase
One  codebase  
tracked  in  SCM,  many  
deploys
II.  Dependencies
Explicitly  declare  and  
isolate  depen...
Cloud  Native  Platform
Pivotal  Cloud  Foundry
http://pivotal.io/platform
12  Factors
App
Auto  
Scaling
Multi
Tenancy
Container
4  Level  HA
Auto
Healing
Spring  Cloud  
Services
Metrics
OAuth2  ...
Spring  Cloud  Services
http://docs.pivotal.io/spring-‐‑‒cloud-‐‑‒services/
• Netflix  OSS-‐‑‒as-‐‑‒a-‐‑‒service  in  Pivo...
Microservices with  Spring  Cloud
Microservices with  SCS
Remove  boilerplate  code,  
implement  patterns
Application  coordination  boilerplate  patterns
Application  configurati...
Concourse  CI
https://concourse.ci
Concourse  CI  Overview
http://www.slideshare.net/gwennetourneau/concourseci-‐‑‒overview
How  Pivotal  make  cycle  of  
code  seamless!!
DEMO
deploy https://github.com/metflix
More  practical  pipeline
https://github.com/making/concourse-‐‑‒ci-‐‑‒demo
More  practical  pipeline
https://github.com/making/concourse-‐‑‒ci-‐‑‒demo
Pivotal  Cloud  Foundry  for  Local  Development
https://docs.pivotal.io/pcf-‐‑‒dev/
Tutorials
• http://pivotal.io/platform/pcf-‐‑‒tutorials/getting-‐‑‒started-‐‑‒
with-‐‑‒pivotal-‐‑‒cloud-‐‑‒foundry
• https...
EBooks  (Free!)
• http://pivotal.io/platform/migrating-‐‑‒to-‐‑‒cloud-‐‑‒native-‐‑‒application-‐‑‒architectures-‐‑‒ebook
•...
Summary
• Spring  4.3,  Spring  Boot  1.4  Jun  2016
• DI・MVC  Improvements,  Composed  Annotations  ...
• Image  Banner, ...
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's Cloud Native Approach
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's Cloud Native Approach
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's Cloud Native Approach
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's Cloud Native Approach
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's Cloud Native Approach
Upcoming SlideShare
Loading in …5
×

#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's Cloud Native Approach

7,670 views

Published on

2016-05-19
JJUG CCC 2016 Spring

Published in: Technology

#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's Cloud Native Approach

  1. 1. What's  new  in   Spring  Framework  4.3/Boot  1.4   + Pivotal's Cloud  Native Approach 2016/05/21  JJUG  CCC  2016  Spring Toshiaki  Maki  (@making) Sr.  Solutions  Architect  @Pivotal #jjug_̲ccc #ccc_̲gh5
  2. 2. Who  am  I  ? •Toshiaki  Maki  (@making) •https://blog.ik.am •Sr.  Solutions  Architect •Spring  Framework  enthusiast Spring Framework 徹底⼊入⾨門 (Coming   Soon?) パーフェクト Java  EE (Coming   Soon?)
  3. 3. Agenda •Spring  Boot  1.4  /  Spring  Framework  4.3 •Spring  Framework  5.0 •Spring  Cloud •Go  to  Cloud  Native
  4. 4. Spring  Boot https://twitter.com/phillip_̲webb/status/641444531867680768
  5. 5. Spring  Initializr https://start.spring.io/
  6. 6. Spring  Initializr https://start.spring.io/
  7. 7. Spring  Initializr https://start.spring.io/
  8. 8. Spring  Boot  Adoption
  9. 9. Roadmap Spring  Framework Spring  Boot 2016  JUN 2017〜~ 4.3  GA 1.4  GA 5.0  RC1 2.0  GA 5.0  M1 5.0  GA
  10. 10. Spring  Boot  1.4 •Banner  Update •Test  Improvements •Spring  Framework  4.3  Support •Misc https://github.com/spring-‐‑‒projects/spring-‐‑‒boot/wiki/Spring-‐‑‒Boot-‐‑‒1.4-‐‑‒Release-‐‑‒Notes
  11. 11. Spring  Boot  1.4 •Banner  Update •Test  Improvements •Spring  Framework  4.3  Support •Misc https://github.com/spring-‐‑‒projects/spring-‐‑‒boot/wiki/Spring-‐‑‒Boot-‐‑‒1.4-‐‑‒Release-‐‑‒Notes
  12. 12. Spring  Boot  with  Banner 👈
  13. 13. Spring  Boot  with  Banner src/main/resrouces/banner.txt •1.1  supported  Custom  Text  Banner  
  14. 14. Spring  Boot  with  Banner •1.3  supported  ANSI  Color  Banner   ${AnsiColor.BRIGHT_GREEN}My Application ${AnsiColor.BRIGHT_YELLOW}Hello!!${AnsiColor.DEFAULT} src/main/resrouces/banner.txt
  15. 15. IntelliJ IDEA's  Support
  16. 16. Nyan Cat! https://github.com/snicoll-‐‑‒demos/spring-‐‑‒boot-‐‑‒4tw-‐‑‒uni/blob/master/spring-‐‑‒boot-‐‑‒4tw-‐‑‒web/src/main/resources/banner.txt https://ja.wikipedia.org/wiki/Nyan_̲Cat
  17. 17. Spring  Boot  with  Banner •1.4  supports  Image  Banner!!
  18. 18. Spring  Boot  with  Banner •1.4  supports  Image  Banner!! src/main/resrouces/banner.png
  19. 19. Spring  Boot  with  Banner •1.4  supports  Image  Banner!! src/main/resrouces/banner.png
  20. 20. Tweet your  banner #tweetbootbanner
  21. 21. Spring  Boot  1.4 •Banner  Update •Test  Improvements •Spring  Framework  4.3  Support •Misc https://github.com/spring-‐‑‒projects/spring-‐‑‒boot/wiki/Spring-‐‑‒Boot-‐‑‒1.4-‐‑‒Release-‐‑‒Notes
  22. 22. Test  Improvements •Test  simplifications •Mocking  and  spying •Testing  application  slices
  23. 23. Test  simplifications @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(MyApp.class) @WebIntegrationTest(randomPort=true) public class MyTest { TestRestTemplate rest = new RestTemplate(); @Value("${local.server.port}") int port; @Test public test() { rest.getForObject("http://localhost:"+port+"/foo", String.class); } } ~∼  Spring  Boot  1.3
  24. 24. Test  simplifications @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT) public class MyTest { TestRestTemplate rest = new RestTemplate(); @LocalServerPort int port; @Test public test() { rest.getForObject("http://localhost:"+port+"/foo", String.class); } } Spring  Boot  1.4  ~∼
  25. 25. Test  simplifications @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT) public class MyTest { TestRestTemplate rest = new RestTemplate(); @LocalServerPort int port; @Test public test() { rest.getForObject("http://localhost:"+port+"/foo", String.class); } } Spring  Boot  1.4  ~∼ • WebEnvironment.DEFINED_PORT • WebEnvironment.MOCK
  26. 26. Test  simplifications @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT) public class MyTest { @Autowired TestRestTemplate rest; @Test public test() { rest.getForObject("/foo", String.class); } } Spring  Boot  1.4  ~∼ equals  to http://localhost:${local.server.port}
  27. 27. Mocking  and  spying @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(MyApp.class) @WebIntegrationTest(randomPort=true) public class MyTest { @Autowired FooController fooController; @Test public test() { FooService fooService = mock(FooService.class); fooController.fooService = fooService; // stubbing behaviors } } ~∼  Spring  Boot  1.3
  28. 28. Mocking  and  spying @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(MyApp.class) @WebIntegrationTest(randomPort=true) public class MyTest { @MockBean // or @SpyBean FooService fooService; public test() { // stubbing behaviors } } Spring  Boot  1.4  ~∼ Mocks  will  be   automatically  reset   across  tests
  29. 29. Testing  application  slices •Testing  the  JPA  slice •Testing  the  Spring  MVC  slice •Testing  the  JSON  slice for  fast  tests (without  Embedded  Server)
  30. 30. Testing  the  JPA  slice @RunWith(SpringRunner.class) @DataJpaTest public class UserRepositoryTests { @Autowired TestEntityManager em; @Autowired UserRepository repository; @Test public void test() { em.persist(new User("maki", 20)); User user = this.repository.findByUsername("maki"); assertThat(user.getUsername()).isEqualTo("maki"); assertThat(user.getAge()).isEqualTo(20); } } Test  data   creation
  31. 31. Testing  the  Spring  MVC  slice @RunWith(SpringRunner.class) @WebMvcTest(FooController.class) public class FooControllerTests { @Autowired MockMvc mvc; @MockBean FooService fooService; @Test public void test() { given(fooService.getFoo("xyz")).willReturn("bar"); mvc.perform(get("/foo") .andExpect(status().isOk()) .andExpect(content().string("bar")); } }
  32. 32. Testing  the  Spring  MVC  slice @RunWith(SpringRunner.class) @WebMvcTest(FooController.class) public class FooControllerTests { @Autowired WebClient webClient; // using HtmlUnit @MockBean FooService fooService; @Test public void test() { given(fooService.getFoo("xyz")).willReturn("bar"); HtmlPage page = webClient.getPage("/foo"); HtmlForm form = page.getHtmlElementById("fooForm"); // ... } }
  33. 33. Testing  the  Spring  MVC  slice @RunWith(SpringRunner.class) @WebMvcTest(FooController.class) public class FooControllerTests { @Autowired WebDriver webDriver; // using Selenium @MockBean FooService fooService; @Test public void test() { given(fooService.getFoo("xyz")).willReturn("bar"); // ... } }
  34. 34. Testing  the  JSON  slice @RunWith(SpringRunner.class) @JsonTest public class MyJsonTests { JacksonTester<VehicleDetails> json; @Test public void testSerialize() { VehicleDetails details = new VehicleDetails("Honda", "Civic"); assertThat(json.write(details)) .isEqualToJson("expected.json"); assertThat(json.write(details)) .extractingJsonPathStringValue("@.make") .isEqualTo("Honda"); } }
  35. 35. Testing  the  JSON  slice @RunWith(SpringRunner.class) @JsonTest public class MyJsonTests { JacksonTester<VehicleDetails> json; @Test public void testDeserialize() { String json = "{¥"make¥":¥"Ford¥",¥"model¥":¥"Focus¥"}"; assertThat(json.parse(json)) .isEqualTo(new VehicleDetails("Ford", "Focus")); assertThat(json.parseObject(json).getMake()) .isEqualTo("Ford"); } }
  36. 36. Spring  Boot  1.4 •Banner  Update •Test  Improvements •Spring  Framework  4.3  Support •Misc https://github.com/spring-‐‑‒projects/spring-‐‑‒boot/wiki/Spring-‐‑‒Boot-‐‑‒1.4-‐‑‒Release-‐‑‒Notes
  37. 37. Spring  Framework  4.3 • Last  4.x  feature  release! • 4.3  RC1:  April  6th • 4.3  GA:  June  1st,  2016 • DI  &  MVC  refinements • Composed  annotations • Extended  support  life  until  2020 • on  JDK  6,  7,  8  (and  JDK  9  on  a  best-‐‑‒effort  basis) • on  Tomcat  6,  7,  8.0,  8.5  (and  on  best-‐‑‒effort  9.0) • on  WebSphere  7,  8.0,  8.5  and  9  (Classic  +  Liberty) from  Keynote  @  Spring  IO  2016
  38. 38. Spring  Framework  4.3 • Implicit  constructor  injection • InjectionPoint like  CDI • .... • Composed  annotations  for  @RequestMapping • Composed  annotations  for  web  @Scopes • @SessionAttribute/@RequestAttribute ... http://docs.spring.io/spring/docs/4.3.0.RC2/spring-‐‑‒framework-‐‑‒reference/htmlsingle/#new-‐‑‒in-‐‑‒4.3 Core Web
  39. 39. Implicit  constructor  injection @RestController public class FooController { private final FooService fooService; @Autowired public FooController(FooService fooService) { this.fooService = fooService; } } ~∼ Spring  4.2 👈
  40. 40. Implicit  constructor  injection @RestController public class FooController { private final FooService fooService; public FooController(FooService fooService) { this.fooService = fooService; } } Spring  4.3  ~∼ 👍
  41. 41. Implicit  constructor  injection @RestController @AllArgsConstructor(onConstructor = @_(@Autowired)) public class FooController { private final FooService fooService; } ~∼  Spring  4.2  +  Lombok 👇😩
  42. 42. Implicit  constructor  injection @RestController @AllArgsConstructor public class FooController { private final FooService fooService; } Spring  4.3  ~∼  +  Lombok 👍
  43. 43. InjectionPoint like  CDI @RestController public class FooController { @Autowired @Xyz("bar") FooService service; }
  44. 44. InjectionPoint like  CDI @Configuration public class FooConfig { @Bean FooService foo(InjectionPoint ip) { AnnotatedElement elm = ip.getAnnotatedElement(); Xyz xyz = elm.getAnnotation(Xyz.class); String value = xyz.value(); // "bar" // create FooService using Xyz's value } }
  45. 45. Composed  annotations  for @RequestMapping •@GetMapping •@PostMapping •@PutMapping •@DeleteMapping •@PatchMapping
  46. 46. @RestController public class FooController { @RequestMapping(path = "foo", method = GET) String getFoo() {/* ... */} @RequestMapping(path = "foo", method = POST) String postFoo() {/* ... */} } Spring  4.2 Composed  annotations  for @RequestMapping
  47. 47. @RestController public class FooController { @GetMapping(path = "foo") String getFoo() {/* ... */} @PostMapping(path = "foo") String postFoo() {/* ... */} } Spring  4.3 Composed  annotations  for @RequestMapping
  48. 48. @RestController public class FooController { @GetMapping("foo") String getFoo() {/* ... */} @PostMapping("foo") String postFoo() {/* ... */} } Spring  4.3 Composed  annotations  for @RequestMapping
  49. 49. Composed  annotations  for web  @Scope s •@RequestScope •@SessionScope •@ApplicationScope
  50. 50. @Scope("request", proxyMode=TARGET_CLASS) public class RequestScopeBean {} @Scope("session", proxyMode=TARGET_CLASS) public class SessionScopeBean {} @Scope("application", proxyMode=TARGET_CLASS) public class ApplicationScopeBean {} ~∼Spring  4.2 Composed  annotations  for web  @Scope s
  51. 51. @RequestScope public class RequestScopeBean {} @SessionScope public class SessionScopeBean {} @ApplicationScope public class ApplicationScopeBean {} Spring  4.3 Composed  annotations  for web  @Scope s
  52. 52. @GetMapping("foo") String foo(@SessionAttribute("foo")String foo) { // equals to sessiong.getAttribute("foo") } @GetMapping("bar") String bar(@RequestAttribute("bar")String bar) { // equals to request.getAttribute("bar") } Spring  4.3 @SessionAttribute/@RequestAttribute for  access  to  session/request  attributes
  53. 53. Spring  Boot  1.4 •Banner  Update •Test  Improvements •Spring  Framework  4.3  Support •Misc https://github.com/spring-‐‑‒projects/spring-‐‑‒boot/wiki/Spring-‐‑‒Boot-‐‑‒1.4-‐‑‒Release-‐‑‒Notes
  54. 54. Miscellaneous • Spring  Boot  1.4 • Startup  error  improvements • Couchbase 2.0  /  Neo4J  Support • @JsonComponent • Spring  Security  4.1 • Spring  Data  Hopper  and  so  on... • Spring  Framework  4.3 • Java  Config supports  constructor  injection • Programmatic  resolution  of  dependencies • Cache  abstraction  refinements • Built-‐‑‒in  support  for  HTTP  HEAD  and  OPTIONS • Caffeine  Support • OkHttp3  Support  and  so  on...
  55. 55. Enjoy  Spring  4.3  /  Boot  1.4  !!
  56. 56. Spring  5.0 •A  new  framework  generation  for  2017+ •5.0  M1  July  2016 •5.0  RC1  December  2016 from  Keynote  @  Spring  IO  2016
  57. 57. Spring  5.0 •Major baseline upgrade •JDK  8+,  Servlet 3.0+,  JMS  2.0+,   JPA  2.1+,  JUnit 5 •JDK  9,  Jigsaw •HTTP/2 •Reactive  Architecture from  Keynote  @  Spring  IO  2016
  58. 58. Reactor •Yet  Another  Rx  library  on  the  JVM •Natively  built  on  top  of  Reactive  Streams •Developed  by  Pivotal •Non-‐‑‒blocking •Reactor  Core  provides  lite  Rx  API •Flux for  0..N  elements •Mono for  0..1  element https://projectreactor.io/
  59. 59. Spring  Reactive • Embeds  Reactor • Experimental  project  on  Spring  5  reactive  support • Runs  on • Reactor  Net • RxNetty • Undertow • Servlet  3.1  containers  (Servlet  is  optional  !!) • Same  programming  model  as  Spring  MVC • Will  be  merged  to  5.x  branch  after  4.3  released https://github.com/spring-‐‑‒projects/spring-‐‑‒reactive
  60. 60. Spring  Reactive @RestController public class TodosController { @GetMapping("todos") Flux<Todo> list() { return this.repository.list(); } @PostMapping("todos") Mono<Void> create(@RequestBody Flux<Todo> stream) { return this.repository.insert(stream); } } https://github.com/sdeleuze/spring-‐‑‒reactive-‐‑‒playground
  61. 61. Spring Web Reactive @MVC HTTP Reactive Streams Servlet 3.1 Reactor I/O RxNetty from  Keynote  @  Spring  IO  2016
  62. 62. from  Keynote  @  Spring  IO  2016 Boot Security Data Cloud Integration
  63. 63. Spring  Cloud
  64. 64. Spring  Cloud http://projects.spring.io/spring-‐‑‒cloud/
  65. 65. Spring  Cloud  provides •Service  Discovery •API  Gateway •Client-‐‑‒side  Load  Balancing •Config Server •Circuit  Breakers •Distributed  Tracing
  66. 66. Spring  Cloud  provides •Service  Discovery •API  Gateway •Client-‐‑‒side  Load  Balancing •Circuit  Breakers •Distributed  Configuration •Distributed  Tracing Eureka Zuul Ribbon Hystrix Zipkin
  67. 67. Microservices with  Spring  Cloud
  68. 68. Go  to  Cloud  Native
  69. 69. Cloud  Native? •"Software  designed  to  run  and  scale   reliably  and  predictably  on  top  of   potentially  unreliable  cloud-‐‑‒based   infrastructure" (Duncan  C.E.  Winn,  Free  O'Reilly  Book:  Intro  to  the  Cloud  Native  Platform) •Microservices is  a  part  of  Cloud  Native
  70. 70. Cloud  Native Cloud  Native   DevOps Continuous Delivery ContainersMicroservices
  71. 71. Continuous   Delivery Release  once  every  6   months More  Bugs  in  production Release  early  and  often Higher  Quality  of  Code DevOps Not  my  problem Separate  tools,  varied  incentives,   opaque  process Shared  responsibility Common  incentives,  tools,  process   and  culture Microservices Tightly  coupled  components Slow  deployment  cycles  waiting   on  integrated  tests  teams Loosely  coupled  components Automated  deploy  without  waiting   on  individual   components
  72. 72. Continuous   Delivery Release  once  every  6   months More  Bugs  in  production Release  early  and  often Higher  Quality  of  Code DevOps Not  my  problem Separate  tools,  varied  incentives,   opaque  process Shared  responsibility Common  incentives,  tools,  process   and  culture Microservices Tightly  coupled  components Slow  deployment  cycles  waiting   on  integrated  tests  teams Loosely  coupled  components Automated  deploy  without  waiting   on  individual   components ArchitectureProcessCulture
  73. 73. Why  Microservices? •Speed and  Safety • They  enable  faster  innovation.
  74. 74. Monolith
  75. 75. Service  Oriented  Architecture
  76. 76. Microservices http://www.kennybastani.com/2016/04/event-‐‑‒sourcing-‐‑‒microservices-‐‑‒spring-‐‑‒cloud.html
  77. 77. Monolith  to  Microservices
  78. 78. Monolith  to  Microservices
  79. 79. Chotto-‐‑‒Matte ✋
  80. 80. Start  from  12  Factors  App http://12factor.net/
  81. 81. I.  Codebase One  codebase   tracked  in  SCM,  many   deploys II.  Dependencies Explicitly  declare  and   isolate  dependencies III. Configuration Store config in the environment VI.  Processes Execute  app  as  stateless   processes V.  Build,  Release,   Run Strictly  separate  build   and  run  stages IV.  Backing  Services Treat  backing   services  as  attached   resources IX. Disposability Maximize robustness with fast startup and graceful shutdown VIII. Concurrency Scale  out  via  the   process  model VII.  Port  binding Export  services  via  port   binding XII. Admin processes Run  admin  /  mgmt tasks  as  one-‐‑‒off   processes X. Dev/prod parity Keep  dev,  staging,  prod   as  similar  as  possible XI. Logs Treat logs as event streams 12  Factors  App
  82. 82. Cloud  Native  Platform
  83. 83. Pivotal  Cloud  Foundry http://pivotal.io/platform
  84. 84. 12  Factors App Auto   Scaling Multi Tenancy Container 4  Level  HA Auto Healing Spring  Cloud   Services Metrics OAuth2   SSO Docker IaaS Agnostic Backend Services Logging Blue/Green Deployment Easy Installation
  85. 85. Spring  Cloud  Services http://docs.pivotal.io/spring-‐‑‒cloud-‐‑‒services/ • Netflix  OSS-‐‑‒as-‐‑‒a-‐‑‒service  in  Pivotal  Cloud  Foundry
  86. 86. Microservices with  Spring  Cloud
  87. 87. Microservices with  SCS
  88. 88. Remove  boilerplate  code,   implement  patterns Application  coordination  boilerplate  patterns Application  configuration  boilerplate  patterns Enterprise  application  boilerplate  patterns   Runtime  Platform,  Infrastructure  Automation  boilerplate   patterns  (provision,  deploy,  secure,  log,  data  services,  etc.) CLOUDDESKTOP Spring  Boot Spring  IO  Platform Pivotal  Cloud  Foundry Spring  Cloud Microservice operation  boilerplate  patterns  (Config Server,  Service  Discovery,  Circuit  Breaker) SERVICES Spring  Cloud  Services
  89. 89. Concourse  CI https://concourse.ci
  90. 90. Concourse  CI  Overview http://www.slideshare.net/gwennetourneau/concourseci-‐‑‒overview
  91. 91. How  Pivotal  make  cycle  of   code  seamless!!
  92. 92. DEMO deploy https://github.com/metflix
  93. 93. More  practical  pipeline https://github.com/making/concourse-‐‑‒ci-‐‑‒demo
  94. 94. More  practical  pipeline https://github.com/making/concourse-‐‑‒ci-‐‑‒demo
  95. 95. Pivotal  Cloud  Foundry  for  Local  Development https://docs.pivotal.io/pcf-‐‑‒dev/
  96. 96. Tutorials • http://pivotal.io/platform/pcf-‐‑‒tutorials/getting-‐‑‒started-‐‑‒ with-‐‑‒pivotal-‐‑‒cloud-‐‑‒foundry • https://github.com/Pivotal-‐‑‒Japan/cf-‐‑‒workshop • https://github.com/Pivotal-‐‑‒Japan/cloud-‐‑‒native-‐‑‒workshop
  97. 97. EBooks  (Free!) • http://pivotal.io/platform/migrating-‐‑‒to-‐‑‒cloud-‐‑‒native-‐‑‒application-‐‑‒architectures-‐‑‒ebook • http://pivotal.io/cloud-‐‑‒foundry-‐‑‒the-‐‑‒cloud-‐‑‒native-‐‑‒platform • http://pivotal.io/beyond-‐‑‒the-‐‑‒twelve-‐‑‒factor-‐‑‒app
  98. 98. Summary • Spring  4.3,  Spring  Boot  1.4  Jun  2016 • DI・MVC  Improvements,  Composed  Annotations  ... • Image  Banner,  Test  Improvements,  ...   • Spring  5.0   • JDK  8+,  JDK9,  HTTP/2,  Reactive • Cloud  Native • Microservices • Speed  &  Safety • Independently  Deployable   • Continuous  Delivery • Concourse  CI • Containers,  DevOps • Cloud  Foundry  as  a  Cloud  Native  Platform

×