Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Christoph Strobl on Spring Data & Hypermedia

Christoph Strobl on Spring Data & Hypermedia

More Decks by Enterprise Java User Group Austria

Other Decks in Technology

Transcript

  1. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Christoph Strobl, Pivotal Software Inc. @stroblchristoph Spring Data, Hypermedia and the Cloud
  2. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 2
  3. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 3 “Spring Data provides a familiar and consistent Spring based programming model retaining store specific features and capabilities. O.Gierke
  4. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data 4 Abstraction relational non-relational JDBC* MongoDB Neo4j JPA* Redis Couchbase Cassandra Solr Spring Data
  5. Core KeyValue Gemfire JPA Solr Elasticsearch Cassandra Couchbase Redis MongoDB

    Community
 modules Core
 modules Neo4j REST Foundational Store modules Web APIs
  6. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ The anatomy of a Spring Data module 6 where needed where needed where reasonable Templates Object mapping Repositories Spring Container Integration CDI Support
  7. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 7 Today we’ll have a look at… Spring Boot App
  8. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 8 “Spring Boot makes it easy to create Spring-powered, production-grade applications and services with absolute minimum fuss. The Spring Boot Team
  9. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ One Slide App @SpringBootApplication public class StoreApp { ! public static void main(String[] args) { SpringApplication.run(StoreApp.class, args); } ! ! ! ! ! } 9 Page<Store> findByAddressLocationNear(Point location, Distance distance, Pageable pageable); interface StoreRepository extends PagingAndSortingRepository<Store, String> { ! ! }
  10. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ § Hypermedia 10 Hypermedia is Coming image source:
 terrordesigners.com
  11. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Hypermedia Presentation of data and navigation controls at the same time 11
  12. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data REST 12 HATEOAS JSON HAL JSON Schema GET PUT POST PATCH Conditional ALPS Repositories Projections Resource http
  13. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data REST 13 @SpringBootApplication public class StoreApp { ! public static void main(String[] args) { SpringApplication.run(StoreApp.class, args); } ! interface StoreRepository extends PagingAndSortingRepository<Store, String> { ! ! } } Page<Store> findByAddressLocationNear(Point location, Distance distance, Pageable pageable); @RestResource(rel = "by-location") <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-rest</artifactId>
  14. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Let’s try this local… 14 $> mvn spring-boot:run <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin>
  15. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 16 image source:
 terrordesigners.com The Cloud 
 is waiting! image source: idigitaltimes.com
  16. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 17 “Docker is an open platform for building, shipping and running distributed applications. It gives programmers, development teams and operations engineers the common toolbox they need to take advantage of the distributed and networked nature of modern applications.
 ! docker.com
  17. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Run on Docker 18 FROM java:8 VOLUME /tmp ADD spring-data-rest-starbucks.jar app.jar RUN bash -c 'touch /app.jar' ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar", "/app.jar"] <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.2.12</version> <configuration> <imageName>cstrobl/${project.artifactId}</imageName> 
 <dockerDirectory>src/main/docker<dockerDirectory>
 ... $> mvn package docker:build $> docker run -p 8080:8080 -t cstrobl/spring-data-rest-starbucks
  18. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 19
  19. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 20 “Lattice aspires to make clustering containers easy. It packages components from Cloud Foundry to provide a cloud native platform for individual developers and small teams.
 ! lattice.cf
  20. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Run on Lattice 21 $> mvn package docker:build $> docker push cstrobl/spring-data-rest-starbucks $> ltc create starbucks cstrobl/spring-data-rest-starbucks --memory-mb 1024
 $> ltc scale starbucks 2
  21. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 22
  22. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 23 “Pivotal Cloud Foundry is a Platform as a Service that supplies developers with a ready-to-use cloud computing environment and application services, all hosted by virtualized servers on your existing public and private infrastructure. ! pivotal.io
  23. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Run on Pivotal Cloud Foundry 24 $> mvn package $> cf push starbucks -p target/spring-data-rest-starbucks.jar --no-start $> cf bind-service starbucks mongo $> cf start starbucks
 $> cf scale starbucks -i 2 -m 512M
  24. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 25
  25. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 26 Go to start.spring.io 
 get Spring Boot with Spring Data 
 and deploy on
 Cloud Foundry, Docker and Lattice
 or simply anywhere you want!
  26. Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Resources (alphabetical) § docker.com § hub.docker.com § lattice.cf § mongodb.org § projects.spring.io/spring-boot 27 § projects.spring.io/spring-data § run.pivotal.io § start.spring.io § vagrantup.com § virtualbox.org