Pure Java RAD and Scaffolding Tools Race

45
Pure Java RAD and Scaffolding Tools Race @Drorb r @jbaru ch #javar ad That’s us! Twitter tag!

description

Rapid application development techniques, favoring rapid prototyping over intensive planning, have become popular in the last few years. Although the "old-school" Java Web frameworks (such as Struts and JSF) are well suited for enterprise projects, their development cycle is often too slow and complicated for prototyping. Due to their nature, dynamic languages such as Ruby, Python, and Groovy are natural for fast prototyping and scaffolding. But is there a way to benefit the Java ecosystem without compromising simplicity and productivity? This presentation tries to answer this question by comparing, head-to-head, three leading Java RAD tools—SeamForge, Play, and Roo—by writing a full-blown Web application in each of them, comparing the pros and cons along the way.

Transcript of Pure Java RAD and Scaffolding Tools Race

Page 1: Pure Java RAD and Scaffolding Tools Race

Pure Java RAD and Scaffolding Tools

Race@Drorbr@jbaruch

#javarad

That’s

us!

Twitter tag!

Page 2: Pure Java RAD and Scaffolding Tools Race

Your Speakers

Dror Bereznitsky @drorbrDevelopment Division

ManagerTangram-Soft

Baruch Sadogursky

@jbaruchInnovation

ExpertBMC Software

Page 3: Pure Java RAD and Scaffolding Tools Race

AgendaBla-bla-bla (AKA Overview)

Yadda-yadda-yadda (Aka Summary)

1 Framework[] frameworks = new Framework[]{ 2 seamForge, springRoo, playFramework}; 3 for (Framework fw : frameworks) { 4 fw.showOverview(); 5 fw.hightlightFeatures(); 6 fw.runDemo(); 7 fw.showProsAndCons(); 8 }

Page 4: Pure Java RAD and Scaffolding Tools Race

RAD

WHAT?Speaking of R

AD,

Page 5: Pure Java RAD and Scaffolding Tools Race

4gl were rad!

FYI, Java

is 3gl

Rapid Application Development

Oracle Forms

MagicBMC Action

Request

Page 6: Pure Java RAD and Scaffolding Tools Race

Opposite to old-school

slow j2ee

Rapid Application Development

Page 7: Pure Java RAD and Scaffolding Tools Race

Why Slow?Any Java Enterprise

application:

– Setup project

– Get the

dependencies

straight

– Setup database

& server

– Write model

classes

Inte

gra

tion

==

pain

!Spring application:

–Map model to

storage (JPA/Hibernate/NoSQL

)–

Write POJO DAOs and

Services–

Write Spring Web

UI (E.G. JSP)

–Write some xmls

(web.xml, beans.xml)

or configure with

Java classes

–Deploy to Servlet

Container

Java EE application– Map model to relational (JPA)– Write Session EJBs for DAOs

and Services– Write JSF UI (E.g.JSP)– Write bunch of xmls

(persistence, web, jsf, server specific)

– Deploy to JEE server

Java W

eb

Frw

ks s

uck

!

Page 8: Pure Java RAD and Scaffolding Tools Race

Scaffolding

They create:– Jar dependencies– Configuration files (e.g. web.xml)– Controller classes

– Views (e.g. jsp)– Static Resources (imgs, css, js)

– I18n (properties files)

~.domain.Tal

k roo> contr

oller all --

package

~.web

You Type:

Ease w

eb

development

Page 9: Pure Java RAD and Scaffolding Tools Race

Modules

Ease In

tegra

tion

They create:– Jar dependencies– Persistence.xml– Database properties– configurations

roo> jpa set

up --provide

r HIBERNATE

--database

HYPERSONIC_I

N_MEMORY

You Type:

Page 10: Pure Java RAD and Scaffolding Tools Race

