Service-oriented webapp construction using a web metaframework

242 views
198 views

Published on

Published in: Internet, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
242
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Service-oriented webapp construction using a web metaframework

  1. 1. Licensed under Creative Commons Attribution-Share Alike 3.0 © 2013-2014 Juan M. Dodero seminar service-oriented webapp construction using a metaframework Juan Manuel Dodero juanma.dodero@uca.es
  2. 2. Licensed under Creative Commons Attribution-Share Alike 3.0 © 2013-2014 Juan M. Dodero agenda issue webapp construction context web of data service-oriented web frameworks techniques ReST services JSON data tooling spring ROO framework practice
  3. 3. Licensed under Creative Commons Attribution-Share Alike 3.0 © 2013-2014 Juan M. Dodero issue
  4. 4. Licensed under Creative Commons Attribution-Share Alike 3.0 © 2013-2014 Juan M. Dodero modern webapp construction
  5. 5. Licensed under Creative Commons Attribution-Share Alike 3.0 © 2013-2014 Juan M. Dodero goal [easily] implement service-oriented web apps
  6. 6. Licensed under Creative Commons Attribution-Share Alike 3.0 © 2013-2014 Juan M. Dodero context
  7. 7. Licensed under Creative Commons Attribution-Share Alike 3.0 service-oriented © 2013-2014 Juan M. Dodero
  8. 8. Licensed under Creative Commons Attribution-Share Alike 3.0 webofdata © 2013-2014 Juan M. Dodero
  9. 9. Licensed under Creative Commons Attribution-Share Alike 3.0 web app architecture © 2013-2014 Juan M. Dodero architectural abstraction MVC pattern data access tier abstraction ORM pattern
  10. 10. Licensed under Creative Commons Attribution-Share Alike 3.0 constructing with web frameworks © 2013-2014 Juan M. Dodero spring framework client code abstraction e.g. MVC pattern inversion of control e.g. Spring DI & AOP
  11. 11. Licensed under Creative Commons Attribution-Share Alike 3.0 constructing with frameworks © 2013-2014 Juan M. Dodero framework control flow client code class MyObject extends Object { myMethod() {...} } o.myMethod(); abstraction design patterns inversion of control dependency injection
  12. 12. Licensed under Creative Commons Attribution-Share Alike 3.0 © 2013-2014 Juan M. Dodero framework trends
  13. 13. Licensed under Creative Commons Attribution-Share Alike 3.0 © 2013-2014 Juan M. Dodero framework trends
  14. 14. Licensed under Creative Commons Attribution-Share Alike 3.0 © 2013-2014 Juan M. Dodero techniques
  15. 15. Licensed under Creative Commons Attribution-Share Alike 3.0 example Requirements PizzaShop must build and deploy a set of web services to enable clients: !  get a list of pizzas !  get info on a specific pizza !  submit a pizza purchase order !  etc © 2013-2014 Juan M. Dodero
  16. 16. Licensed under Creative Commons Attribution-Share Alike 3.0 Request [XML doc] Response [XML doc] webserver SOAP envelope HTTP POST aURL HTTP Response getPizzaList() Request [XML doc] Response [XML doc] HTTP POST aURL HTTP Response getPizza(id)SOAP server Request [XML doc] HTTP POST aURL submit(PizzaOrder) Response [XML doc] HTTP Response SOAP implementation © 2013-2014 Juan M. Dodero
  17. 17. Licensed under Creative Commons Attribution-Share Alike 3.0 webserver HTTP GET request /pizzas HTTP response Response (HTML/XML/JSON doc) HTTP GET request HTTP response HTTP POST /pizzaorder/id HTTP responseURL to submitted Order Request (HTML/XML/JSON) Pizza List Pizza Pizza Order ReST implementation © 2013-2014 Juan M. Dodero /pizza/id Response (HTML/XML/JSON doc)
  18. 18. Licensed under Creative Commons Attribution-Share Alike 3.0 ReST design © 2013-2014 Juan M. Dodero
  19. 19. Licensed under Creative Commons Attribution-Share Alike 3.0 JSON data serialization © 2013-2014 Juan M. Dodero $ curl -s -H "Accept: application/json" http://localhost:8080/pizzashop/pizzas | jq . [ { "version": 1, "toppings": [ { "version": 1, "name": "Mozzarella", "id": 9 }, { "version": 1, "name": "Anchovy fillets", "id": 10 } ], "price": 7.5, "name": "Napolitana", "id": 8, "base": { "version": 1, "name": "Thin Crust", "id": 1 } } ]
  20. 20. Licensed under Creative Commons Attribution-Share Alike 3.0 © 2013-2014 Juan M. Dodero tooling
  21. 21. Licensed under Creative Commons Attribution-Share Alike 3.0 © 2013-2014 Juan M. Dodero “fundamentally improve Java developer productivity without compromising engineering integrity or flexibility"!
  22. 22. Licensed under Creative Commons Attribution-Share Alike 3.0 spring ROO features ! 100% java: based on other solid, well-known frameworks (spring, hibernate, apache tiles, aspectj, flexJSON, dojoToolkit, etc.) ! convention over configuration ! meta-framework (generates source code) ! generated/manual code keep in sync ! works in build-time (not run-time) ! command console ! extensible by add-ons © 2013-2014 Juan M. Dodero
  23. 23. Licensed under Creative Commons Attribution-Share Alike 3.0 roo architecture © 2013-2014 Juan M. Dodero
  24. 24. Licensed under Creative Commons Attribution-Share Alike 3.0 ReST URI pattern © 2013-2014 Juan M. Dodero
  25. 25. Licensed under Creative Commons Attribution-Share Alike 3.0 demo roo console © 2013-2014 Juan M. Dodero
  26. 26. Licensed under Creative Commons Attribution-Share Alike 3.0 demo web app © 2013-2014 Juan M. Dodero
  27. 27. Licensed under Creative Commons Attribution-Share Alike 3.0 demo domain model © 2013-2014 Juan M. Dodero
  28. 28. Licensed under Creative Commons Attribution-Share Alike 3.0 demo roo script // Create a new project project --topLevelPackage com.springsource.pizzashop // Setup JPA persistence using EclipseLink and H2 jpa setup --provider ECLIPSELINK --database H2_IN_MEMORY // Create domain entities entity jpa --class ~.domain.Base --activeRecord false --testAutomatically field string --fieldName name --sizeMin 2 –notNull entity jpa --class ~.domain.Topping --activeRecord false -- testAutomatically field string --fieldName name --sizeMin 2 –notNull entity jpa --class ~.domain.Pizza --activeRecord false --testAutomatically field string --fieldName name --notNull --sizeMin 2 field number --fieldName price --type java.math.BigDecimal field set --fieldName toppings --type ~.domain.Topping field reference --fieldName base --type ~.domain.Base entity jpa --class ~.domain.PizzaOrder --testAutomatically --activeRecord false --identifierType ~.domain.PizzaOrderPk field string --fieldName name --notNull --sizeMin 2 field string --fieldName address --sizeMax 30 field number --fieldName total --type java.math.BigDecimal field date --fieldName deliveryDate --type java.util.Date field set --fieldName pizzas --type ~.domain.Pizza field string --fieldName shopCountry --class ~.domain.PizzaOrderPk field string --fieldName shopCity field string --fieldName shopName // Define a repository layer for persistence repository jpa --interface ~.repository.ToppingRepository --entity ~.domain.Topping repository jpa --interface ~.repository.BaseRepository --entity ~.domain.Base repository jpa --interface ~.repository.PizzaRepository --entity ~.domain.Pizza repository jpa --interface ~.repository.PizzaOrderRepository --entity ~.domain.PizzaOrder // Define a service/façade layer service type --interface ~.service.ToppingService --entity ~.domain.Topping service type --interface ~.service.BaseService --entity ~.domain.Base service type --interface ~.service.PizzaService --entity ~.domain.Pizza service type --interface ~.service.PizzaOrderService --entity ~.domain.PizzaOrder // Offer JSON remoting for all domain types through Spring MVC json all --deepSerialize web mvc json setup web mvc json all --package ~.web web mvc setup web mvc all --package ~.web © 2013-2014 Juan M. Dodero
  29. 29. Licensed under Creative Commons Attribution-Share Alike 3.0 demo json data © 2013-2014 Juan M. Dodero $ curl -s -H "Accept: application/json" http://localhost:8080/pizzashop/pizzas | jq . [ { "version": 1, "toppings": [ { "version": 1, "name": "Mozzarella", "id": 9 }, { "version": 1, "name": "Anchovy fillets", "id": 10 } ], "price": 7.5, "name": "Napolitana", "id": 8, "base": { "version": 1, "name": "Thin Crust", "id": 1 } } ]
  30. 30. Licensed under Creative Commons Attribution-Share Alike 3.0 ~.domain.Pizza © 2013-2014 Juan M. Dodero @RooJavaBean   @RooToString   @RooJpaEntity   @RooJson(deepSerialize  =  true)   public  class  Pizza  {          @NotNull          @Size(min  =  2)          private  String  name;          private  BigDecimal  price;          @ManyToMany(cascade  =  CascadeType.ALL)          private  Set<Topping>  toppings  =  new  HashSet<Topping>();          @ManyToOne          private  Base  base;   }  
  31. 31. Licensed under Creative Commons Attribution-Share Alike 3.0 Pizza_Roo_JavaBean.aj © 2013-2014 Juan M. Dodero privileged  aspect  Pizza_Roo_JavaBean  {          public  String  Pizza.getName()  {                  return  this.name;          }          public  void  Pizza.setName(String  name)  {                  this.name  =  name;          }          ...          public  Set<Topping>  Pizza.getToppings()  {                  return  this.toppings;          }          public  void  Pizza.setToppings(Set<Topping>  toppings)  {                  this.toppings  =  toppings;          }          public  Base  Pizza.getBase()  {                  return  this.base;          }          public  void  Pizza.setBase(Base  base)  {                  this.base  =  base;          }   }  
  32. 32. Licensed under Creative Commons Attribution-Share Alike 3.0 Pizza_Roo_Json.aj © 2013-2014 Juan M. Dodero privileged  aspect  Pizza_Roo_Json  {      ...      public  String  Pizza.toJson(String[]  fields)  {            return  new  JSONSerializer()              .include(fields).exclude("*.class").deepSerialize(this);      }      public  static  Pizza  Pizza.fromJsonToPizza(String  json)  {              return  new  JSONDeserializer<Pizza>()                .use(null,  Pizza.class).deserialize(json);      }      public  static  String  Pizza.toJsonArray(Collection<Pizza>  collection)  {              return  new  JSONSerializer()                .exclude("*.class").deepSerialize(collection);      }      ...      public  static  Collection<Pizza>  Pizza.fromJsonArrayToPizzas(String  json)  {          return  new  JSONDeserializer<List<Pizza>>()            .use("values",  Pizza.class).deserialize(json);      }   }  
  33. 33. Licensed under Creative Commons Attribution-Share Alike 3.0 © 2013-2014 Juan M. Dodero http://dodero.github.io/sosc-wmf/ practice
  34. 34. Licensed under Creative Commons Attribution-Share Alike 3.0 references © 2013-2014 Juan M. Dodero
  35. 35. Licensed under Creative Commons Attribution-Share Alike 3.0 © 2013-2014 Juan M. Dodero Attribution-Share Alike 3.0

×