• Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,150
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
19
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Play with Play! Anton Naumov email: anton.naumow@gmail.com linkedin: http://ua.linkedin.com/in/antonnaumovMonday, May 21, 12
  • 2. Who am I? Java Engineer 11+ years in Java development Photographer Sci-Fi addictedMonday, May 21, 12
  • 3. RIA Frameworks ?Monday, May 21, 12
  • 4. RIA Frameworks Ruby -> RailsMonday, May 21, 12
  • 5. RIA Frameworks Python -> DjangoMonday, May 21, 12
  • 6. RIA Frameworks Scala -> Play!Monday, May 21, 12
  • 7. RIA Frameworks PHP -> PHPMonday, May 21, 12
  • 8. RIA Frameworks Java ->Monday, May 21, 12
  • 9. RIA Frameworks Java -> ?Monday, May 21, 12
  • 10. RIA Frameworks Java -> JSF?Monday, May 21, 12
  • 11. RIA Frameworks JSF? Java -> GWT?Monday, May 21, 12
  • 12. RIA Frameworks JSF? GWT? Java -> Play!Monday, May 21, 12
  • 13. Play! FeaturesMonday, May 21, 12
  • 14. Play! Features NO compiling, NO redeploymentMonday, May 21, 12
  • 15. Play! Features NO compiling, NO redeployment MVC out of the boxMonday, May 21, 12
  • 16. Play! Features NO compiling, NO redeployment MVC out of the box Unit & Functional test infrastructureMonday, May 21, 12
  • 17. Play! Features NO compiling, NO redeployment MVC out of the box Unit & Functional test infrastructure Dependency managementMonday, May 21, 12
  • 18. Play! Features NO compiling, NO redeployment MVC out of the box Unit & Functional test infrastructure Dependency management Simple text and YAML configurationMonday, May 21, 12
  • 19. Play! Features NO compiling, NO redeployment MVC out of the box Unit & Functional test infrastructure Dependency management Simple text and YAML configuration ModulesMonday, May 21, 12
  • 20. Play! Features NO compiling, NO redeployment MVC out of the box Unit & Functional test infrastructure Dependency management Simple text and YAML configuration Modules Cloud hosting supportMonday, May 21, 12
  • 21. Play! AnatomyMonday, May 21, 12
  • 22. What You Save Is What You GetMonday, May 21, 12
  • 23. What You Save Is What You Get Eclipse Java CompilerMonday, May 21, 12
  • 24. What You Save Is What You Get Eclipse Java Compiler Custom ClassLoaderMonday, May 21, 12
  • 25. What You Save Is What You Get Eclipse Java Compiler Custom ClassLoader JavassistMonday, May 21, 12
  • 26. What You Save Is What You Get Eclipse Java Compiler Custom ClassLoader Javassist NettyMonday, May 21, 12
  • 27. Model package  models; import  play.db.jpa.Model; import   javax.persistence.Entity; @Entity public  class  User  extends   Model  {        @Required        public  String  firstName; }Monday, May 21, 12
  • 28. Model package  models; import  play.db.jpa.Model; JPA 2.0 import   javax.persistence.Entity; @Entity public  class  User  extends   Model  {        @Required        public  String  firstName; }Monday, May 21, 12
  • 29. Model package  models; import  play.db.jpa.Model; JPA 2.0 import   javax.persistence.Entity; play.db.jpa.Model @Entity public  class  User  extends   Model  {        @Required        public  String  firstName; }Monday, May 21, 12
  • 30. Model package  models; import  play.db.jpa.Model; JPA 2.0 import   javax.persistence.Entity; play.db.jpa.Model @Entity public  class  User  extends   Public fields Model  {        @Required        public  String  firstName; }Monday, May 21, 12
  • 31. Model Simplified Queries User.find("byEmailAndPassword",                         "vpupkin@gmail.com",  "s3cr#t"); JPQL Queries User.find("SELECT  u  FROM  User  u  WHERE  u.email  LIKE  ?1",                                                      "vpupkin%");Monday, May 21, 12
  • 32. Controller package  controllers; import  play.*; import  play.mvc.*; import  java.util.*; import  models.*; public  class  Application   extends  Controller  {        public  static  void  index()   {                render();        } }Monday, May 21, 12
  • 33. Controller package  controllers; import  play.*; import  play.mvc.*; import  java.util.*; public static import  models.*; methods public  class  Application   extends  Controller  {        public  static  void  index()   {                render();        } }Monday, May 21, 12
  • 34. Controller package  controllers; import  play.*; import  play.mvc.*; import  java.util.*; public static import  models.*; methods public  class  Application   extends  Controller  { play.mvc.Controller        public  static  void  index()   {                render();        } }Monday, May 21, 12
  • 35. Controller package  controllers; import  play.*; import  play.mvc.*; import  java.util.*; public static import  models.*; methods public  class  Application   extends  Controller  { play.mvc.Controller        public  static  void  index()   render method {                render();        } }Monday, May 21, 12
  • 36. Controller BindingMonday, May 21, 12
  • 37. Controller Binding public  static  void  show(Long[]  id)  { ... }Monday, May 21, 12
  • 38. Controller Binding public  static  void  show(Long[]  id)  { ... } public  static  void  show(List<Long>  id)  { ... }Monday, May 21, 12
  • 39. Controller BindingMonday, May 21, 12
  • 40. Controller Binding public  static  void  update(@As("dd/MM/yyyy")  Date   updatedAt)  { ... }Monday, May 21, 12
  • 41. Controller Binding public  static  void  update(@As("dd/MM/yyyy")  Date   updatedAt)  { ... } public  static  void  update(@As(",")  List<String>   items)  { ... }Monday, May 21, 12
  • 42. Controller Binding public  static  void  update(@As("dd/MM/yyyy")  Date   updatedAt)  { ... } public  static  void  update(@As(",")  List<String>   items)  { ... } public  static  void  anyAction(@As(binder=Binder.class)   String  name)  { ... }Monday, May 21, 12
  • 43. Controller WorkflowMonday, May 21, 12
  • 44. Controller Workflow  @Before(only={"login","logout"})  static  void  doSomething()  { ...  }Monday, May 21, 12
  • 45. Controller Workflow  @Before(only={"login","logout"})  static  void  doSomething()  { ...  } @After static  void  log()  {        Logger.info("Action  executed  ..."); }Monday, May 21, 12
  • 46. Controller Workflow  @Before(only={"login","logout"})  static  void  doSomething()  { ...  } @After static  void  log()  {        Logger.info("Action  executed  ..."); } @Finally static  void  log()  {        Logger.info("Response  contains  :  "  +  response.out); }Monday, May 21, 12
  • 47. Controller WorkflowMonday, May 21, 12
  • 48. Controller Workflow  @Catch(value  =  Throwable.class,  priority  =  1)  public  static  void  logThrowable(Throwable  t)  { ...  }Monday, May 21, 12
  • 49. Controller Workflow  @Catch(value  =  Throwable.class,  priority  =  1)  public  static  void  logThrowable(Throwable  t)  { ...  } @With(Secure.class) public  class  Admin  extends  Controller  { ... }Monday, May 21, 12
  • 50. View ...                <title>#{get  title  /}</ title> ...                #{get  moreStyles  /} ...                <script  src="@{/public/ javascripts/jquery-­‐1.6.4.min.js}"   Groovy type="text/javascript"  charset="$ {_response_encoding}"></script>                #{get  moreScripts  /}        </head>        <body>                #{doLayout  /}        </body> ...Monday, May 21, 12
  • 51. Testing Unit Tests import  play.test.*; import  org.junit.*;   public  class  UsersTest  extends  UnitTest  {        @Test        public  void  aTest()  { ...        }        @Test        public  void  testUsers()  { ...        } }Monday, May 21, 12
  • 52. Testing Functional Tests import  play.test.*; import  play.mvc.*; import  play.mvc.Http.*; import  org.junit.*;   public  class  ApplicationTest  extends  FunctionalTest  {                @Test        public  void  testTheHomePage()  {                Response  response  =  GET("/");                assertStatus(200,  response);        } }Monday, May 21, 12
  • 53. Testing Selenium #{selenium  Test  security}        clearSession()        open(/admin)        assertTextPresent(Login)        type(login,  admin)        type(password,  secret)        clickAndWait(signin)          assertText(success,  Welcom  admin!) #{/selenium}Monday, May 21, 12
  • 54. Dependency ManagementMonday, May 21, 12
  • 55. Dependency Management #  Application  dependencies require: YAML        -­‐  play  1.2.4        -­‐  play  -­‐>  crud        -­‐  play  -­‐>  secure repositories:        -­‐  jboss:                type:              iBiblio                artifact:  "http:// repository.jboss.org/nexus/ content/groups/public-­‐jboss/"                contains:                        -­‐  org.drools  -­‐>  *Monday, May 21, 12
  • 56. Dependency Management #  Application  dependencies require: YAML        -­‐  play  1.2.4        -­‐  play  -­‐>  crud        -­‐  play  -­‐>  secure Ant Ivy repositories:        -­‐  jboss:                type:              iBiblio                artifact:  "http:// repository.jboss.org/nexus/ content/groups/public-­‐jboss/"                contains:                        -­‐  org.drools  -­‐>  *Monday, May 21, 12
  • 57. Dependency Management #  Application  dependencies require: YAML        -­‐  play  1.2.4        -­‐  play  -­‐>  crud        -­‐  play  -­‐>  secure Ant Ivy repositories: Repositories        -­‐  jboss:                type:              iBiblio                artifact:  "http:// repository.jboss.org/nexus/ content/groups/public-­‐jboss/"                contains:                        -­‐  org.drools  -­‐>  *Monday, May 21, 12
  • 58. Dependency Management #  Application  dependencies require: YAML        -­‐  play  1.2.4        -­‐  play  -­‐>  crud        -­‐  play  -­‐>  secure Ant Ivy repositories: Repositories        -­‐  jboss:                type:              iBiblio                artifact:  "http:// Deps & Sync repository.jboss.org/nexus/ content/groups/public-­‐jboss/"                contains:                        -­‐  org.drools  -­‐>  *Monday, May 21, 12
  • 59. ConfigurationMonday, May 21, 12
  • 60. Configuration application.mode=dev %prod.application.mode=prod   Application jpda.port=8000 java.source=1.6 db=mem %prod.db=postgres://user:pwd@host/ database %test.db.url=jdbc:h2:mem:play;MODE=MYSQL ;LOCK_MODE=0Monday, May 21, 12
  • 61. Configuration GET    /                                            Application.index GET    /favicon.ico                      404 Application GET    /public/                              staticDir:public *        /admin                                  module:crud *        /                                            module:secure Routing *        /{controller}/{action}  {controller}. {action}Monday, May 21, 12
  • 62. ModulesMonday, May 21, 12
  • 63. Modules CRUDMonday, May 21, 12
  • 64. Modules CRUD required:        -­‐  play  -­‐>  crudMonday, May 21, 12
  • 65. Modules CRUD required:        -­‐  play  -­‐>  crud *        /admin        module:crudMonday, May 21, 12
  • 66. Modules CRUD required:        -­‐  play  -­‐>  crud *        /admin        module:crud package  controllers; public  class  Users  extends  CURD  { }Monday, May 21, 12
  • 67. Modules SecureMonday, May 21, 12
  • 68. Modules Secure required:        -­‐  play  -­‐>  secureMonday, May 21, 12
  • 69. Modules Secure required:        -­‐  play  -­‐>  secure *        /      module:secureMonday, May 21, 12
  • 70. Modules Secure required:        -­‐  play  -­‐>  secure *        /      module:secure package  controllers; import  play.mvc.With; @With(Secure.class) public  class  Users  extends  CURD  { }Monday, May 21, 12
  • 71. Modules Custom ModuleMonday, May 21, 12
  • 72. Modules Custom Module RoutingMonday, May 21, 12
  • 73. Modules Custom Module Routing MVC classesMonday, May 21, 12
  • 74. Modules Custom Module Routing MVC classes DependenciesMonday, May 21, 12
  • 75. Modules Custom Module Routing MVC classes Dependencies ZIP packagingMonday, May 21, 12
  • 76. Modules Custom Module Routing MVC classes Dependencies ZIP packagingMonday, May 21, 12
  • 77. Modules Custom Module Routing NO configuration MVC classes Dependencies ZIP packagingMonday, May 21, 12
  • 78. Modules Custom Module Routing NO configuration MVC classes NO tests Dependencies ZIP packagingMonday, May 21, 12
  • 79. Modules Custom Module Routing NO configuration MVC classes NO tests Dependencies NO dependencies ZIP packagingMonday, May 21, 12
  • 80. Let it Play!Monday, May 21, 12
  • 81. Clouds Heroku CloudBees PlayApp Google AppEngineMonday, May 21, 12
  • 82. DisadvantagesMonday, May 21, 12
  • 83. Disadvantages Custom Modules managementMonday, May 21, 12
  • 84. Disadvantages Custom Modules management Precompiling requirementsMonday, May 21, 12
  • 85. Disadvantages Custom Modules management Precompiling requirements Cloud deployment limitationsMonday, May 21, 12
  • 86. Disadvantages Custom Modules Configuration management management limitations Precompiling requirements Cloud deployment limitationsMonday, May 21, 12
  • 87. Disadvantages Custom Modules Configuration management management limitations Precompiling requirements Technology stack limitations Cloud deployment limitationsMonday, May 21, 12
  • 88. Disadvantages Custom Modules Configuration management management limitations Precompiling requirements Technology stack limitations Cloud deployment limitations Lack of documentationMonday, May 21, 12
  • 89. AlternativesMonday, May 21, 12
  • 90. Alternatives Pure JPA 2.0Monday, May 21, 12
  • 91. Alternatives Pure JPA 2.0 NamedQueriesMonday, May 21, 12
  • 92. Alternatives Pure JPA 2.0 NamedQueries Spring 3.1Monday, May 21, 12
  • 93. Alternatives Pure JPA 2.0 NamedQueries Spring 3.1 Spring SecurityMonday, May 21, 12
  • 94. Alternatives Pure JPA 2.0 Maven NamedQueries Spring 3.1 Spring SecurityMonday, May 21, 12
  • 95. Alternatives Pure JPA 2.0 Maven NamedQueries TestNG Spring 3.1 Spring SecurityMonday, May 21, 12
  • 96. Alternatives Pure JPA 2.0 Maven NamedQueries TestNG Spring 3.1 DBUnit Spring SecurityMonday, May 21, 12
  • 97. Take AwayMonday, May 21, 12
  • 98. Thanks! Anton Naumov email: anton.naumow@gmail.com linkedin: http://ua.linkedin.com/in/antonnaumovMonday, May 21, 12