rapid prototyping with jboss forgefiles.meetup.com/1956831/forge_jozijug.pdf · prototyping /...

27
> Rory Preddy Rapid prototyping with JBoss Forge

Upload: others

Post on 08-Jul-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

> Rory Preddy

Rapid prototyping

with JBoss Forge

Page 2: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

Agenda

• Background• Prototyping and Scaffolding• Forge

Forge 101 Installation Building a basic app

• Getting Fancy Angular Arquillian

• Spring-Roo

Page 3: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

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

Page 4: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

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

Page 5: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

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

Page 6: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

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

Page 7: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

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

Page 8: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

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

Page 9: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

• Prototyping 101• Forge

Forge 101 Installation Building a basic app

• Getting Fancy Angular Arquillian

• Spring-Roo

Page 10: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

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

Page 11: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

Architecture

Shell

Plugins Core

MetaDataJPADependenciesFile Undo

Services (CDI, Registry)

Furnace

Page 12: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

add-ons

Core

• JPA

• Scaffold

• Maven

• REST

• Angular

Community

• Arquillian

• Twitter

• Camel

• Confluence/JIRA

• Wildfly-Swarm

• OpenShift/Docker

• Portlets

Page 13: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

Installation

– Unzip Forge installation and run Forge.bat

or

– Red Hat Eclipse IDE (Preferred)

or

– Plugins

Eclipse

IntelliJ

Netbeans

Page 14: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

Forge 101

• Core Tasks

Adding JPA entities

Scaffolding a view layer

• Pure JSF

• Angular reverse-engineered from REST Layer

Deploy to an application server

Page 15: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

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

Page 16: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

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;

Page 17: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

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

Page 18: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

• Prototyping and Scaffolding• Forge

Forge 101 Installation Building a basic app

• Getting Fancy Angular Arquillian

• Spring-Roo

Page 19: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

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)

Page 20: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

Arquillian

• Container extensions JBoss, Tomcat, Weld, Glassfish, Jetty, WebSphere,

WebLogic

• Container types Embedded

Remote

Managed

Page 21: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

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

Page 22: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

@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

Page 23: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

• Prototyping and Scaffolding• Forge

Forge 101 Installation Building a basic app

• Getting Fancy Angular Arquillian

• Spring-Roo

Page 24: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

Roo

• Like-for-Like Forge

• Spring ecosystem based

• Unit and Selenium testing built in

• IDE integrated

• AspectJ heavy

• Remove via IDE

Page 25: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

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

Page 26: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

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

Page 27: Rapid prototyping with JBoss Forgefiles.meetup.com/1956831/Forge_JoziJUG.pdf · Prototyping / Scaffolding • 1960 Ada prototyping • 1970/1980 ”Mythical Man-Month” and “No

> Rory Preddy

Questions?

Build an Addon OpenShift Wildfly-storm