introduction to spring roo 1.0.0

Post on 17-May-2015

21.815 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

Introducing Spring Roo 1.0.0, which is a Java-based rapid application development framework. This presentation represents an updated version of the session I delivered at SpringOne USA in October 2009.

TRANSCRIPT

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.

Introducing Spring Roo 1.0.0

Extreme Productivity in 10 Minutes

Ben Alex, Project Lead, Spring Roo

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 2

Agenda

• Introducing Roo• Capability Areas• Using Roo• Roadmap and Resources

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 3

Agenda

• Introducing Roo• Capability Areas• Using Roo• Roadmap and Resources

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 4

Mission Statement

“Roo's mission is to fundamentally and sustainably

improve Java developer productivity without

compromising engineering integrity or flexibility”

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 5

End User's Description

“Roo is a little genie who sits in the background and

handles the things I don't want to worry about”

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 6

What Is Roo?

• Roo is an extensible, text-based RAD tool for Java

• Roo is development-time only (no Roo runtime)

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 7

Roo Infrastructure

Implementation Overview

User's Project

.aj .xml .jsp .properties

RooAdd-OnsRoo

Add-OnsRooAdd-Ons@Roo

Annotationsprovide

source onlyretention

.java

monitor andchange

RooAdd-Ons

STS

Shell

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 8

Easy To Learn and Use

• Usability you'll love– “hint” and “help” commands to guide you all the way– TAB completion for nearly everything– Command hiding and automatic contextual awareness– Even if you make a mistake, Roo will rollback changes!

• Scriptable UI that can even “replay” scripts

• You're in charge and Roo won't get in your way– Roo acts predictably and conservatively at all times

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 9

Familiar Libraries

• Roo builds on what you already know– Popular, proven, and mature APIs at your full disposal

• Java• Spring Framework• Java Persistence API (Hibernate)• Java Server Pages• Spring Security• Spring Web Flow• Log4J, Maven, AspectJ, Eclipse/STS...

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 10

Uses Java's Strengths

• The world's most popular language (Tiobe)– Skills availability, vendor choice, low risks, open source

• APIs are popular, standardised, safe, proven

• Quality, mature and deep tooling integration– IDE code assist, debuggers, refactoring, profilers etc

• Static typing– Fewer errors, robust refactoring, code assist, JVM design

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 11

Cloud-Class Scalability

• Zero performance overhead– Efficient, reflection-free code– No dynamic proxies, deferred compiling, LTW or similar– No Roo runtime means no runtime performance cost

• Zero memory overhead– No class creation means no Perm Gen memory issues– No Roo runtime means no runtime memory cost

• Zero deployment footprint– Roo apps leverage OSGi bundles out-of-the-box– No Roo runtime means no WAR footprint size

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 12

More Great Stuff

• No lock-in– Get rid of Roo from your project in under 10 minutes!

• Easy to write and deploy your own Roo add-ons– Roo can even write them for you (seriously!)

• Open source and SpringSource maintained– SpringSource-endorsed application architecture

• Consistent apps across your team and enterprise

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 13

Code Generation Approach

• Roo is a hybrid code generator– The best of the passive and active generation models– Achieved by use case-specific design decisions

• Passive generation– Use Roo shell to make Roo generate something– It's done and it's finished (usually .xml and .java files)

• Active generation (automatic round-tripping)– Builds detailed metadata model with help of @Roo*– Incrementally updates .aj, .jsp files - never .java files

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 14

AspectJ ITDs

Active Generation

Person_Roo_ToString.aj

toString():String

Person.java

name:String

write

Person_Roo_JavaBean.aj

getName():StringsetName(String):void

readRooAdd-OnsRoo

Add-OnsRooAdd-OnsRoo

Add-Ons

Person.class

name:StringtoString():String

getName():StringsetName(String):void

AspectJCompiler

read read

writeCompilation unit separationwith automated round-trips

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 15

Demo #1

The Roo Tour:

A Web App Without Reading The Manual

(or blogs, web sites, samples, pre-written code or similar)

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 16

Agenda

• Introducing Roo• Capability Areas• Using Roo• Roadmap and Resources

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 17

Out Of The Box

