Chariot Training Classes

Training Courses

I run Chariot's training and mentoring services. We provide training in AngularJS, HTML5, Spring, Hibernate, Maven, Scala, and more.

Chariot Education Services

Technology

Chariot Emerging Tech

Learn about upcoming technologies and trends from my colleagues at Chariot Solutions.

Resources

Chariot Conferences

Podcasts

« Debugging add-ons via the Roo shell | Main | Maven Search Site Online »
Sunday
Aug212011

Now you can choose ActiveRecord or Service/Repo for Roo 1.2

Check it out!  Now you can install services and repositories, and when you scaffold the project automatically generates calls to the service layer rather than to the Active Record pattern.

I think personally it's a huge win for Roo to be able to support both approaches, since having to switch tools based on a difference in one pattern approach to me feels wrongheaded.  Here's a screenshot from IntelliJ:


The new service model in action with IntelliJHere is a snippet of the code written in the CourseController_Roo_Controller.aj file proving the nice integration:

privileged aspect CourseController_Roo_Controller {
  
  @Autowired
  CourseService CourseController.courseService;
  
  @RequestMapping(method = RequestMethod.POST)
  public String CourseController.create(@Valid Course course, 
       BindingResult bindingResult, Model uiModel, 
       HttpServletRequest httpServletRequest) {
    if (bindingResult.hasErrors()) {
        uiModel.addAttribute("course", course);
        return "courses/create";
    }
    uiModel.asMap().clear();
    courseService.saveCourse(course);
    return "redirect:/courses/" + 
         encodeUrlPathSegment(
            course.getId().toString(), httpServletRequest);
  }
  
  @RequestMapping(params = "form", method = RequestMethod.GET)
  public String CourseController.createForm(Model uiModel) {
      uiModel.addAttribute("course", new Course());
      return "courses/create";
  }
  
  @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  public String CourseController.show(
      @PathVariable("id") Long id, Model uiModel) {
    uiModel.addAttribute("course", courseService.findCourse(id));
    uiModel.addAttribute("itemId", id);
    return "courses/show";
  } 
...
}

To try it out, head over to the nightly builds page and download the latest nightly.  (Do NOT unzip this over a working 1.1 or earlier 1.2 or you'll be crying a sweater of tears).  Then, make your /usr/bin/roo or /usr/bin/roo12 symbolic link (my angle as during the writing of the book I've been testing things against roo 1.1, 1.2, etc).  Create your project and you'll see the options.

You can build this if you put the snapshot repository into your list of repositories in your pom.xml file:

<repository>
    <id>spring-roo-internal-repo</id>
    <name>Spring Roo Internal Snapshot Repo</name>
    <url>http://spring-roo-repository.springsource.org/snapshot</url>
</repository>

Best of luck, and enjoy playing with the upcoming Roo features. I'm also going to check out some newer add-ons, such as JSF and the newly updated Flex (by Roo forum contributor working with the team on a patch) and GWT addons in future blog entries. For now, though, it's back to my add-ons chapter, which is coming soon.

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (3)

This is cool stuff, finally ROO can be a serious contender in my service infested work project.

Also looking forward to your ROO Addons chapter in MEAP.

What about another pen-cast, the one you did is a great resource.

August 21, 2011 | Unregistered Commenterhatim

Whoops, I defiantly mixed you up with your colleague author for the pen cast :D

August 31, 2011 | Unregistered Commenterhatim

Hatim,

LOL, no worries!

We work across the room from each other at Chariot anyway, and we've known each other for 20+ years! He's the experimentalist - PenCasts, Prezi presentations, etc... Someone we worked with used to call us the Bopsi Twins back in the 90's when we worked for a training / consulting outfit.

For those reading, he's at the Technophile Blog, and is a very deep expert in all things Spring Integration, and other enterprise Springy things. We both teach Spring for Chariot. See our upcoming training events page for course schedule.

September 4, 2011 | Registered CommenterKen Rimple

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>