Spring Roo – Cheat Sheet
New project:
- “project –topLevelPackage com.jmh.????”
- “persistence setup –provider HIBERNATE –database ORACLE”
- create entities (below)
- “web mvc setup”
- “web mvc all –package ~.web”
note: May need to change the oracle dependency to 10.2.0.2.0
Entity -
- MongoDB -
- “mongo setup”
- “entity mongo –class ~.domain.Pizza”
- “repository mongo –interface ~.repository.PizzaRepository –entity ~.domain.Pizza”
- JPA – Set up persistence: “persistence setup –provider HIBERNATE –database ORACLE”
- Create new object: “entity –class ~.domain.foo –testAutomatically”
Create properties:
- “field string –fieldName name –notNull –sizeMin 2″
- “field number –fieldName price –type java.lang.Float”
- “field date –fieldName deliveryDate –type java.util.Date”
- “field enum –fieldName color –type ~.domain.Colors” (create using ‘enum type –class ~.domain.Colors, enum constant –name RED, enum’) constant –name BLUE,
- m:m – “field set –fieldName toppings –type ~.domain.Topping”
- m:1 – “field reference –fieldName base –type ~.domain.Base”
Annotations -
@RooEntity(identifierField = “personId”, identifierColumn = “PERSON_ID”)
Add an enum: “enum type | constant [...]
Reverse Engineer an Existing Database – LINK
“database introspect –schema no-scehma-required”
“addon info id –searchResultId 01″
“addon install id –searchResultId 01″
“database reverse engineer –schema blah –package ~.domain –testAutomatically –enableViews”
Testing -
“perform tests”
create a new integration/mock/stub test for the entity – “test integration | mock | stub”
Web Tier -
- initial project MVC setup: “web mvc setup”
- scaffold all entities – “web mvc all –package ~.web”
- scaffold an entity – “web mvc scaffold –class ~.web.EntityController”
Controller Annotations – @RooWebScaffold(path = “pizzaorder”, formBackingObject = PizzaOrder.class,
delete=false, update=false)
Select list text – Entities referred to in select lists automatically have a @ModelAttribute added and a conversion service to create the text. Go to ApplicationConversionServiceFactoryBean_Roo_ConversionService.aj to modify the text that appears in the select boxes.
Finders -
to list available finders, focus on desired entity then “finder list”
to add a finder from list, “finder add –finderName blah”
Security -
security setup
creates applictionContext-security.xml in …META/INF/spring
JMS
“jms setup –provider ACTIVEMQ_IN_MEMORY”
configures a JMS sender in an arbritrary target type – “field jms template –class ~.domain.Person –async”
new class to receive messages – “jms listener class –class ~.jms.MyListener”
Email support
setup sender – “email sender setup –hostServer smtp.server.com –port 587 –protocol SMTP –username foo –password foo”
creates a dependency injected field of type MailSender and also a sendMessage method in that target type – “field email template –class ~.domain.Person –async
JSON Support
number of methods are provided to facilitate serialization and deserialization in the domain layer and scaffolding – “json all”
adds methods String toJson(), fromJsonToPerson(String json), and collections handling.
Files -
- \WEB-INF\i18n\application.properties – labels, application_name, etc.
- message.properties – the rest of the values and labels
- WEB-INF\views\menu.jspx – menu
- webmvc-config.xml – noncontroller routing, other mvc stuff
Cloud Foundry
- pgp automatic trust
- addon install bundle –bundleSymbolicName org.springframework.roo.addon.cloud.foundry
Special Enhancements:
Adding file upload
Adding JQuery
Adding AD Security