Your SlideShare is downloading. ×
0
Grails, Trails, and Sails:
Rails Through a Coffee Filter

Matt Hughes
David Esterkin

Chariot Solutions
http://chariotsolu...
Agenda

Brief History of Web Development
Ruby On Rails
Sails
Trails
Grails
The Future of *ails



                 2007 Ja...
Agenda

Brief History of Web Development
Ruby On Rails
Sails
Trails
Grails
The Future of *ails



                2007 Jav...
A Brief History of
  Web Application Development

In the beginning there was pain

           ...

then came Ruby on Rails...
Agenda

Brief History of Web Development
Ruby On Rails
Sails
Trails
Grails
The Future of *ails



                 2007 Ja...
Rails Screencast




      rails blog_app



               2007 JavaOneSM Conference | Session BOF-9843 |   6
Gives You...




                                A functional CRUD app
                                in 15 minutes
     ...
Ruby on Rails

                                                      Opinionated
 Convention                              ...
Rails Dissected

   ActiveRecord                     Model


   ERB      Ruby                         View



   ActionCon...
State of Java Web Development
• Coincides with
  •   Disillusioned with EJB 2.x
  •   Code, compile, deploy, restart serve...
2007 JavaOneSM Conference | Session BOF-9843 |   11
The Contenders


Trail   Domain Driven Design

Sail    Controller-centric

Grail   DDD / Full stack


               2007 ...
Agenda

Brief History of Web Development
Ruby On Rails
Sails
Trails
Grails
The Future of *ails



                 2007 Ja...
• Started in 2005
• Brings the flavor of Rails development to
  Java
• Viento: custom template engine
• Rigging: custom dep...
Similar to *ails
• Generates nice URLs
• Promotes easy testing
• Templates are closest to Rails of the 3 Java
  frameworks...
Differs from *ails
• Does not provide utilities to generate scaffolding
• No functionality to facilitate Hibernate persist...
Components
• Model: Hibernate
   • Developers don’t think ActiveRecord can be duplicated
     in Java
   • Already comfort...
Convention over Configuration
• Controllers all go in a specific package
• Action URL contains the controller name, action...
Generate Sample Application
• Download zip file from opensails.org
• Create Eclipse project
  • Import Existing Projects i...
