Play with Play!                                       Anton Naumov                             email: anton.naumow@gmail.c...
Who am I?                     Java Engineer                     11+ years in Java                     development         ...
RIA Frameworks                          ?Monday, May 21, 12
RIA Frameworks                     Ruby -> RailsMonday, May 21, 12
RIA Frameworks       Python -> DjangoMonday, May 21, 12
RIA Frameworks                     Scala -> Play!Monday, May 21, 12
RIA Frameworks                      PHP -> PHPMonday, May 21, 12
RIA Frameworks                     Java ->Monday, May 21, 12
RIA Frameworks                     Java -> ?Monday, May 21, 12
RIA Frameworks                     Java -> JSF?Monday, May 21, 12
RIA Frameworks                       JSF?                     Java -> GWT?Monday, May 21, 12
RIA Frameworks                       JSF?       GWT?                     Java -> Play!Monday, May 21, 12
Play! FeaturesMonday, May 21, 12
Play! Features                     NO compiling, NO redeploymentMonday, May 21, 12
Play! Features                     NO compiling, NO redeployment                     MVC out of the boxMonday, May 21, 12
Play! Features                     NO compiling, NO redeployment                     MVC out of the box                   ...
Play! Features                     NO compiling, NO redeployment                     MVC out of the box                   ...
Play! Features                     NO compiling, NO redeployment                     MVC out of the box                   ...
Play! Features                     NO compiling, NO redeployment                     MVC out of the box                   ...
Play! Features                     NO compiling, NO redeployment                     MVC out of the box                   ...
Play! AnatomyMonday, May 21, 12
What You Save Is                      What You GetMonday, May 21, 12
What You Save Is                      What You Get                     Eclipse Java CompilerMonday, May 21, 12
What You Save Is                      What You Get                     Eclipse Java Compiler                     Custom Cl...
What You Save Is                      What You Get                     Eclipse Java Compiler                     Custom Cl...
What You Save Is                      What You Get                     Eclipse Java Compiler                     Custom Cl...
Model                      package	  models;                      import	  play.db.jpa.Model;                      import	...
Model                                package	  models;                                import	  play.db.jpa.Model;         ...
Model                                       package	  models;                                       import	  play.db.jpa.M...
Model                                       package	  models;                                       import	  play.db.jpa.M...
Model   Simplified Queries  User.find("byEmailAndPassword",	    	   	   	   	   	   	   	   	   	   	   	   "vpupkin@gmail...
Controller                         package	  controllers;                         import	  play.*;                        ...
Controller                                 package	  controllers;                                 import	  play.*;        ...
Controller                                       package	  controllers;                                       import	  pla...
Controller                                       package	  controllers;                                       import	  pla...
Controller          BindingMonday, May 21, 12
Controller          Binding                     public	  static	  void	  show(Long[]	  id)	  {                     ...    ...
Controller          Binding                     public	  static	  void	  show(Long[]	  id)	  {                     ...    ...
Controller          BindingMonday, May 21, 12
Controller          Binding              public	  static	  void	  update(@As("dd/MM/yyyy")	  Date	                updatedA...
Controller          Binding              public	  static	  void	  update(@As("dd/MM/yyyy")	  Date	                updatedA...
Controller          Binding              public	  static	  void	  update(@As("dd/MM/yyyy")	  Date	                updatedA...
Controller       WorkflowMonday, May 21, 12
Controller       Workflow             	  @Before(only={"login","logout"})             	  static	  void	  doSomething()	  {...
Controller       Workflow             	  @Before(only={"login","logout"})             	  static	  void	  doSomething()	  {...
Controller       Workflow             	  @Before(only={"login","logout"})             	  static	  void	  doSomething()	  {...
Controller       WorkflowMonday, May 21, 12
Controller       Workflow       	  @Catch(value	  =	  Throwable.class,	  priority	  =	  1)       	  public	  static	  void...
Controller       Workflow       	  @Catch(value	  =	  Throwable.class,	  priority	  =	  1)       	  public	  static	  void...
View                              ...                              	  	  	  	  	  	  	  	  <title>#{get	  title	  /}</    ...
Testing                                    Unit Tests                     import	  play.test.*;                     import...
Testing                              Functional Tests       import	  play.test.*;       import	  play.mvc.*;       import	...
Testing                                             Selenium                     #{selenium	  Test	  security}            ...
Dependency                     ManagementMonday, May 21, 12
Dependency                        Management                            #	  Application	  dependencies                    ...
Dependency                         Management                               #	  Application	  dependencies                ...
Dependency                         Management                                    #	  Application	  dependencies           ...
Dependency                         Management                                    #	  Application	  dependencies           ...
ConfigurationMonday, May 21, 12
Configuration                                   application.mode=dev                                   %prod.application.m...
Configuration                                   GET	  	  /	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	...
ModulesMonday, May 21, 12
Modules               CRUDMonday, May 21, 12
Modules               CRUD    required:    	  	  	  	  -­‐	  play	  -­‐>	  crudMonday, May 21, 12
Modules               CRUD    required:    	  	  	  	  -­‐	  play	  -­‐>	  crud     *	  	  	  	  /admin	  	  	  	  module:...
Modules               CRUD    required:    	  	  	  	  -­‐	  play	  -­‐>	  crud     *	  	  	  	  /admin	  	  	  	  module:...
Modules             SecureMonday, May 21, 12
Modules             Secure    required:    	  	  	  	  -­‐	  play	  -­‐>	  secureMonday, May 21, 12
Modules             Secure    required:    	  	  	  	  -­‐	  play	  -­‐>	  secure   *	  	  	  	  /	  	  	  module:secureMo...
Modules             Secure    required:    	  	  	  	  -­‐	  play	  -­‐>	  secure   *	  	  	  	  /	  	  	  module:secure  ...
Modules       Custom ModuleMonday, May 21, 12
Modules       Custom Module                     RoutingMonday, May 21, 12
Modules       Custom Module                     Routing                     MVC classesMonday, May 21, 12
Modules       Custom Module                     Routing                     MVC classes                     DependenciesMo...
Modules       Custom Module                     Routing                     MVC classes                     Dependencies  ...
Modules       Custom Module                     Routing                     MVC classes                     Dependencies  ...
Modules       Custom Module                     Routing         NO configuration                     MVC classes          ...
Modules       Custom Module                     Routing         NO configuration                     MVC classes     NO te...
Modules       Custom Module                     Routing         NO configuration                     MVC classes     NO te...
Let it Play!Monday, May 21, 12
Clouds                     Heroku                     CloudBees                     PlayApp                     Google App...
DisadvantagesMonday, May 21, 12
Disadvantages                 Custom Modules                 managementMonday, May 21, 12
Disadvantages                 Custom Modules                 management                 Precompiling                 requi...
Disadvantages                 Custom Modules                 management                 Precompiling                 requi...
Disadvantages                 Custom Modules     Configuration                 management         management              ...
Disadvantages                 Custom Modules     Configuration                 management         management              ...
Disadvantages                 Custom Modules     Configuration                 management         management              ...
AlternativesMonday, May 21, 12
Alternatives                     Pure JPA 2.0Monday, May 21, 12
Alternatives                     Pure JPA 2.0                     NamedQueriesMonday, May 21, 12
Alternatives                     Pure JPA 2.0                     NamedQueries                     Spring 3.1Monday, May 2...
Alternatives                     Pure JPA 2.0                     NamedQueries                     Spring 3.1             ...
Alternatives                     Pure JPA 2.0      Maven                     NamedQueries                     Spring 3.1  ...
Alternatives                     Pure JPA 2.0      Maven                     NamedQueries      TestNG                     ...
Alternatives                     Pure JPA 2.0      Maven                     NamedQueries      TestNG                     ...
Take AwayMonday, May 21, 12
Thanks!                                       Anton Naumov                             email: anton.naumow@gmail.com      ...
Upcoming SlideShare
Loading in …5
×

Play with play!

1,412 views
1,325 views

Published on

Play with Play!, JEEconf 05/19/2012

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

  • Be the first to like this

No Downloads
Views
Total views
1,412
On SlideShare
0
From Embeds
0
Number of Embeds
787
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Play with play!

  1. 1. Play with Play! Anton Naumov email: anton.naumow@gmail.com linkedin: http://ua.linkedin.com/in/antonnaumovMonday, May 21, 12
  2. 2. Who am I? Java Engineer 11+ years in Java development Photographer Sci-Fi addictedMonday, May 21, 12
  3. 3. RIA Frameworks ?Monday, May 21, 12
  4. 4. RIA Frameworks Ruby -> RailsMonday, May 21, 12
  5. 5. RIA Frameworks Python -> DjangoMonday, May 21, 12
  6. 6. RIA Frameworks Scala -> Play!Monday, May 21, 12
  7. 7. RIA Frameworks PHP -> PHPMonday, May 21, 12
  8. 8. RIA Frameworks Java ->Monday, May 21, 12
  9. 9. RIA Frameworks Java -> ?Monday, May 21, 12
  10. 10. RIA Frameworks Java -> JSF?Monday, May 21, 12
  11. 11. RIA Frameworks JSF? Java -> GWT?Monday, May 21, 12
  12. 12. RIA Frameworks JSF? GWT? Java -> Play!Monday, May 21, 12
  13. 13. Play! FeaturesMonday, May 21, 12
  14. 14. Play! Features NO compiling, NO redeploymentMonday, May 21, 12
  15. 15. Play! Features NO compiling, NO redeployment MVC out of the boxMonday, May 21, 12
  16. 16. Play! Features NO compiling, NO redeployment MVC out of the box Unit & Functional test infrastructureMonday, May 21, 12
  17. 17. Play! Features NO compiling, NO redeployment MVC out of the box Unit & Functional test infrastructure Dependency managementMonday, May 21, 12
  18. 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. 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. 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. 21. Play! AnatomyMonday, May 21, 12
  22. 22. What You Save Is What You GetMonday, May 21, 12
  23. 23. What You Save Is What You Get Eclipse Java CompilerMonday, May 21, 12
  24. 24. What You Save Is What You Get Eclipse Java Compiler Custom ClassLoaderMonday, May 21, 12
  25. 25. What You Save Is What You Get Eclipse Java Compiler Custom ClassLoader JavassistMonday, May 21, 12
  26. 26. What You Save Is What You Get Eclipse Java Compiler Custom ClassLoader Javassist NettyMonday, May 21, 12
  27. 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. 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. 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. 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. 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. 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. 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. 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. 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. 36. Controller BindingMonday, May 21, 12
  37. 37. Controller Binding public  static  void  show(Long[]  id)  { ... }Monday, May 21, 12
  38. 38. Controller Binding public  static  void  show(Long[]  id)  { ... } public  static  void  show(List<Long>  id)  { ... }Monday, May 21, 12
  39. 39. Controller BindingMonday, May 21, 12
  40. 40. Controller Binding public  static  void  update(@As("dd/MM/yyyy")  Date   updatedAt)  { ... }Monday, May 21, 12
  41. 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. 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. 43. Controller WorkflowMonday, May 21, 12
  44. 44. Controller Workflow  @Before(only={"login","logout"})  static  void  doSomething()  { ...  }Monday, May 21, 12
  45. 45. Controller Workflow  @Before(only={"login","logout"})  static  void  doSomething()  { ...  } @After static  void  log()  {        Logger.info("Action  executed  ..."); }Monday, May 21, 12
  46. 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. 47. Controller WorkflowMonday, May 21, 12
  48. 48. Controller Workflow  @Catch(value  =  Throwable.class,  priority  =  1)  public  static  void  logThrowable(Throwable  t)  { ...  }Monday, May 21, 12
  49. 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. 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. 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. 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. 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. 54. Dependency ManagementMonday, May 21, 12
  55. 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. 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. 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. 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. 59. ConfigurationMonday, May 21, 12
  60. 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. 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. 62. ModulesMonday, May 21, 12
  63. 63. Modules CRUDMonday, May 21, 12
  64. 64. Modules CRUD required:        -­‐  play  -­‐>  crudMonday, May 21, 12
  65. 65. Modules CRUD required:        -­‐  play  -­‐>  crud *        /admin        module:crudMonday, May 21, 12
  66. 66. Modules CRUD required:        -­‐  play  -­‐>  crud *        /admin        module:crud package  controllers; public  class  Users  extends  CURD  { }Monday, May 21, 12
  67. 67. Modules SecureMonday, May 21, 12
  68. 68. Modules Secure required:        -­‐  play  -­‐>  secureMonday, May 21, 12
  69. 69. Modules Secure required:        -­‐  play  -­‐>  secure *        /      module:secureMonday, May 21, 12
  70. 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. 71. Modules Custom ModuleMonday, May 21, 12
  72. 72. Modules Custom Module RoutingMonday, May 21, 12
  73. 73. Modules Custom Module Routing MVC classesMonday, May 21, 12
  74. 74. Modules Custom Module Routing MVC classes DependenciesMonday, May 21, 12
  75. 75. Modules Custom Module Routing MVC classes Dependencies ZIP packagingMonday, May 21, 12
  76. 76. Modules Custom Module Routing MVC classes Dependencies ZIP packagingMonday, May 21, 12
  77. 77. Modules Custom Module Routing NO configuration MVC classes Dependencies ZIP packagingMonday, May 21, 12
  78. 78. Modules Custom Module Routing NO configuration MVC classes NO tests Dependencies ZIP packagingMonday, May 21, 12
  79. 79. Modules Custom Module Routing NO configuration MVC classes NO tests Dependencies NO dependencies ZIP packagingMonday, May 21, 12
  80. 80. Let it Play!Monday, May 21, 12
  81. 81. Clouds Heroku CloudBees PlayApp Google AppEngineMonday, May 21, 12
  82. 82. DisadvantagesMonday, May 21, 12
  83. 83. Disadvantages Custom Modules managementMonday, May 21, 12
  84. 84. Disadvantages Custom Modules management Precompiling requirementsMonday, May 21, 12
  85. 85. Disadvantages Custom Modules management Precompiling requirements Cloud deployment limitationsMonday, May 21, 12
  86. 86. Disadvantages Custom Modules Configuration management management limitations Precompiling requirements Cloud deployment limitationsMonday, May 21, 12
  87. 87. Disadvantages Custom Modules Configuration management management limitations Precompiling requirements Technology stack limitations Cloud deployment limitationsMonday, May 21, 12
  88. 88. Disadvantages Custom Modules Configuration management management limitations Precompiling requirements Technology stack limitations Cloud deployment limitations Lack of documentationMonday, May 21, 12
  89. 89. AlternativesMonday, May 21, 12
  90. 90. Alternatives Pure JPA 2.0Monday, May 21, 12
  91. 91. Alternatives Pure JPA 2.0 NamedQueriesMonday, May 21, 12
  92. 92. Alternatives Pure JPA 2.0 NamedQueries Spring 3.1Monday, May 21, 12
  93. 93. Alternatives Pure JPA 2.0 NamedQueries Spring 3.1 Spring SecurityMonday, May 21, 12
  94. 94. Alternatives Pure JPA 2.0 Maven NamedQueries Spring 3.1 Spring SecurityMonday, May 21, 12
  95. 95. Alternatives Pure JPA 2.0 Maven NamedQueries TestNG Spring 3.1 Spring SecurityMonday, May 21, 12
  96. 96. Alternatives Pure JPA 2.0 Maven NamedQueries TestNG Spring 3.1 DBUnit Spring SecurityMonday, May 21, 12
  97. 97. Take AwayMonday, May 21, 12
  98. 98. Thanks! Anton Naumov email: anton.naumow@gmail.com linkedin: http://ua.linkedin.com/in/antonnaumovMonday, May 21, 12

×