• Project management• General object services• Entity support• Field management• Persistence• JUnit testing• Dynamic finders• Spring MVC, Spring Web Flow and Selenium• JMS, SMTP and build system integration• Spring Security, Logging Setup.....

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 18

Project Management

• Commands– “project” creates new project in current dir→

– “dependency add” adds dependency to POM→

– “dependency remove” opposite of add→

– “backup” creates ZIP of project→

• All dependencies use Enterprise Bundle Repo– Versioned, quality-checked, OSGi-compatible JARs

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 19

General Objects

• Roo annotations suitable for any class– @RooJavaBean – getters and setters for free– @RooConfigurable – adds Spring @Configurable– @RooToString – you guessed it

• Roo will automatically maintain the code for you

• Roo won't get in your way– It just sits in the background and writes code you don't– You don't have to “tell” it to stop doing something– You don't have to use the Roo shell (any editor will do)

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 20

Entity Support

• “entity” creates an → @RooEntity– Delivers a flexible, feature-rich JPA entity– Declares a JPA @Entity with id, version, EntityManager

and a no-arg constructor– Automatically adds count, findAll, findById, findEntries,

persist, remove, merge and flush methods to an entity

• Command accepts many optional directives– Whether to build an automatic integration test– Table name, identifier column name etc

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 21

Field Management

• “field” commands for most major field types

• Field commands have options for– JPA-specific annotations (--fetch, --column etc)– JavaBean valiation-specific annotations (--max etc)– Java modifiers (--primitive, --transient etc)

• Shell remembers last entity you worked with– Fields are automatically added to that entity– Override using --class

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 22

Persistence

• “persistence setup”– Use --provider for Hibernate, OpenJPA and EclipseLink– Use --database for most common databases

• Related commands– “persistence exception translation” via AspectJ→

– “database properties list” lists JDBC props→

– “database properties set” changes JDBC prop→

– “database properties remove” deletes JDBC prop→

• You can re-run “persistence setup” at any time– Switch from Hibernate to OpenJPA in one line!

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 23

JUnit Testing

• “test integration” JUnit integration test→– Automatic “data on demand” feature for seed data– This is implied with “entity --testAutomatically”

• “test mock” JUnit mock test→– Allows test mocking of static methods in your entities

• “dod” creates a → data on demand class– Rarely used directly– Automatically created if tests require it

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 24

Dynamic Finders

• Saves you having to write JPA QL finders– Roo will write them for you, complete with type safety!

• Finders are added as static methods to entities– They're even compatible with abstract entities– “finder list” shows all available finders→

– “finder add” enable a specific finder→

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 25

Easy Spring Web MVC

• “controller scaffold” an automatic controller→– Automatic REST controller for a given entity– Automatic JSP creation and maintenance– Can fine-tune allowed methods (CRUD subset)– Permits date format to be specified

• “controller all” automatically scaffold all entities→

• “controller class” stub a → manual controller– Just the controller – you write the rest

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 26

Web Stack

• Automatic Spring JS, Tiles and URL Rewrite

• “selenium test” Test a scaffolded controller→– Start Tomcat with “mvn tomcat:run”– Then run the test with “mvn selenium:selenese”

• “webflow” Create a flow with Spring Web Flow→

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 27

Messaging: SMTP and JMS

• “email sender setup” setup SMTP sender→

• “field email” adds an email sender field→

• “jms setup” sets up JMS support→– Optionally embeds a TCP-accessible ActiveMQ instance

• “field jms template” adds a JMS sender field→

• “jms listener class” makes a JMS receiver→

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 28

Build System Integration

• Assorted build options– “perform clean” runs “mvn clean eclipse:clean”→

– “perform eclipse” runs “mvn eclipse:eclipse”→

– “perform tests” runs “mvn test”→

– “perform package” runs “mvn package”→

– “perform command” custom mvn command→

• You must have Maven setup and in path to use• Often used at end of “script” files

– Verifies success– Brings project into Eclipse for further work

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 29

Miscellaneous

• “security setup” sets up Spring Security→

• “logging setup” sets up Log4J configuration→

• “script” executes a script→– Specify clinic.roo, wedding.roo, vote.roo and

bundlor.roo for inbuilt sample applications– Specify a fully-qualified file system path for your files

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 30

Demo #2

Exploring “script clinic.roo”

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 31

