Rapid Application Development

and Application Generation Tools

5/2014 Walter Knesel ... A place where many, many ideas have been tried and discarded.

A current problem is it's success: so many libraries, so many technologies, so many choices

Or, You want to be a Java Full Stack Developer?

WEB Project DNA

● IDE (, NetBeans, Jbuilder, IntelliJ, ...)

● Build Tool (Maven, Ant, …)

● Unit testing (Arquillian, EasyMock, JUnit, ...)

● App server (Tomcat, JBoss, WebLogic, WebSphere, Netty, ...)

● UI framework (JSF, GWT, Spring MVC, Struts, Tapestry, …)

● CSS files, JavaScript files, Images, HTML files, SQL

● View JavaBeans, Business JavaBeans, WebService endpoints

● ORM, DAO (JPA, , JDBC), WebService clients

(SQL Server, Oracle, MySQL, ...)

Java SE

Java takes too long:

● develop / compile / deploy / test cycle is long

● IDE / project integration mysteries

● download / config jars into IDE / app server

● XML configurations are tedious (older spring / hibernate) ● Technologies change every darn time

● !! Getting a new project started is hard !!

So what did we do about it?

Rapid Application Development !

As usual, there are many choices:

AppFuse 3.x

● open-source Java EE web app framework

● designed for quick, easy development start up

● Provides project skeleton and additional code features

● Maven 2 build automation

● Hibernate, iBATIS or JPA as persistence frameworks

● compatible with JSF, Spring MVC, Struts 2 or Tapestry frameworks

● Uses Netty web server

● http://appfuse.org

Some of the Code Features:

● User Management – login, signup, remember

● E-Mail

● Templated Layout

● File Upload

AppFuse 3.x

Grails

● Re-use technologies like Hibernate and Spring under a single interface

● Templates using GSP (Groovy Server Pages)

● Dynamic tag libraries for creating web page components

● Customizable support

● sample applications that demonstrate the framework

● includes a web server and automatic reload of resources

● http://grails.org/

Features

● No XML configuration

● All required libraries present

● Automatically prepares the Java web environment for deployment

● provides dynamic methods () based on class type

● allows developers to perform operations without implements or extends

● Has an app generator, owned by Spring Source, works like

Grails

JSPX(-bay)

● asp.net like imitator, yet different ● Does not mix java into jspx pages ● Plain use – page tags ● convention over configuration ● stateful ui interface ● Data persistence exists, JPA not mentioned ● http://jspx.sourceforge.net/

JSPX(-bay)

OpenXava

● You write the code for data structure and business logic

● You do not have to write HTML, JavaScript, CSS, SQL, etc.

● Java EE and the database logic are automatically provided

● Extend any part of the app later, if needed

● List mode (search) has paging, ordering, filtering, adding / removing / moving columns, PDF reports, export to Excel, etc.

● Detail mode (view) with tabs, frames, dialogs, editors for references and collections, etc.

OpenXava

Play 2.x

● Definite Scala web platform possibility

● Scala and Java, non Java EE

● heavily inspired by and similar to and , uses module concept

● Uses convention over configuration

● designed to be run using JBoss Netty web server

● Can package to war and run on EE app servers.

● Stateless: Play 2 is fully RESTful - there is no Java EE session per connection

● a persistence layer based on JPA

● Built in hot-reloading

● an embedded database

● full embedded testing framework

● http://www.playframework.com/

Play 2.x

WaveMaker 6.x

● Automatic generation of Hibernate mapping, queries from database schema import ● Automatic creation of Enterprise Data Widgets based on schema import ● Edit form implements create, update, delete functions automatically ● Visual, drag & drop assembly of web applications ● Developer sees live application data within the studio (LiveLayout) ● one-touch deployment to Tomcat, Websphere, Weblogic, Jboss ● Browser-based WaveMaker studio can be bundled ● Deploys a standard Java .war file ● effectively an open source alternative to Force.com ● http://www.wavemaker.com

WaveMaker 6.x

Others not covered

● Jrapid, not free, based, DRY http://www.jrapid.org/

, not specifically RAD http://www.stripesframework.org

, not specifically RAD https://vaadin.com

● Wicket, not RAD, plain html, components http://wicket.apache.org/

Common Features

● Project skeletons and some feature code

● Convention over configuration and Annotations

● Maven – get / configure / deploy jars

● Maven – standard project config, operations

● light-weight frameworks, scripting langs

