Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Future of Spring Dr. Mark Pollack Agenda  Unifying Component Model  New Web Application Architectures  NoSQL & Big Data Deploy to Cloud or on.

Similar presentations


Presentation on theme: "The Future of Spring Dr. Mark Pollack Agenda  Unifying Component Model  New Web Application Architectures  NoSQL & Big Data Deploy to Cloud or on."— Presentation transcript:

1

2 The Future of Spring Dr. Mark Pollack

3 Agenda  Unifying Component Model  New Web Application Architectures  NoSQL & Big Data Deploy to Cloud or on premise NoSQL, Big Data Web, Integration, Batch

4 Remember this…? 4

5 Remember this? 5

6 Some things change… 6 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

7 Some things stay the same 7 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"

8 Some things stay the same 8 “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

9 The Spring Stack 9

10 Spring – Unifying Component Model 10

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

12 Simple Object Annotated Components Injection Annotations Composable Stereotypes Service-Oriented Annotations An Annotated Perspective

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

14 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 { … }

15 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) { … }

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

17 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 public void deleteOwner(int id);

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

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

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

21 Bootstrapping Your Annotated Components Typical: a concise XML bean definition file – –@Repository / @Service / @Controller / @Configuration stereotype –compare: JPA persistence.xml with @Entity classes Alternative: AnnotationConfigApplicationContext –scan(basePackage) –register(componentClass) –register(configurationClass)

22 WebApplicationInitializer /** * Servlet 3.0 based initializer, autodetected by Spring. */ public class MyWebAppInitializer implements WebApplicationInitializer { public void 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));... } }

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

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

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

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

27 Drivers of Change

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

29 From: server-side apps To: smart clients and services

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

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

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

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

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

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

36 HTML5 (& native) PaaS JSONHTTP & websockets HTML5 & JS Engine events & notifications Applications Services

37 Smart Clients

38 The Monty Hall Game

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

40 The Monty Hall Game

41 Stick or Change?

42 Cujo –curl –wire –when –aop Clicks Client-side code walkthrough and demo $> demo

43 Service-side design

44 The frontline: SPAs, REST, (& WebSockets)

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

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

47 Monty Hall Game Resource 47 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”}]}

48 Monty Hall Door Resource 48 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”} ] }

49 Monty Hall Door Resource 49 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”}

50 Design Pattern controller resource assembler resource domain object representation

51 Spring MVC Spring Hateoas Code Walkthrough and Demo 51 $> demo

52 Why do we need new data access solutions? What do they look like? How do I build these apps with Spring? Data Access

53 Drivers of Change

54 The New Data Universe 54

55 The Data Revolution 55

56 Putting Data to Work 56

57 Spring Data Mission Statement 57 89% of all virtualized applications in the world run on VMware. Gartner, December 2008 “ Provides a familiar and consistent Spring-based programming model for Big Data, NoSQL, and relational stores while retaining store-specific features and capabilities.

58 Consistency Accuracy –JPA != NoSQL Productivity –Template classes –Object Mapping –Repositories Horizontal integration –Spring Integration –Spring Batch –Gemfire 7.0 From there to here, from here to there, funny things are everywhere!” 58 Programming Model Gemfire Data Technologies JPA/JDBC

59 Configuration 59 @Configuration @ComponentScan @EnableTransactionManagement @EnableJpaRepositories public class JpaConfig { @Bean public DataSource dataSource() {... } @Bean public PlatformTransactionManager transactionManager() {... } } @Configuration @ComponentScan @EnableMongoRepositories public class MongoConfig extends AbstractMongoConfig { @Override public Mongo mongo() throws Exception { … } @Override protected String getDatabaseName() { … } }

60 Mapping 60 @Entity @Table(name = "Orders") public class Order { @ManyToOne(optional = false) private Customer customer; @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @JoinColumn(name = "order_id") private Set lineItems = new HashSet (); } @Document(collection="Orders") public class Order { @DBRef private Customer customer; private Set lineItems = new HashSet ();... }

61 Repository 61 public interface ProductRepository extends CrudRepository, QueryDslPredicateExecutor { Page findByDescriptionContaining(String description, Pageable pageable); @Query("select p from Product p where p.attributes[?1] = ?2") List findByAttributes(String attribute, String value); } public interface ProductRepository extends CrudRepository, QueryDslPredicateExecutor { Page findByDescriptionContaining(String description, Pageable pageable); @Query("{ ?0 : ?1 }") List findByAttributes(String key, String value); }

62 Big Data problems are also integration problems Horizontal Integration 62 CollectTransformRT AnalysisIngestBatch AnalysisDistributeUse Spring Integration & Data Spring Hadoop + Batch Spring MVC Twitter Search & Gardenhose Twitter Search & Gardenhose Redis

63 Spring Integration Spring Data Code Walkthrough and Demo $> demo

64 What’s next?

65 Spring Framework – Next version themes Java SE 8 –SE 8 language features are a natural fit for the Spring programming model Java EE 7 –Support for JCache, JMS 2.0, JPA 2.1, Bean Validation 1.1 Annotation-driven message listening and annotation-driven events within the application Websockets Removal of deprecated classes System requirements: Java SE 6+, Java EE 5+

66 Spring Integration, Batch, Data Unified platform to address existing + new integration markets Shared Data Integration Framework Combine Spring Integration, Batch, Data via single Modular data flow API and DSL Common adapters, serializers, deserializers Batch job scheduling, composition of data processing pipelines Spring Integration Enterprise integration Enterprise messaging Channel abstraction Adapters Spring Data Relational and NoSQL Object mapping CRUD, repository Now also Hadoop Spring Batch Batch job scheduling Parsers, mappers Readers, writers Partial processing etc.

67 Simplifying Java development Helping enterprise developers with their biggest challenges Spring has always been about… 67

68 Thank You!


Download ppt "The Future of Spring Dr. Mark Pollack Agenda  Unifying Component Model  New Web Application Architectures  NoSQL & Big Data Deploy to Cloud or on."

Similar presentations


Ads by Google