Agenda

• Introducing Roo• Capability Areas• Using Roo• Roadmap and Resources

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 32

Requirements

• Java 5– Same as Spring 3

• Maven 2.0.9 or above– Roo itself doesn't need Maven installed to work– Maven is only needed for Roo-generated projects– ROO-91 requests Ant/Ivy vote if you'd like it!→

• Tested with Linux, Windows and Apple– All platforms support tab completion and a colour shell

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 33

Download and Easy Install

• Download Roo from www.springsource.org/roo– Simply unzip and add to your path

• Linux/Apple users would use something like:– sudo ln -s $HOME/spring-roo-

1.0.0.RELEASE/bin/roo.sh /usr/bin/roo

• Windows– Add %HOME%/spring-roo-1.0.0.RELEASE/bin to PATH

• A public Subversion repository is also available– See readme.txt in root of checkout for dev installation

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 34

IDE Interoperability

• We highly recommend SpringSource Tool Suite– Download it from www.springsource.com– Totally free to use– Includes Roo integration (eg CTRL-ALT-R commands)– Also pre-bundles AJDT and other useful IDE plugins

• Eclipse also works, but use the latest AJDT– Eclipse does not provide STS' Roo integration– Roo can still be used concurrently via the shell

• Roo also happily lives alongside emacs, vim, notepad, and no IDE at all

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 35

Lifecycle Notes

• SpringSource Tool Suite– Use the embedded Roo option

• Any other case– Load Roo at the same time as your IDE or text editor– Roo automatically detects changes made outside Roo

• No need to add Roo to your build system– Although “roo quit” will run Roo, update files and exit

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 36

Upgrade Actions

• When you upgrade Roo, .aj files may change– This is a feature of active code generation– We make optimizations and enhancements in .aj files

• Please refrain from editing Roo's .aj files– Roo “owns” the *_Roo_*.aj files– You can freely edit any file in your project except these

• Just “push-in refactor” any .aj files you wish to edit

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 37

Removing Roo in Three Steps

1.Use AJDT's “push-in refactoring” feature– This moves the Roo .aj content into normal .java files

2.Remove Roo's annotation JAR from your POM– You can use Roo's “dependency remove” command

3.Remove @Roo* annotations from .java files– Use a regular exp find/replace in Eclipse for speed

• You can still use Roo on the project again– Its “hands off by default” will ensure it's problem-free

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 38

Roo Internals

• “development mode” full exception tracing→

• “poll status” auto-scaled file monitoring stats→

• “poll speed” adjust auto-scaled file monitoring→

• “poll now” force an immediate file scan→

• “metadata status” metadata statistics→

• “metadata for type” metadata summary→

• “metadata for id” metadata information→

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 39

Add-On Services

• Third parties can easily publish new add-ons– See the addon.roo script

• “addon list” lists add-ons presently installed→

• “addon install” downloads and installs add-on→

• “addon uninstall” removes an add-on→

• “addon cleanup” refreshes the environment→

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 40

Recommendations

• Use SpringSource Tool Suite• Don't remove Roo from your projects

– You'll have much code to now manage by hand again– You'll miss out on automatic upgrade improvements– Consider removal as your insurance against lock-in

• Record your jump-start applications as scripts– It's now so quick to change your design, so enjoy it!– Defer custom coding until your model seems correct

• Ask questions on the forum for fast support

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 41

Demo #3

Roo IDE Integration

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 42

Agenda

• Introducing Roo• Capability Areas• Using Roo• Roadmap and Resources

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 43

Present Release

• Spring Roo 1.0.0.RELEASE

• Released 31 December 2009

• Extensive community feedback over 8 releases

• Plenty of documentation and tutorials included

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 44

Project Resources

• Home → http://www.springsource.org/roo

– Contains links to all other resources

• Forum → http://forum.springsource.org– Roo team actively monitor forum and answer queries

• Issues → http://jira.springframework.org/browse/ROO

• Twitter → #roo hash key

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 45

Conclusion

• Roo delivers serious productivity gains for Java

– Popular, proven technologies you already know– Easy to learn and easy to use– Builds on Java's strengths– Extreme performance– No runtime, no lock-in, no risk

• An active, supported, open source project

• Questions? balex@vmware.com

top related