Add New Controller
public class PostController                                             Maps to /post/* urls
      exte...
List Posts View (list.vto)
<body>
  ...
  <table>                                      Ruby like each construct
    <tr>
 ...
Add Post view (/post/add.vto)
<html>
  <head><title>Add Post</title></head>
  <body>
    $form.start
    
    $form.text('...
Viento: Top Level Mixins
In Java:
 public class Mixin {
     public boolean isEven (int i) {
         return (i % 2 == 0);...
Viento: Type Mixins

 In Java:
  public class EvenMixin {
      public boolean isEven (int i) {
          return (i % 2 ==...
Viento: Method Missing
 In Java:
  public class TagTool implements MethodMissing {
      public String methodMissing(Strin...
Viento: Custom Method Names
 In Java:
  public class Tool {
    @Name(“?”)
    public String question(String arg) {
      ...
Roadmap
• Project is dormant
• Development team is now using Rails!
• Lead developer was very helpful, and would like to
 ...
Agenda

Brief History of Web Development
Ruby On Rails
Sails
Trails
Grails
The Future of *ails



                 2007 Ja...
• Started in mid 2005
• Currently at 1.0-SNAPSHOT
• Influences
  • Ruby on Rails
  • Naked Objects pattern




           ...
Rails Influence
• Rapid web application development
• Scaffolding generation
• Convention over configuration




         ...
Naked Objects Influence
•   http://nakedobjects.org
•   Domain Driven Design
•   Domain objects are behaviorally complete
...
Components
•   Tapestry
•   Spring
•   Hibernate
•   Maven




                2007 JavaOneSM Conference | Session BOF-984...
Getting Started
• Requirements
   • Java 1.5
   • Maven 2
• trails-archetype
   • 1.0-SNAPSHOT: build locally
   • Release...
Creating the Application
mvn -U archetype:create 
 -DarchetypeGroupId=org.trailsframework 
 -DarchetypeArtifactId=trails-a...
What this generates

                                            Source structure created, and
                           ...
Running the Application
  mvn tomcat:run or mvn jetty:run


• Create process generates a base domain object
• Initially us...
IDE Support
• Because Trails is built on popular Java libraries,
  there is already pretty good support in the popular
  I...
Create Company domain class
@Entity                                                               Define as an entity
@Val...
Create Speaker domain class
@Entity
public class Speaker {

   private int id;

   private String name;

   private Date p...
Ready to Go!
 mvn tomcat:run or mvn jetty:run




                2007 JavaOneSM Conference | Session BOF-9843 |   40
Home page




            2007 JavaOneSM Conference | Session BOF-9843 |   41
List Companies




                 2007 JavaOneSM Conference | Session BOF-9843 |   42
Search Company




             2007 JavaOneSM Conference | Session BOF-9843 |   43
Add/Edit/Delete Company




              2007 JavaOneSM Conference | Session BOF-9843 |   44
List Speakers




                2007 JavaOneSM Conference | Session BOF-9843 |   45
Search Speaker




                 2007 JavaOneSM Conference | Session BOF-9843 |   46
Add/Edit/Delete Speaker




               2007 JavaOneSM Conference | Session BOF-9843 |   47
Customizing View
• Copy the default view to view specific to the
  controller.
   • cp DefaultEdit SpeakerEdit
• Modify li...
Roadmap
• Release version 1.0
• Search refactoring and Lucene integration
• equals() Aspect




                     2007 ...
Agenda

Brief History of Web Development
Ruby On Rails
Sails
Trails
Grails
The Future of *ails



                 2007 Ja...
• Open-source web framework started in early
  2006
   • Most heavily influenced by Rails
• Built with top of Groovy
  •   ...
First Cousin of Rails

• Takes the most inspiration from Rails
• Design really driven by language
   • Ruby drives Rails
 ...
...But not the Weird Cousin
• All the libraries you already know
  • Hibernate 3.2
  • Spring
  • SiteMesh
  • Quartz
• An...
What’s the Same?
•   Project quickstart / artifact generation
•   MVC
•   Convention over Configuration
•   Dynamic finder m...
What’s Different Philosophically?
• Domain Driven Development
  • No class to inherit from
  • Class properties drive DB, ...
What’s Different Technically?
• Performance
   • Uses native threads
   • Runs on JVM
• Deployment
   • Deploys as a war, ...
Up and Running



 grails create-app glogger




             2007 JavaOneSM Conference | Session BOF-9843 |   57
Built-in support for
     Gives you...                                                             internationalization


...
What Else Can It Do?

                                  create-webtest
create-controller                 generate-all
crea...
Dissecting the Domain
    grails create-domain-class Post




groggergrails-appdomainPost.groovy
groggergrails-testsPostTe...
Further Dissecting the Domain
         class Post {                                                 No super class!

     ...
Generating the Rest

grails generate-all Post




grails-appcontrollersPostController.groovy
grails-appviewspostlist.gsp
....
Groovy Views (GSP)
• Groovy Server Pages
• Creation of custom tags couldn’t be easier
   • No TLDs
   • Changes are seen i...
Controllers - Generated
class PostController {
  def index = {
    redirect(action:list,params:params)
  }

  def allowedM...
Controllers - Dynamic



class PostController {
  def scaffold = true
}




          2007 JavaOneSM Conference | Session ...
Controllers - Dynamic Override

class PostController {                                            Implement methods to
  d...
Let’s See the App




     2007 JavaOneSM Conference | Session BOF-9843 |   67
Glogger Homepage




2007 JavaOneSM Conference | Session BOF-9843 |   68
Create Post




2007 JavaOneSM Conference | Session BOF-9843 |   69
List Posts




2007 JavaOneSM Conference | Session BOF-9843 |   70
View Post




2007 JavaOneSM Conference | Session BOF-9843 |   71
Edit Post




2007 JavaOneSM Conference | Session BOF-9843 |   72
Dynamic Methods and Properties

Post.findByAuthor("Matt")
Post.findByTitleAndAuthor("Grails", "Matt")
Post.findAll()
Post....
Services
• Keeping business logic in the right place
    class PostService {
          boolean transactional = false
    }...
Builders - Query Criteria

   def c = Post.createCriteria()
   def results = c {
     like("title", "%grails%")
     and {...
Builders - Configuration

def bb = new grails.spring.BeanBuilder()
bb.beans {
  dataSource(BasicDataSource) {
    driverCl...
Builders - XML Generation
import groovy.xml.MarkupBuilder
<blog>
def xmlDoc= new MarkupBuilder()
  <post title="Grails Roc...
Grails Roadmap
•   1.0 now targeted for autumn 2007
•   Performance and stability are key
•   Middlegen support
•   JPA su...
Agenda

Brief History of Web Development
Ruby On Rails
Sails
Trails
Grails
The Future of *ails



                 2007 Ja...
Popularity




 2007 JavaOneSM Conference | Session BOF-9843 |   80
Jobs




2007 JavaOneSM Conference | Session BOF-9843 |   81
But...




Room for Growth




2007 JavaOneSM Conference | Session BOF-9843 |   82
Why Aren’t *ails More Popular?
• Haven’t reached critical 1.0 milestone
• Do Trails/Sails solve enough pain points?
• JRub...
Q&A



      2007 JavaOneSM Conference | Session XXXX |   84
Upcoming SlideShare
Loading in...5
×

Grails, Trails, and Sails: Rails Through a Coffee Filter

2,769

Published on

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

No Downloads
Views
Total Views
2,769
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
14
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Grails, Trails, and Sails: Rails Through a Coffee Filter"

  1. 1. Grails, Trails, and Sails: Rails Through a Coffee Filter Matt Hughes David Esterkin Chariot Solutions http://chariotsolutions.com BOF-9843 2007 JavaOneSM Conference | Session BOF-9843 |
  2. 2. Agenda Brief History of Web Development Ruby On Rails Sails Trails Grails The Future of *ails 2007 JavaOneSM Conference | Session BOF-9843 | 2
  3. 3. Agenda Brief History of Web Development Ruby On Rails Sails Trails Grails The Future of *ails 2007 JavaOneSM Conference | Session BOF-9843 | 3
  4. 4. A Brief History of Web Application Development In the beginning there was pain ... then came Ruby on Rails 2007 JavaOneSM Conference | Session BOF-9843 | 4
  5. 5. Agenda Brief History of Web Development Ruby On Rails Sails Trails Grails The Future of *ails 2007 JavaOneSM Conference | Session BOF-9843 | 5
  6. 6. Rails Screencast rails blog_app 2007 JavaOneSM Conference | Session BOF-9843 | 6
  7. 7. Gives You... A functional CRUD app in 15 minutes 2007 JavaOneSM Conference | Session BOF-9843 | 7
  8. 8. Ruby on Rails Opinionated Convention Software MVC over Configuration 80/20 Rule Test Driven Don’t Repeat Development Yourself Agile Get Real 2007 JavaOneSM Conference | Session BOF-9843 | 8
  9. 9. Rails Dissected ActiveRecord Model ERB Ruby View ActionController Controller 2007 JavaOneSM Conference | Session BOF-9843 | 9
  10. 10. State of Java Web Development • Coincides with • Disillusioned with EJB 2.x • Code, compile, deploy, restart server cycle • Popularity of dynamic languages on the JVM • Realization that Enterpriseyness != Self-Worth 2007 JavaOneSM Conference | Session BOF-9843 | 10
  11. 11. 2007 JavaOneSM Conference | Session BOF-9843 | 11
  12. 12. The Contenders Trail Domain Driven Design Sail Controller-centric Grail DDD / Full stack 2007 JavaOneSM Conference | Session BOF-9843 | 12
  13. 13. Agenda Brief History of Web Development Ruby On Rails Sails Trails Grails The Future of *ails 2007 JavaOneSM Conference | Session BOF-9843 | 13
  14. 14. • Started in 2005 • Brings the flavor of Rails development to Java • Viento: custom template engine • Rigging: custom dependency injection library 2007 JavaOneSM Conference | Session BOF-9843 | 14
  15. 15. Similar to *ails • Generates nice URLs • Promotes easy testing • Templates are closest to Rails of the 3 Java frameworks 2007 JavaOneSM Conference | Session BOF-9843 | 15
  16. 16. Differs from *ails • Does not provide utilities to generate scaffolding • No functionality to facilitate Hibernate persistence layer 2007 JavaOneSM Conference | Session BOF-9843 | 16
  17. 17. Components • Model: Hibernate • Developers don’t think ActiveRecord can be duplicated in Java • Already comfortable with Hibernate • View: Viento • Custom template engine • Supports partials and caching • Mixins • Controller: Rigging • Custom dependency injection library • Provides convention over configuration defaults 2007 JavaOneSM Conference | Session BOF-9843 | 17
  18. 18. Convention over Configuration • Controllers all go in a specific package • Action URL contains the controller name, action name, and action parameters • ‘widget/list’ => WidgetController.list() • Views all go under the /views webapp directory • View names match the controller/action names • /views/widget/list.vto • Template engine extensions follow similar pattern • View tools are in org.opensails.examples.tools • Mixins are in org.opensails.examples.mixins 2007 JavaOneSM Conference | Session BOF-9843 | 18
  19. 19. Generate Sample Application • Download zip file from opensails.org • Create Eclipse project • Import Existing Projects into Workspace • Select Archive file (downloaded zip file) • Configure Server • Run as Java Application • Main Class org.opensails.example.JettyBoot 2007 JavaOneSM Conference | Session BOF-9843 | 19
  20. 20. Add New Controller public class PostController Maps to /post/* urls extends BaseController { Extends BaseController public void list() { Maps to /post/list Exposes ‘posts’ to view expose("posts", postService.getAllPosts()); } public void view(int postId) { Maps to /post/view/#id Exposes ‘post’ to view expose("post", postService.getPost(postId); } public void add() { Exposes the Post model for exposeModel(“post”, new Post()); a form to use } public void save(Post post) { Post is loaded from the form // persist post } 2007 JavaOneSM Conference | Session BOF-9843 | 20
  21. 21. List Posts View (list.vto) <body> ... <table> Ruby like each construct <tr> <th>Date</th> <th>Title</th> Bean style attribute access </tr> $posts.each(cur_post) [[ <tr> <td>$cur_post.dateString</td> <td> <a href="/app/post/view/$cur_post.id">$cur_post.title</a> </td> </tr> ]] </table> <a href="/app/post/add">New Post</a> ... </body> 2007 JavaOneSM Conference | Session BOF-9843 | 21
  22. 22. Add Post view (/post/add.vto) <html> <head><title>Add Post</title></head> <body> $form.start $form.text('post.title').label("Title")<br /> $form.textarea('post.body').label("Body")<br /> $form.submit("Post Entry").action(save, [$post]) $form.end </body> </html> Maps to PostController.save(post) 2007 JavaOneSM Conference | Session BOF-9843 | 22
  23. 23. Viento: Top Level Mixins In Java: public class Mixin { public boolean isEven (int i) { return (i % 2 == 0); } } ... binding.mixin(new Mixin()); In Viento: $isEven($row_num) 2007 JavaOneSM Conference | Session BOF-9843 | 23
  24. 24. Viento: Type Mixins In Java: public class EvenMixin { public boolean isEven (int i) { return (i % 2 == 0); } } ... binding.mixin(int.class, new EventMixin()); In Viento: $row_num.isEven 2007 JavaOneSM Conference | Session BOF-9843 | 24
  25. 25. Viento: Method Missing In Java: public class TagTool implements MethodMissing { public String methodMissing(String methodName, Object[] args) { return “<” + methodName + “>”; } } ... binding.put(“tag”, new TagTool()); In Viento: $tag.div 2007 JavaOneSM Conference | Session BOF-9843 | 25
  26. 26. Viento: Custom Method Names In Java: public class Tool { @Name(“?”) public String question(String arg) { return “do something interesting”; } In Viento: $tool.?(“my string”) 2007 JavaOneSM Conference | Session BOF-9843 | 26
  27. 27. Roadmap • Project is dormant • Development team is now using Rails! • Lead developer was very helpful, and would like to see Sails continue 2007 JavaOneSM Conference | Session BOF-9843 | 27
  28. 28. Agenda Brief History of Web Development Ruby On Rails Sails Trails Grails The Future of *ails 2007 JavaOneSM Conference | Session BOF-9843 | 28
  29. 29. • Started in mid 2005 • Currently at 1.0-SNAPSHOT • Influences • Ruby on Rails • Naked Objects pattern 2007 JavaOneSM Conference | Session BOF-9843 | 29
  30. 30. Rails Influence • Rapid web application development • Scaffolding generation • Convention over configuration 2007 JavaOneSM Conference | Session BOF-9843 | 30
  31. 31. Naked Objects Influence • http://nakedobjects.org • Domain Driven Design • Domain objects are behaviorally complete • Domain objects have single point of definition 2007 JavaOneSM Conference | Session BOF-9843 | 31
  32. 32. Components • Tapestry • Spring • Hibernate • Maven 2007 JavaOneSM Conference | Session BOF-9843 | 32
  33. 33. Getting Started • Requirements • Java 1.5 • Maven 2 • trails-archetype • 1.0-SNAPSHOT: build locally • Release will be in maven repository 2007 JavaOneSM Conference | Session BOF-9843 | 33
  34. 34. Creating the Application mvn -U archetype:create -DarchetypeGroupId=org.trailsframework -DarchetypeArtifactId=trails-archetype -DremoteRepositories= http://snapshots.repository.codehaus.org/ -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=com.chariotsolutions.trailsdemo -DartifactId=trailsdemo 2007 JavaOneSM Conference | Session BOF-9843 | 34
  35. 35. What this generates Source structure created, and includes base domain object JUnit application test Hibernate configuration (set for HSQL) 2007 JavaOneSM Conference | Session BOF-9843 | 35
  36. 36. Running the Application mvn tomcat:run or mvn jetty:run • Create process generates a base domain object • Initially uses an in-memory HSQL database 2007 JavaOneSM Conference | Session BOF-9843 | 36
  37. 37. IDE Support • Because Trails is built on popular Java libraries, there is already pretty good support in the popular IDEs • mvn eclipse • mvn idea • Netbeans mevenide? 2007 JavaOneSM Conference | Session BOF-9843 | 37
  38. 38. Create Company domain class @Entity Define as an entity @ValidateUniqueness(property="name") Force name to be unique public class Company { private int id; private String name; Define Primary Key private String website; and generation method @Id @GeneratedValue(strategy = GenerationType.AUTO) public int getId() ... @PropertyDescriptor(index=0) public getName() ... Set screen display order @PropertyDescriptor(index=1) public String getWebsite() ... // omitted setters } 2007 JavaOneSM Conference | Session BOF-9843 | 38
  39. 39. Create Speaker domain class @Entity public class Speaker { private int id; private String name; private Date presentationDate; private Company employer; Define many to one relationship between speaker and company @ManyToOne @JoinColumn(name="company_id") @PropertyDescriptor(index=3) public Company getEmployer() ... } 2007 JavaOneSM Conference | Session BOF-9843 | 39
  40. 40. Ready to Go! mvn tomcat:run or mvn jetty:run 2007 JavaOneSM Conference | Session BOF-9843 | 40
  41. 41. Home page 2007 JavaOneSM Conference | Session BOF-9843 | 41
  42. 42. List Companies 2007 JavaOneSM Conference | Session BOF-9843 | 42
  43. 43. Search Company 2007 JavaOneSM Conference | Session BOF-9843 | 43
  44. 44. Add/Edit/Delete Company 2007 JavaOneSM Conference | Session BOF-9843 | 44
  45. 45. List Speakers 2007 JavaOneSM Conference | Session BOF-9843 | 45
  46. 46. Search Speaker 2007 JavaOneSM Conference | Session BOF-9843 | 46
  47. 47. Add/Edit/Delete Speaker 2007 JavaOneSM Conference | Session BOF-9843 | 47
  48. 48. Customizing View • Copy the default view to view specific to the controller. • cp DefaultEdit SpeakerEdit • Modify like any other Tapestry template 2007 JavaOneSM Conference | Session BOF-9843 | 48
  49. 49. Roadmap • Release version 1.0 • Search refactoring and Lucene integration • equals() Aspect 2007 JavaOneSM Conference | Session BOF-9843 | 49
  50. 50. Agenda Brief History of Web Development Ruby On Rails Sails Trails Grails The Future of *ails 2007 JavaOneSM Conference | Session BOF-9843 | 50
  51. 51. • Open-source web framework started in early 2006 • Most heavily influenced by Rails • Built with top of Groovy • Dynamic language • Can compile down to Java bytecode • Interoperability with Java key goal • 1.0 released early 2007 2007 JavaOneSM Conference | Session BOF-9843 | 51
  52. 52. First Cousin of Rails • Takes the most inspiration from Rails • Design really driven by language • Ruby drives Rails • Groovy drives Grails 2007 JavaOneSM Conference | Session BOF-9843 | 52
  53. 53. ...But not the Weird Cousin • All the libraries you already know • Hibernate 3.2 • Spring • SiteMesh • Quartz • And access to anything else in the Java world • Calls into Java natural 2007 JavaOneSM Conference | Session BOF-9843 | 53
  54. 54. What’s the Same? • Project quickstart / artifact generation • MVC • Convention over Configuration • Dynamic finder methods • Interactive console • Support for development/production mode 2007 JavaOneSM Conference | Session BOF-9843 | 54
  55. 55. What’s Different Philosophically? • Domain Driven Development • No class to inherit from • Class properties drive DB, not the other way around • Embrace Legacy • Support for more complex relationships with Hibernate • Middlegen support in the works • Go Beyond Crud • Grails Services • Half in Groovy, Half in Java 2007 JavaOneSM Conference | Session BOF-9843 | 55
  56. 56. What’s Different Technically? • Performance • Uses native threads • Runs on JVM • Deployment • Deploys as a war, hence any servlet container including app servers • These are arguably the motivations behind JRuby 2007 JavaOneSM Conference | Session BOF-9843 | 56
  57. 57. Up and Running grails create-app glogger 2007 JavaOneSM Conference | Session BOF-9843 | 57
  58. 58. Built-in support for Gives you... internationalization Support for transactional services Go under the covers when you need to Promotes TDD Your J2EE webapp 2007 JavaOneSM Conference | Session BOF-9843 | 58
  59. 59. What Else Can It Do? create-webtest create-controller generate-all create-domain-class generate-controller create-job generate-views create-plugin generate-webtest create-script install-plugin create-service install-templates create-tag-lib run-app create-test-suite run-webtest shell 2007 JavaOneSM Conference | Session BOF-9843 | 59
  60. 60. Dissecting the Domain grails create-domain-class Post groggergrails-appdomainPost.groovy groggergrails-testsPostTests.groovy 2007 JavaOneSM Conference | Session BOF-9843 | 60
  61. 61. Further Dissecting the Domain class Post { No super class!   String title   String body Simple properties automatically mapped   String author   String tags Easy definition of   Date datePosted relationships   static hasMany = [comments:Comment]   static constraints = { Powerful   constraints   title(unique:true, length:0..150)     body(blank:false, maxSize:5000)     datePosted(nullable:false)   } 2007 JavaOneSM Conference | Session BOF-9843 | 61
  62. 62. Generating the Rest grails generate-all Post grails-appcontrollersPostController.groovy grails-appviewspostlist.gsp ......................show.gsp ......................edit.gsp ......................create.gsp 2007 JavaOneSM Conference | Session BOF-9843 | 62
  63. 63. Groovy Views (GSP) • Groovy Server Pages • Creation of custom tags couldn’t be easier • No TLDs • Changes are seen instantly • Discourages scripting • Ships with large and growing tag library • Includes tags for AJAX 2007 JavaOneSM Conference | Session BOF-9843 | 63
  64. 64. Controllers - Generated class PostController { def index = { redirect(action:list,params:params) } def allowedMethods = [delete:'POST', save:'POST', update:'POST'] def list = { ... } def show = { ... } def delete = { ... } ... ... 2007 JavaOneSM Conference | Session BOF-9843 | 64
  65. 65. Controllers - Dynamic class PostController { def scaffold = true } 2007 JavaOneSM Conference | Session BOF-9843 | 65
  66. 66. Controllers - Dynamic Override class PostController { Implement methods to def scaffold = true override the default def list = { if(!params.max)params.max = 10 [ postList: Post.list( params ).reverse() ] } } 2007 JavaOneSM Conference | Session BOF-9843 | 66
  67. 67. Let’s See the App 2007 JavaOneSM Conference | Session BOF-9843 | 67
  68. 68. Glogger Homepage 2007 JavaOneSM Conference | Session BOF-9843 | 68
  69. 69. Create Post 2007 JavaOneSM Conference | Session BOF-9843 | 69
  70. 70. List Posts 2007 JavaOneSM Conference | Session BOF-9843 | 70
  71. 71. View Post 2007 JavaOneSM Conference | Session BOF-9843 | 71
  72. 72. Edit Post 2007 JavaOneSM Conference | Session BOF-9843 | 72
  73. 73. Dynamic Methods and Properties Post.findByAuthor("Matt") Post.findByTitleAndAuthor("Grails", "Matt") Post.findAll() Post.listOrderTitle() Post.hasErrors() Post.save() 2007 JavaOneSM Conference | Session BOF-9843 | 73
  74. 74. Services • Keeping business logic in the right place class PostService { boolean transactional = false } • Dependency Inject by Convention (Autowiring) class PostService { CommentService commentService } 2007 JavaOneSM Conference | Session BOF-9843 | 74
  75. 75. Builders - Query Criteria def c = Post.createCriteria() def results = c { like("title", "%grails%") and { eq("author", "Matt") } maxResults(10) order("title", "desc") } 2007 JavaOneSM Conference | Session BOF-9843 | 75
  76. 76. Builders - Configuration def bb = new grails.spring.BeanBuilder() bb.beans { dataSource(BasicDataSource) { driverClassName = "org.hsqldb.jdbcDriver" url = "jdbc:hsqldb:mem:grailsDB" username = "sa" password = "" } sessionFactory(ConfigurableLocalSessionFactoryBean) { dataSource = dataSource } } 2007 JavaOneSM Conference | Session BOF-9843 | 76
  77. 77. Builders - XML Generation import groovy.xml.MarkupBuilder <blog> def xmlDoc= new MarkupBuilder() <post title="Grails Rocks" author="Matt"> <body> xmlDoc.blog { post(title:"Grailsreal potential Grails has some Rocks") { </body> body("Grails has some real potential") <comment author="anonymous"> comment("Yeah right", author:"anonymous")) Yeah right. } </comment> } </post> </blog> 2007 JavaOneSM Conference | Session BOF-9843 | 77
  78. 78. Grails Roadmap • 1.0 now targeted for autumn 2007 • Performance and stability are key • Middlegen support • JPA support • JavaScript templates 2007 JavaOneSM Conference | Session BOF-9843 | 78
  79. 79. Agenda Brief History of Web Development Ruby On Rails Sails Trails Grails The Future of *ails 2007 JavaOneSM Conference | Session BOF-9843 | 79
  80. 80. Popularity 2007 JavaOneSM Conference | Session BOF-9843 | 80
  81. 81. Jobs 2007 JavaOneSM Conference | Session BOF-9843 | 81
  82. 82. But... Room for Growth 2007 JavaOneSM Conference | Session BOF-9843 | 82
  83. 83. Why Aren’t *ails More Popular? • Haven’t reached critical 1.0 milestone • Do Trails/Sails solve enough pain points? • JRuby • Are Java developers holding out for JRuby on Rails? • Inertia? • Rails already has huge community, documentation, training, etc 2007 JavaOneSM Conference | Session BOF-9843 | 83
  84. 84. Q&A 2007 JavaOneSM Conference | Session XXXX | 84
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×