> Rory Preddy
Rapid prototyping
with JBoss Forge
Agenda
• Background• Prototyping and Scaffolding• Forge
Forge 101 Installation Building a basic app
• Getting Fancy Angular Arquillian
• Spring-Roo
Background
• I had to find a way to train 200 newbies
EJB/JPA/JSF
Angular/REST
• I first used forge in July 2014
• It harnessed my inner lazyness
Prototyping / Scaffolding• 1960
Ada prototyping
• 1970/1980 ”Mythical Man-Month” and “No Silver Bullet” books
• 1990 RAD
• 2007 Ruby-on-Rails 2
Seam-Gen
• 2009 Spring Roo
• 2012 Yeoman (Node.Js)
• 2014 Forge 2.0
Prototyping
• Prototypes are of two types
• Throwaway prototypes
eventually discarded - Think recycling!
screen mock-ups and story boards.
• Evolutionary Prototypes
Tactical becomes strategic
Users can talk and talk and talk
Advantages
• Users Understand us
• They work with us
• They don’t scream at us
• We don’t pretend to understand them
• We dumb it down for them
Disadvantages
• Code-and-Repair – Patch work fixes
• Scope creep
• Do we have to maintain it also? We don’t like that!
• Loyalty to the throw-away
• “Over-zealous-just-been-on-training” Anti-pattern
Scaffolding
• Ruby on Rails
Hipsters - “Inventors or first adopters of novelties”
Popularized
• inbuilt ORM
• scaffolding
• simple CLI commands
• Shipped with Mac OS X v10.5
> ruby script/generate scaffold Movie title:string
• Prototyping 101• Forge
Forge 101 Installation Building a basic app
• Getting Fancy Angular Arquillian
• Spring-Roo
What is Forge
• Java EE scaffolding tool
• Shell commands
• CRUD scaffolding
• Quick Start
• Takes care of integration
• Plugin based Create Custom Plugins
no need to know the IDE API
Architecture
Shell
Plugins Core
MetaDataJPADependenciesFile Undo
Services (CDI, Registry)
Furnace
add-ons
Core
• JPA
• Scaffold
• Maven
• REST
• Angular
Community
• Arquillian
• Camel
• Confluence/JIRA
• Wildfly-Swarm
• OpenShift/Docker
• Portlets
Installation
– Unzip Forge installation and run Forge.bat
or
– Red Hat Eclipse IDE (Preferred)
or
– Plugins
Eclipse
IntelliJ
Netbeans
Forge 101
• Core Tasks
Adding JPA entities
Scaffolding a view layer
• Pure JSF
• Angular reverse-engineered from REST Layer
Deploy to an application server
CLI Demo: a Basic App
• project-new --named conference --topLevelPackageorg.example;
• jpa-new-entity --named Speaker;• jpa-new-field --named firstname;• scaffold-setup --provider Faces;• scaffold-generate --provider Faces --targets
org.example.model.*;• build;
Right click “run as server”
http://localhost:8080/conference
Elaborating on Entities
• Add a new Entity “Talk”, “Book”• Add some bean-validation constraints• Add REST services
Map “Talk” to “Speaker”• jpa-new-field --named speakers --type
org.example.domain.Speaker --relationshipTypeOne-to-Many;
IDE Demo: a Basic App
• Eclipse - CTRL+4• Netbeans – CTRL+I• IntelliJ – CTRL+ALT+4
1. Create a project2. Setup JPA3. Add a entity
Add a field4. Setup Scaffold5. Generate Scaffold
6. Deploy to JBoss Server
• Prototyping and Scaffolding• Forge
Forge 101 Installation Building a basic app
• Getting Fancy Angular Arquillian
• Spring-Roo
Angular
• Add REST layer• rest-setup;• rest-generate-endpoints-from-entities --targets
org.example.model.*;
Generate Angular Scaffold• scaffold-setup --provider AngularJS ;• scaffold-generate --targets org.example.model.*;
(Make a tiny change to display Entity Relationships)
Arquillian
• Container extensions JBoss, Tomcat, Weld, Glassfish, Jetty, WebSphere,
WebLogic
• Container types Embedded
Remote
Managed
Arquillian with Forge
• Install add-onaddon-install-from-git --url https://github.com/forge/addon-arquillian.git --coordinate org.arquillian.forge:arquillian-addon• Setup Arquillianarquillian-setup --testFramework junit
• Add Test casearquillian-create-test --targets demo.CoolBean--archiveType JAR• Add meat to Test case
@RunWith(Arquillian.class)public class StatusServiceTest {
@Injectprivate StatusService statusService;
@Deploymentpublic static Archive<?> deployment() {
return ShrinkWrap.create(WebArchive.class).addPackage(StatusService.class.getPackage()).addAsResource("META-INF/persistence.xml","META-INF/persistence.xml").addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
@Testpublic void testPostStatus() throws Exception {
Status status = statusService.postStatus("Hello, world");Assert.assertNotNull(status);Assert.assertEquals(1L, status.getId().longValue());
}
Demo – Arquillian Example
• Prototyping and Scaffolding• Forge
Forge 101 Installation Building a basic app
• Getting Fancy Angular Arquillian
• Spring-Roo
Roo
• Like-for-Like Forge
• Spring ecosystem based
• Unit and Selenium testing built in
• IDE integrated
• AspectJ heavy
• Remove via IDE
Demo - Roo Commands
• Open STS IDE or roo CLI
• Create a new roo project
• roo> script --file C:\spring-roo-2.0.0.M1\samples\clinic.roo
(Change Maven selenium config to your browser of choice)
1. mvn package tomcat:run
2. mvn selenium:selenese
Feature Forge Roo
Persistence JPA JPA/Spring-data
User interface JSF/Angular/RichFaces JSF/Spring-MVC/GWT
Cloud OpenShift (3rd party) GAE/Cloud Foundry
Removal N/A One-way via IDE
Containers Servlet/JEE Boot/Servlet/JEE
Documentation None/Low Plenty
Books None “Roo in action”
“Getting Started with Roo”
Forge vs Roo
> Rory Preddy
Questions?
Build an Addon OpenShift Wildfly-storm
Top Related