1 / 67

The Future of Spring

The Future of Spring. Dr. Mark Pollack. Agenda. Deploy to Cloud or on premise. Unifying Component Model New Web Application Architectures NoSQL & Big Data. NoSQL, Big Data. Core Model. Web, Integration, Batch. Remember this…?. Remember this?. Some things change….

conroy
Download Presentation

The Future of Spring

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Future of Spring Dr. Mark Pollack

  2. Agenda Deploy to Cloud or on premise • Unifying Component Model • New Web Application Architectures • NoSQL & Big Data NoSQL, Big Data CoreModel Web, Integration, Batch

  3. Remember this…?

  4. Remember this?

  5. Some things change… • Changes in version 0.9 (25.6.2003) • ---------------------------------- • first public release since the version that came with the book "Expert One-on-One J2EE Design and Development” • following various unofficial 0.8 CVSsnapshots

  6. Some things stay the same • Changes in version 0.9 (25.6.2003) • ---------------------------------- • first public release since the version that came with the book "Expert One-on-One J2EE Design and Development” • following various unofficial 0.8 CVS snapshots • log via Commons Logging • revised web framework • general tightening and polishing • new sample application "Petclinic"

  7. Some things stay the same • “I believe that Spring is unique, for several reasons: • It addresses important areas that many other popular frameworks don't • Spring is both comprehensive and modular. • Spring is designed from the ground up to help you write code that's easy to test. • Spring is an increasingly important integration technology” • - Rod Johnson, TheServerSide.com, 2005

  8. The Spring Stack

  9. Spring – Unifying Component Model

  10. Remember This One? Simple Objects Simple Object Dependency Injection (DI) Aspect Orientation (AOP) Portable Service Abstractions

  11. An Annotated Perspective AnnotatedComponents Simple Object Injection Annotations Composable Stereotypes Service-Oriented Annotations

  12. A Typical Annotated Component @Service publicclass MyBookAdminService implements BookAdminService { @Autowired public MyBookAdminService(AccountRepository ar) { … } @Transactional public BookUpdate updateBook(Addendum addendum) { … } }

  13. 1. Composable Stereotype Model Powerful options for custom stereotypes @Service @Scope("request") @Transactional(rollbackFor=Exception.class) @Retention(RetentionPolicy.RUNTIME) public@interface MyService {} @MyService public class BookAdminService { … }

  14. 2. Injection Annotations Spring's @Autowired & @Value versus JSR-330's @Inject @Autowired public MyBookAdminService(@Qualifier("myRepo") AccountRepository ar, @Value("#{systemProperties.databaseName}") String dbName) { … } @Inject public MyBookAdminService(@Named("myRepo") AccountRepository ar) { … }

  15. 3. Service-Oriented Annotations E.g. declarative transactions & declarative scheduling @Transactional public BookUpdate updateBook(Addendum addendum) { … } @Scheduled(cron = "0 0 12 * * ?") public void performTempFileCleanup() { … }

  16. Example: Declarative Caching Based on a full-featured cache abstraction @Cacheable public Owner loadOwner(int id); @Cacheable(condition="name.length < 10") public Owner loadOwner(String name); @CacheEvict publicvoid deleteOwner(int id);

  17. @RequestMapping(value = "/books/{id}", method = GET) public Book findBook(@PathVariable("id") long id) { return this.bookAdminService.findBook(id); } Example: Spring MVC - @PathVariable http://mybookstore.com/books/12345

  18. Example: Declarative Model Validation publicclass Book { @NotNull @Past private Date releaseDate; } @RequestMapping("/books/new") public void newBook(@Valid Book book) { … } JSR-303 "Bean Validation" as the common ground

  19. Example: Declarative Formatting Annotation-driven number and date formatting publicclass Book { @NotNull @Past @DateTimeFormat(iso=ISO.DATE) private Date releaseDate; }

  20. Bootstrapping Your Annotated Components Typical: a concise XML bean definition file <context:component-scan base-package=”com.myapp”/> @Repository / @Service / @Controller / @Configuration stereotype compare: JPA persistence.xml with @Entity classes Alternative: AnnotationConfigApplicationContext scan(basePackage) register(componentClass) register(configurationClass)

  21. WebApplicationInitializer /** * Servlet 3.0 based initializer, autodetected by Spring. */ publicclass MyWebAppInitializer implements WebApplicationInitializer { publicvoid onStartup(ServletContext sc) throws ServletException { // Create the 'root' Spring application context AnnotationConfigWebApplicationContext root =new AnnotationConfigWebApplicationContext(); root.scan("com.mycompany.myapp"); root.register(FurtherConfig.class); // Manages the lifecycle of the root application context sc.addListener(new ContextLoaderListener(root)); ... } }

  22. Configuration Classes @Configuration publicclass MyBookAdminConfig { @Bean public BookAdminService myBookAdminService() { MyBookAdminService service = new MyBookAdminService(); service.setDataSource(bookAdminDataSource()); return service; } @Bean public DataSource bookAdminDataSource() { … } }

  23. XML-Free JPA Setup @Configuration publicclass MyBookAdminConfig { @Bean public FactoryBean myEntityManagerFactoryBean() { LocalContainerEntityManagerFactoryBean emfb =new LocalContainerEntityManagerFactoryBean(); emfb.setPackagesToScan(“com.mycompany.myapp”); emfb.setDataSource(bookAdminDataSource()); return emfb; } @Bean public DataSource bookAdminDataSource() { … } }

  24. Summary Spring's distinctive annotated component model composable stereotype model injection annotations service-oriented annotations flexible bootstrapping options if desired: 100% XML-free deployment

  25. Application Architecture • Why do we need new application architectures? • What do they look like? • How do I build these apps with Spring?

  26. Drivers of Change

  27. Drivers of Change User expectations • Data • New client • devices • QoS • internet scale??? • survive AWS outage • Corporate • expectations • Hybrid is • inevitable

  28. From: server-side appsTo: smart clients and services

  29. Client Browser-based HTML Rendering (progressive enhancement) Browser HTML HTTP View Generation Controllers Application Server Service Layer Channels Repositories RDBMS Server CRUD

  30. Client HTML5 & JS Engine Browser app or embedded in native Client-side model web stg JSON HTTP & websockets events & notifications Service Layer DOM Controllers Channels Repositories RDBMS Server CRUD

  31. Client HTML5 & JS Engine Browser app or embedded in native Client-side model web stg business / domain services JSON HTTP & websockets events & notifications Service Layer DOM Controllers Cloud/ PaaS Service Service Service Channels Repositories RDBMS CRUD

  32. Client HTML5 & JS Engine Browser app or embedded in native Client-side model web stg business / domain services JSON HTTP & websockets events & notifications DOM Controllers Service Service Service PaaS CRUD Channels Repositories RDBMS

  33. Client HTML5 & JS Engine Browser app or embedded in native Client-side model web stg business / domain services JSON HTTP & websockets events & notifications DOM Controllers Service Service Service Service Service Service platform services, web APIs SQL NoSQL PaaS Other

  34. HTML5 & JS Engine Applications HTML5 (& native) JSON HTTP & websockets events & notifications Services PaaS

  35. Smart Clients

  36. The Monty Hall Game

  37. The Monty Hall Game The Gray Mouse Lemur – Small, Furry, and Gray! http://www.factzoo.com/mammals/gray-mouse-lemur-small-furry-gray.html

  38. The Monty Hall Game

  39. The Monty Hall Game Stick or Change?

  40. Client-side code walkthrough and demo • Cujo • curl • wire • when • aop • Clicks $> demo

  41. Service-side design

  42. The frontline:SPAs, REST, (& WebSockets)

  43. Apps, REST, & WebSockets native apps App Store (Web Apps) & Services REST ws: SPA Download Interaction browser-based apps

  44. RESTful API design with Spring • Spring MVC as the foundation • Spring Data REST • Basic Entity Management via CRUD • Builds on… • Spring HATEOAS • Link Builder • Resource Assembler

  45. Monty Hall Game Resource POST /games 201 Created Location : /games/{id} GET /games/{id} 200 OK {status : “awaiting_initial_selection” links : [ { rel : “self”, href : “http://…/games/{id}” }, { rel : “doors”, href : “http://…/games/{id}/doors”}, { rel : “history”, href : “http://…/games/{id}/history”}]}

  46. Monty Hall Door Resource GET /games/{id}/doors 200 OK { doors : [ {status : “closed”, content : “unknown”, links : [ {rel : “self”, href : “http://…/games{id}/doors/1”}]}, {status : “closed”, content : “unknown”, links : [ {rel : “self”, href : “http://…/games{id}/doors/2”}]}, {status : “closed”, content : “unknown”, links : [ {rel : “self”, href : “http://…/games{id}/doors/3”}]} ], links : [ { rel : “self”, href : “http://…/games{id}/doors”} ] }

  47. Monty Hall Door Resource PATCH (PUT) /games/{id}/doors/{id} {“status” : “SELECTED”} 200 OK {status : “SELECTED”, content : “unknown”, links : [ {rel : “self”, href : “http://…/games{id}/doors/1”} PATCH (PUT) /games/{id}/doors/{id} {“status” : “OPENED”} 200 OK {status : “OPENED”, content : “juergen”, links : [ {rel : “self”, href : “http://…/games{id}/doors/1”}

  48. Design Pattern resource assembler resource controller representation domain object

  49. Code Walkthrough and Demo • Spring MVC • Spring Hateoas $> demo

More Related