1 @Async 2 public static void Talk.indexTalks(Collection<Talk> talks) { 3 List<SolrInputDocument> documents = new ArrayList<SolrInputDocument>(); 4 for (Talk talk : talks) { 5 SolrInputDocument sid = new SolrInputDocument(); 6 sid.addField("id", "talk_" + talk.getId()); 7 sid.addField("talk.id_l", talk.getId()); 8 sid.addField("talk.code_l", talk.getCode()); 9 sid.addField("talk.title_s", talk.getTitle()); 10 sid.addField("talk.track_t", talk.getTrack()); 11 sid.addField("talk.category_t", talk.getCategory()); 12 sid.addField("talk.speaker_t", talk.getSpeaker()); 13 // Add summary field to allow searching documents 14 sid.addField("talk_solrsummary_t", new StringBuilder(). 15 append(talk.getId()).append(" ").append(talk.getCode()). 16 append(" ").append(talk.getTitle()).append(" "). 17 append(talk.getTrack()).append(" "). 18 append(talk.getCategory()).append(" "). 19 append(talk.getSpeaker())); 20 documents.add(sid); 21 } 22 try { 23 SolrServer solrServer = solrServer(); 24 solrServer.add(documents); 25 solrServer.commit(); 26 } catch (Exception e) { 27 e.printStackTrace(); 28 } 29 }

Modules

Ease

Integra

tion

They create:– configurations

roo> solr

setup

You Type: They create:

~.domain.Talk roo> solr

add

You Type:

Page 11: Pure Java RAD and Scaffolding Tools Race

Writing your own module

Module

s

Generate codeGenerate configuration filesGenerate testing code

Change project structure

Add dependencies

Change existing

code

Inject content

Page 12: Pure Java RAD and Scaffolding Tools Race

Convention…

Page 13: Pure Java RAD and Scaffolding Tools Race

Over…

Page 14: Pure Java RAD and Scaffolding Tools Race

Configuration

Page 15: Pure Java RAD and Scaffolding Tools Race

Showtime!

Page 16: Pure Java RAD and Scaffolding Tools Race

JBOSS SEAM FORGEOn the Left lane:

Page 17: Pure Java RAD and Scaffolding Tools Race

Obvious and trivial jboss SEAM FORGE

FactsDeveloped by JBOSS (surprise!)Heavily based on JBOSS SEAM (surprise!)Heavily based on MavenUses standard java ee 6 featuresEvolved from seam-gen project in August 2010latest version 1.0.0-beta1

Page 18: Pure Java RAD and Scaffolding Tools Race

Interesting stuff

Page 19: Pure Java RAD and Scaffolding Tools Race

Interesting stuff

Page 20: Pure Java RAD and Scaffolding Tools Race

Plugins (aka Modules)Persistence

JPA major 4 providers

Seam Persistence

only Hibernate

currently supported

JCR

DB Reverse

Engineering

WEBMetawidget

JSF & RIchfaces

JavaSCriptInfrastructureJavabean validationJboss asGlassfish ASApache Maven

Page 21: Pure Java RAD and Scaffolding Tools Race

Developing Pluginuse “forge.api”

facet to access forge API

Use forge’s project

object to access

dependencies,

packaging, etc.

Modular application ==

Classpath hell

Use standard java ee cdi TO access container services

Page 22: Pure Java RAD and Scaffolding Tools Race

Demo!

Page 23: Pure Java RAD and Scaffolding Tools Race

Pros

Scaffolding

Java ee 6 integration

Seam framework

integration

Clean, simple, standard

code generation

COns

Early daysNo separation between

generated and user data

Lack of documentation

No nosql support

Pros and Cons

Page 24: Pure Java RAD and Scaffolding Tools Race

SPRING ROOOn the Middle lane:

Page 25: Pure Java RAD and Scaffolding Tools Race

Obvious and trivial Spring ROO Facts

Developed by springsource (surprise!) Heavily based on the Spring framework (surprise!) revealed @ SpringOne Europe on 27 April 2009 latest version 1.1.5

Page 26: Pure Java RAD and Scaffolding Tools Race

1 @RooJavaBean 2 @RooToString 3 @RooEntity 4 public class Speaker { 5 6 @NotNull 7 private String firstName; 8 9 @NotNull 10 private String lastName; 11 12 private String email; 13 14 @ManyToMany(cascade = CascadeType.ALL) 15 private Set<Talk> talks = new HashSet(); 16 }

Inter-type declarationsYour Class:

1 privileged aspect Speaker_Roo_JavaBean { 2 3 public String Speaker.getFirstName() { 4 return this.firstName; 5 } 6 7 public void Speaker.setFirstName(String firstName) { 8 this.firstName = firstName; 9 } 10 … 11 }

ITD:

Page 27: Pure Java RAD and Scaffolding Tools Race

1 privileged aspect Speaker_Roo_Entity { 2 3 declare @type: Speaker: @Entity; 4 5 @PersistenceContext 6 transient EntityManager Speaker.entityManager; 7 8 @Id 9 @GeneratedValue(strategy = GenerationType.AUTO) 10 @Column(name = "id") 11 private Long Speaker.id; 12 13 @Version 14 @Column(name = "version") 15 private Integer Speaker.version; 16 17 @Transactional 18 public void Speaker.persist() { 19 this.entityManager.persist(this); 20 } 21 22 public static long Speaker.countSpeakers() { 23 return entityManager().createQuery( 24 "SELECT COUNT(o) FROM Speaker o", 25 Long.class).getSingleResult(); 26 } 27 … 28 }

1 @RooJavaBean 2 @RooToString 3 @RooEntity 4 public class Speaker { 5 6 @NotNull 7 private String firstName; 8 9 @NotNull 10 private String lastName; 11 12 private String email; 13 14 @ManyToMany(cascade = CascadeType.ALL) 15 private Set<Talk> talks = new HashSet(); 16 }

Inter-type declarationsYour Class:

ITD:

Look, ma,

active record!

BMP Entity EJB

1.0 FTW!

Page 28: Pure Java RAD and Scaffolding Tools Race

add-ons (AKA Modules)

Persistence

JPA major 4 providers

Incremental DB Reverse

Engineering

WEBSpring MVC

over JSPXGWTREST & JSON

JavaSCriptInfrastructure

Javabean validationCloud Foundry and GAEEmbedded Jetty

Apache MAVEN

SOLRJUNIT and seleniumOSGi

Page 29: Pure Java RAD and Scaffolding Tools Race

Modular application ==

Classpath hell

Developing add-onuse “Add-on creator” add-on to

generate the add-on

Use Roo’s Services to:

Change The

POM.xml

Create/edit

Properties files

Add new types

Add new Itds

Annotate existing

types

Add static content

Add-on is Spring bean. nuff said.

Page 30: Pure Java RAD and Scaffolding Tools Race

Demo!

Page 31: Pure Java RAD and Scaffolding Tools Race

Pros

Separation of concerns

Spring framework

integration

Full text search

Good usage of OSGi

ConsAspectj magic

No nosql supportNo DAO option

Pros and Cons

Page 32: Pure Java RAD and Scaffolding Tools Race

PLAY! FRAMEWORKOn the Right lane:

Page 33: Pure Java RAD and Scaffolding Tools Race

Obvious and trivial Play! Facts

Developed by guillaume bort, supported by zenexityFirst signs of life from 12 may 2007latest version 1.2.3

Page 34: Pure Java RAD and Scaffolding Tools Race

Not your grandpa’s RAD Tool

So, what gives?

No Ui Is the sameSo why bother?

Page 35: Pure Java RAD and Scaffolding Tools Race

The other “rapid”

On-the-fly compile

No recompile

No redeploy

No server restart

Page 36: Pure Java RAD and Scaffolding Tools Race

More unusual stuff Not using servlet APIBuild and deployment handled by Python scripts Static controllers“Share nothing” architectureJSP-LIKE templating engine (based on Groovy)Admin area otf generation Graphical Test runner

Page 37: Pure Java RAD and Scaffolding Tools Race

Modules

Persistence

JPA over Hibernate

Morphia over

MongoDB

Siena (Relational DBs

and GAE)

WEBJSP-like templates

REST-easy (REST & JSON)

GWTScaffolding*InfrastructureScalaEclipse CompilerGAEJBoss Netty

ElasticSearch and LuceneJUNIT and seleniumOAuth

*Yap, we lied

Page 38: Pure Java RAD and Scaffolding Tools Race

Developing module

Module is (part of) play!

Application.

Nuff said.

Page 39: Pure Java RAD and Scaffolding Tools Race

Developing module

OK, Here’s

more:

Modular application ==

Classpath hell

Create module with “play new-

module” command

Modules are loaded from

“Modules” directory

Repo: www.playframework.org/modules

Page 40: Pure Java RAD and Scaffolding Tools Race

Demo!

Page 41: Pure Java RAD and Scaffolding Tools Race

Pros

Productivity boost with

OTF compile

Full text search, NOSQL,

SCALA

NIO Server (Netty)

Stateless model - share

nothing

Full Stack Solution

ConsProprietaryScaffolding not

in coreClasspath hell

Pros and Cons

Page 42: Pure Java RAD and Scaffolding Tools Race

HEAD

TO

HEAD!

Let’s ru

mble!

Page 43: Pure Java RAD and Scaffolding Tools Race

Feature Seam Forge

Spring Roo

Play!

Scaffolding One-Time Continuous One-time(as module)

OTF compile

No No Yes

Persistence JPA JPA JPAMorphia

User interface

JSF Spring-MVCGWT

HOME-Grown(JSP-like)

Full Text Search

No Solr ElasticSearchLucene

REST support

No Spring-rest Rest-easy

Deployment JBOss ASGlassfish AS

Servlet containerGAECloud Foundry

Embedded nettyGaeServlet container

Page 44: Pure Java RAD and Scaffolding Tools Race

Feature Seam Forge

Spring Roo

Play!

Backed up JBOss Springsource

zenexity

Maturity Low High high

Documentation

Low Medium Medium

Books NO “Roo in action”Early access

“Introducing the Play Framework”

License LGPL Apache 2 Apache 2

Mailing List 6 messages in last month

132 messages in last month

~550 messages in last month*

*Inc. announcements on usage, etc.

Page 45: Pure Java RAD and Scaffolding Tools Race

Thank you!Q&A

TIME