This presentation was given to the Dallas Spring User Group http://www.springdallasug.org/ for educational purposes and made available as a non-profit contribution to the learning community.
2. What is Spring Roo?
● Roo is CLI shell tool to create Spring Applications without
dealing with the environmental complexities of system
configuration
● Roo can transparently take care of client/server
development cycle and is independent of the application
runtime environment
● Spring Roo is an extensible Rapid Application
Development (RAD) tool for building enterprise
applications without engineering trade-offs
● Roo is a friendly Magic Genie watching over your source
code to make sure code dependencies are
updated/modified while you work on the project
2
3. Why use Spring Roo?
● Roo can passively generate a custom Spring Reference
Implementation (RI) based on your requirements and your
design inputs
● If you know how to write Spring Enterprise Applications then
Roo can help with actively manage code dependencies
● And if you don't know Spring, then you will discover how Roo
implements best practices within your Spring application
3
5. Roo Implementation
● Roo Infrastructure {Roo Flex Add-On, STS
Eclipse IDE, Command Shell} generates Spring
Framework source code
● Roo Infrastructure monitors and updates User
project files {as, aj, java, xml, jsp, properties}
● Roo Infrastructure builds detailed metadata
model for @Roo Annotations within class files to
aid in incremental updates to AOP management
functions {Finders, Setters,Getters,toString,etc.}.
5
6. Roo Workflow
● Roo writes the AspectJ Inter-Type Declaration
(ITD) source files to support methods like
toString(), Getters, Setters, and Finders.
● Roo reads (monitors) Java and other source
files to update aspects accordingly to
implementation changes in domain objects.
● AspectJ Compiler reads all the above source
files and writes byte code class files for JVM
execution.
6
7. What is Flex Add-on?
● Roo tool extension to implement Adobe's Open Source
Software libraries including Blaze Data Services (BlazeDS)
on the backend and Flex Framework on the front end
● Automates the configuration of Spring BlazeDS Integration project
including Spring Framework, Maven, and Eclipse
● Generation of BlazeDS @RemotingDestination services with
full CRUD capabilities for each specified domain entity
● Continuous synchronization of changes between ActionScript and
Java domain classes for AMF remoting capabilities
● UI scaffold generation to continuously updated as changes occur
in the corresponding ActionScript or Java classes
● Client-side Flex validators generation corresponding to the Bean
Validation annotations on the Java model 7
8. What is BlazeDS?
● Blaze Data Services is Adobe Open Sourced Software supporting
ActionScript Message Format (AMF) to give the Flex Client more
options with server connectivity
● BlazeDS Remoting service can invoke Java objects deployed in
application server container.
● BlazeDS Messaging service provides publish/subscribe middleware
infrastructure to allow real-time data push to clients and collaborative
application communication across clients.
● BlazeDS Proxy service provides cross-domain service requests in a
secure and controlled manner.
● BlazeDS is deployed as a Java Archive (JAR) in the web application
8
9. Client/Server Communication
Flex Client ↔ Java MessageBrokerServlet (Server)
communicates <-talks-to-> using the following
messaging transports:
● Servlet-based Endpoints ↔ HTTP Proxy
● HTTP Endpoints ↔ HTTP Proxy
● AMF Endpoints ↔ Message
● Streaming AMF Endpoints ↔ Remoting
9
10. What is Flex?
● User Interface (UI) component framework from Adobe freely available
in a SDK package for building Rich Internet Applications (RIAs)
● The Flex (Fx) SDK is Open Sourced Software – Free to develop-with
& delivery-to internet users. Flex supports 98% of all web users
across multiple browser vendors within browser versions
● The Flex SDK provides many component libraries, a compiler with
debugger, and Java-Doc style documentation
● Flex has an extensive set of UI class libraries going far beyond the
capabilities of Java Swing
● Stand-alone Flex clients can access back-end data using either the
HTTPService or SOAP WebService components without BlazeDS
● More information please see resource slides at the end
10
11. What are the Flex source files?
● ActionScript (.as) - ECMAScript-compliant, object-oriented
programming language. Flex looks and feels like Java,
and supports the same object-oriented constructs:
packages, classes, inheritance, interfaces, strong typing,
dynamic typing and data binding.
● MXML (.mxml) - Macromedia XML presentation
description language, like JSPs are to Java, built on top of
ActionScript to allow declarative construction of view
components
● The Flex source code (.mxml and .as files) is compiled
into Flash byte-code (.swf like .jar) executed on the client
browser by Flash Player or on the desktop by AIR
Platform
11
12. Flex Deployment Targets
● Fx SDK/Flash → (.swf file) → Flash Player in Browser
● Fx SDK/AIR → (.air file) → AIR Platform on Desktop
{Native OS Application}
● Fx Hero SDK → (.apk or.ipa file) →
Android or Apple iOS
{Native OS Application}
● Hero SDK is based on subset of the Flex 4.x SDK and
optimized for mobile device architectures
12
13. What is the difference between
Flash and Flex technology?
● Flash (Fl) is design around a central time-line for creating
graphic animations
● Flash can not run on Desktop AIR platform therefore no access
to native APIs from the OS environment
● Flex (Fx) is programmatically based on event model from users
and application generated events. Plus supports interactive
data visualization components.
● Flex on AIR Platform supports multiple device form-factors from
mobile phones, TV Set-top boxes, entertainment hand sets, etc.
● Both use ActionScript programming (similar to Java), but Flash
does not use MXML files
● Both Flash and Flex use binary (.swf) file to run in the
ActionScript virtual machine, like Java virtual machine 13
14. Flex in Adobe Platform
● Adobe Flash/Flex technology supports multiple
screens on multiple hardware platforms for RIA
applications with rich user content and video
● Adobe Flash Builder is the designer and development
tool for the RIA application platform
● Adobe Flex framework is the Software Development
Kit (SDK) for RIA applications
● Adobe Air and Flash Player provide the run-time
execution environment for RIA applications
● Adobe BlazeDS provide the RIA application
communication services to the Java server-side
14
15. Software Resources
● Spring Source Tools Suite – STS 2.3.3.M1 Release
http://bit.ly/7vNfLN
● Spring Source Roo 1.1.0.M1 Release
http://www.springsource.org/roo/start
● Adobe Flash Builder 4 Plugin (Flex 4 SDK)
http://bit.ly/cgJNRG
● Spring BlazeDS Integration 1.5.0.M1 Distribution
for Flex Add-on support
http://bit.ly/c0UhUh
● Installing Flex Addon documentation from
Spring BlazeDS Integration Reference Guide
http://bit.ly/c86for
15
16. Demo Highlights
● Launch STS tool, inside fire up the Roo shell tool
● Run the Roo Flex script in the Roo shell tool to
create the Demo Application. Note: Allow mvn console
to finish command execution before next entry.
● Run the Demo Application in a browser
● Take deep drive into Roo script and
see each command executed from Roo script
● Use the Roo shell console to access the managed files
in the project and review the Roo actions and created
artifacts
16
17. Spring Flex Demo
1. Run the Roo Script
• Create project
• Setup persistence
• Setup data resources
• Create domain – entities & fields
• Create controller (No DAO)
• Create UI scaffold from domain model
• Create Tests
2. Run the App
3. Run the Test
4. Remove Roo Artifacts
5. Redeploy without Roo files
17
18. Shell Commands
persistence setup --database H2_IN_MEMORY --provider HIBERNATE
flex setup
entity --class ~.domain.Presenter --testAutomatically
field string --class ~.domain.Presenter --fieldName presenterName --notNull
field string --class ~.domain.Presenter --fieldName springModule --notNull
field date --class ~.domain.Presenter --fieldName presentationDate --type java.util.Date --notNull
field boolean --class ~.domain.Presenter --fieldName usefulInformation
flex remoting all --package ~.service
entity --class ~.domain.Feedback
field reference --fieldName presenter --type ~.domain.Presenter
field number --fieldName lengthOfPresentation --type java.lang.Float --decimalMin 30.0
--decimalMax 120.0
field number --fieldName difficulityRating --type java.lang.Integer --min 1 --max 5
field boolean --fieldName goodDemostration
flex remoting scaffold --name ~.service.FeedbackService
18
19. Run Application
● Deploy the new application – configure Tomcat server by drag
drop project folder onto “SpringSource tc server”, start-up
Tomcat server, and then run your new application in browser
● Test out the UI – create two Presenter records, create two
Feedback records and attach to the a Presenter record
● Copy browser URL and startup another browser with the
application URL to view data changes from the H2 database
● Delete one Feedback record and edit one field in Presenter
record. View changes in both browsers/applications
19
20. Testing Code Updates
● Edit the Action Script class by adding a line of code like
public var NewName:String;
● Check the Roo shell to see if the change has been added to the
server side Java files.
● On the client side, we will switch over to the Flash Builder
perspective - we see the action script files and mxml files
matches the changed domain classes as specify for the GUI
presentation.
● See what happens in the Flash Builder Perspective?
Review both Java and Flex source files for updates in design
view editor of Eclipse.
20
21. Removing Capabilities
● You can avoid system lock-in with Roo by -
● Push-In Refactor by ITD insertion into Java
● Pull-Out Roo Annotations from source files
● Remove Roo Annotation JAR file and delete
the pom reference from the project
● Best of all – you can re-enable Roo after the
above removal process was completed
21
22. Push In Refactor -
AspectJ ITD into Java
● You can manually remove the Roo meta data and Aspects
from your project to yield a Spring Flex Application without
.aj files.
● Push in POJO attributes from the Spring Aspect JavaBean
classes using STS Refactoring feature
● Finally, remove all Roo generated aspects via menu options:
Select Project icon → Source → Refactor → Push-In
● Tip - remove errors: Refresh, Clean, Rebuild mvn project.
22
23. Pull-Out Annotations 1/2
● If you want to pull out Roo Annotations, then consider taking a
snap shot of the code in a repository for app backup. Also,
create .roo script file using the Roo backup command.
● A best practice would be to get the model, entities and fields
nailed down before pulling out Roo.
● Pull out (or comment out) POJO attributes and then watch the
Roo shell automatically do it's magic.
23
24. Pull-Out Annotations 2/2
● Begin by removing the @Roo annotation from Java files
Search->File Search string replace “n.*Roo.*n” without quotes
on .java files, check Regular Expression checkbox, click
Replace button. Enter the “n” in the text box.
● Remove jar artifact “org.springframework.roo.annotations-*.jar
artifact from the pom.xml file and then refresh STS.
● Execute “mvn eclipse:clean” and then “mvn eclipse:eclipse”
● Check the Roo generated aspect files are delete from Roo
project and all related Java project files have been updated with
the methods from the Spring AspectJ files.
24
25. New Features
● Incremental reverse engineering of existing
databases
● Enhanced ORM Entity Relationship support
● Google Web Toolkit (GWT) & Google Application
Engine (GAE) Integration
● JSON support in Spring MVC apps
● Social Media Integration Support (16)
Example: YouTube, Flikr, Picasa, Google Maps, Twitter, Facebook, etc.
● Flash message area in STS
● More info see SpringSource - Team Blog post
http://blog.springsource.com/2010/08/25/spring-roo-1-1-0-m3-released/
25
26. Resources
● Project Home
● http://www.springsource.org/roo
● More resources, like videos, ref cards, guides, manuals...
● Community Forums
● http://forum.springsource.org/
● Roo team monitors the forum and answers queries
● Issue Tracker
● http://jira.springframework.org/browse/ROO
● Twitter - Latest Roo Announcements
● Search code: #roo
● Follow @schmidtstenfan, @benalexau, @SpringRoo
26
27. Roo & Flex Book Resources
● Adobe Flex 4: Training from the source – by Michael Labriola,
Jeff Tapper, Matthew Boles
● First Steps in Flex - by James Ward, Bruce Eckel (Java Guy)
● Flash Builder 4 & Flex 4 Bible – by David Gassner
● Flex 4 Cookbook – by Joshua Noble, Todd Anderson, Garth
Braithwaite, Marco Casario, Rich Tertola, David Tucker
● Flex 4 in Action - By Dan Orlando, Tariq Ahmed, John C. Bland
II, Joel Hooks (Dallas native – Robot Legs),
● Spring Roo in Action (Manning Early Access Edition) – by
Gordon Dickens and Ken Rimple, Twitter @rooinaction
27
28. Adobe Resources
● Adobe Developers Network – Java & Flex
http://www.adobe.com/devnet/flex/flex_java.html
● Adobe's Flex quick-start tutorial:
http://www.adobe.com/devnet/flex/quickstarts/index.html
● Adobe LiveDocs online reference documentation:
http://bit.ly/4TVeT5
● Adobe TV: http://tv.adobe.com/product/flex
● Adobe Learn Flex In A Week video training:
http://www.adobe.com/devnet/flex/videotraining
● Adobe Tour De Flex – running Flex examples & view source code:
http://www.adobe.com/devnet/flex/tourdeflex/
● Dallas Flex User Groups (D-Flex) – Meets Third Thursday night
of each month. Click here for details. http://bit.ly/dzAyq7
28
29. Developer Zone Resources
Offers free Reference Cards (RC) to help you get started
in Flex & Spring Frameworks -
● Dzone RC17 Very First Steps in Flex
http://refcardz.dzone.com/refcardz/very-first-steps-flex
● Dzone RC75 Getting Started with BlazeDS
http://bit.ly/afTkc7
● Dzone RC91 Getting Started Adobe Flash Builder 4
http://bit.ly/ckbw9W
● Dzone RC102 Flex 4 & Spring 3 Integration
http://bit.ly/bSmgIu
29
30. Questions & Answers
1) Can you create a RESTful Flex client with Spring? Yes, use the
HTTP Remote object in Flex client.
2) Can Flex client connect to more than one BlazeDS server?
Yes, without cross domain file required on the server.
3) How can I push data from one Flex client to many Flex clients?
Publish a JMS message in a queue to be pushed to
client subscribers. See Test Drive at http://bit.ly/a1s8gq
4) How do you implement the different polling mechanisms in
Flex/Spring Integration? Very simple just change the configuration
properties as follows:
<flex:message-broker>
<flex:message-service
default-channels="my-streaming-amf,my-longpolling-amf,my-polling-amf" />
<flex:secured />
</flex:message-broker>
30
31. Spring Flex Summary
● A great RAD tool for Spring application development
● Script driven => easy to learn, modify, and reuse
● Provides Reference Implementation application
● Supports Best Practices from Spring community
● No Lock-ins with runtime, no deployment footprint,
and no control flow invocation or altercation
● Open source extensibility includes OSGI add-on
● Flex can build RIA Clients for Java developers
● Thanks for you time and attention. :)
31
32. More Resources
Slide 5 - Roo Implementation & Slide 7 Roo Workflow
http://www.slideshare.net/benalexau/introduction-to-spring-roo-100-2805183
Slide 9 – Client/Server Communication
http://opensource.adobe.com/wiki/display/blazeds/BlazeDS/
Slide 12 – Flex Deployment Targets
Paul Trani on SlideShare, http://slidesha.re/9qeSK4
Slide 14 – Flex in Adobe Platform
http://www.adobe.com/products/
http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK
http://www.adobe.com/products/flashplatformruntimes/
Special thanks for resource contributions from SpringSource Engineers
and Adobe Evangelists
32
33. SpringSource Roo
Flex Add-on Presentation
● Most of the presentation resources (images, text, etc.)
displayed herein are respectfully owned by the following:
Adobe Flex http://www.adobe.com/products/flex/
Dzone http://refcardz.dzone.com/
Oracle Java http://www.oracle.com/technetwork/java/index.html
SpringSource Roo http://www.springsource.org/roo
● The software technologies presented are copyright protected
and/or patented by the respective companies and/or
contributing authors herein.
● This is an informational presentation given for educational
purposes only, as a non-for-profit contribution, to support the
learning of open source software related and non-related
technologies.
33
34. LIABILITY DISCLAIMER
● THE PRECEEDING SOFTWARE RESOURCES PRESENTED ARE
PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
PRESENTATION OR RESOURCES, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
34