● DRY (don't repeat yourself) pattern

● code generation or support of some layers

Another Approach Please?

● I don't really want to give up my environment for another ● The technology changed again and I don't want to jump to yet another environment to catch up ● I' like to just push a button.....

Application Generation Tools

● Not as easy as pushing a button

● Does not generate a production application

● DOES generate a deployable running application

● A good start, delete what you don't want

● Grails

● Maven archetypes

● Spring Roo

● Seam / JBoss Forge

Maven Archetypes

● Many choices, will likely find one for your desired environment and version.

● Built a demo with jboss-javaee6-webapp-archetype 7.1.3 Final

● Command line: mvn archetype:generate

● Eclipse new → maven project

● Produces a maven project skeleton

● http://maven.apache.org

Jboss EE6 Blank Project

Jboss EE6 non blank Project

Maven Archetypes

Pros

● Part of Maven, instant Maven project

● Light, quick, easy to run

● No other external to install

● Freedom to build app your way

● Many, many archetypes to work with

Cons

● Produces a skeleton only

● Blank is truly minimal (pom, libraries, persistence.)

Spring Roo

● Is a separate (commandline) generator ● Has to be installed (unzipped)

● Install oracle driver into internal

● Reversing a database worked first try!

● Had to build database tables first

● http://projects.spring.io/spring-roo/

Roo shell

Roo commands

● project --topLevelPackage org.cchmc.bmi.psysoc.pvp

● jpa setup --provider HIBERNATE --database ORACLE

● dependency remove --groupId com.oracle --artifactId ojdbc14 --version 10.2.0.2

● dependency add --groupId com.oracle --artifactId ojdbc6 --version 11.2.0

● database properties set --key database.driverClassName --value oracle.jdbc.OracleDriver

● database properties set --key database.url --value jdbc:oracle:thin:@localhost:1521:XE

● database properties set --key database.username --value myid

● database properties set --key database.password --value mypass ### all tables at once

● database reverse engineer --schema PSYSOCPVP --package ~.models

● web jsf setup --implementation ORACLE_MOJARRA --library PRIMEFACES --theme BLUESKY ### build them all

● web jsf all --package ~.beans

Roo

Generated: ● a PrimeFaces JSF UI ● Non EE AspectJ Spring beans and models ● heavy use annotation and injection ● Models use JPA ● Some internationalization provided ● Simple CRUD app, runs in Tomcat

Roo Project

Roo App

Roo

Pros

● Little investment

● More capabilities than shown

● Database schema reversal works

● Spring, JPA, JSF, PrimeFaces

Cons

● Non EE

● AspectJ bean generation

● Roo Specific Annotations

● Does not “drop in” to Jboss servers

Seam 2

● Marry JSF 1.2 w/ JPA and make it work

● My first app generation encounter

● Installed Seam external to IDE

● Defined schema in reveng.xml

● Built an EE 5 CRUD app

● MPM admin tool started this way

● http://www.seamframework.org/Seam2/Home

Seam 3

● Java EE 6 and CDI ● Seam 2 had to become Seam 3

● Seam 3 introduced JBoss forge

● Seam 3 has stopped (see Apache DeltaSpike, others)

● http://www.seamframework.org/Seam3

Jboss Forge 1.4x

● Is a separate (commandline) generator ● Has to be installed (unzipped, Eclipse)

● Reversing a database - miserable failure

● Did it their way, inside out

● http://forge.jboss.org/

Forge Shell

Forge Commands

● New-project;

setup --scaffoldType faces;

● beans setup;

● entity --named Customer --package ~.domain;

● field string --named firstName;

● field string --named lastName;

● field temporal --type DATE --named birthDate;

● …

● @/* Generate the UI for all */;

● scaffold from-entity ~.domain.* --scaffoldType faces –overwrite;

● @/* create rest WebService CRUD endpoints */;

● rest setup;

● rest endpoint-from-entity ~.domain.*;

● build;

Forge

Generated:

● JSF UI ● Domain beans, EE criteria query view beans

● heavy use annotation and injection

● views use JPA ● Simple CRUD app, runs in Jboss 7

Forge Project

Forge App

Forge

Pros

● More function, for free

● J2EE 6 Annotated, JBoss compatible, what we use

● JSF, JPA, criteria queries already built if desired

● Large table paging is built in.

Cons

● Multiple injected entity managers

● Extended conversations

● More pages, clicks to navigate

● Want DB reverse engineering to work

● View beans are too dense

Conclusions

● Generally good starts or short cuts ● Use what works, delete what doesn't

● May show new ideas, techniques, APIs

● Build multiple projects, cannibalize them

● Don't be afraid to modify / extend