tapestry: state of the union

86
© 2009 Formos www.formos.com Apache Tapestry 5: State of the Union Howard M. Lewis Ship Director of Open Source Technology Formos © 2006 Chris Walton http://www.flickr.com/photos/philocrites/245011706/

Upload: howard-lewis-ship

Post on 28-Jan-2015

107 views

Category:

Economy & Finance


0 download

DESCRIPTION

The slide deck from my session at JavaOne 2009.

TRANSCRIPT

Page 1: Tapestry: State of the Union

© 2009 Formos www.formos.com

Apache Tapestry 5: State of the UnionHoward M. Lewis Ship

Director of Open Source TechnologyFormos

© 2006 Chris Waltonhttp://www.flickr.com/photos/philocrites/245011706/

Page 2: Tapestry: State of the Union

© 2009 Formos www.formos.com

Howard Lewis Ship

• Creator, Apache Tapestry

• Author, "Tapestry in Action"

• Independent Consultant 2003-2007

• Formos 2008-

Page 3: Tapestry: State of the Union

© 2009 Formos www.formos.com

What is Tapestry?

Page 4: Tapestry: State of the Union

© 2009 Formos www.formos.com

Java

Page 5: Tapestry: State of the Union

© 2009 Formos www.formos.com

Open Source

Page 6: Tapestry: State of the Union

© 2009 Formos www.formos.com

Component Based

Page 7: Tapestry: State of the Union

© 2009 Formos www.formos.com

Developer Focused

Page 8: Tapestry: State of the Union

© 2009 Formos www.formos.com

Concise

Page 9: Tapestry: State of the Union

© 2009 Formos www.formos.com

Fast!

Page 10: Tapestry: State of the Union

© 2009 Formos www.formos.com

Mature

Page 11: Tapestry: State of the Union

© 2009 Formos www.formos.com

Tapestry Elements

© 2009 Nataline Funghttp://www.flickr.com/photos/metaphora/3384569933/

Page 12: Tapestry: State of the Union

© 2009 Formos www.formos.com

Tapestry Templates

<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <h1>Please Login</h1>

<t:form> <t:label for="userId"/> <t:textfield value="userId"/> <br/> <t:label for="password"/> <t:passwordfield value="password"/> <br/> <input type="submit" value="Login"/> </t:form></html>

Login.tml

Login

form

label

textfield

label

passwordfield

Page 13: Tapestry: State of the Union

© 2009 Formos www.formos.com

Page Classes

<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <body> <h1>Please Login</h1>

<t:form> <t:label for="userId"/> <t:textfield value="userId"/> <br/> <t:label for="password"/> <t:passwordfield value="password"/> <br/> <input type="submit" value="Login"/> </t:form></html>

Login.tml

public class Login{ @Property private String userId;

@Property private String password;

Object onSuccess() { … }}

Login.java

Page 14: Tapestry: State of the Union

© 2009 Formos www.formos.com

Page Flows

public class Login{ @Property private String userId;

@Property private String password;

void onValidate() { … }

Object onSuccess() { …

return UserProfile.class; }}

Login.java

public class UserProfile{ … }

UserProfile.java

Page 15: Tapestry: State of the Union

© 2009 Formos www.formos.com

Inversion of Control

public class Login{ @Property private String userId;

@Property private String password;

@Inject private Session session;

@CommitAfter Object onSuccess() { …

User user = (User) session. …

user.setLastLogin(new Date());

return UserProfile.class; }}

Login.java

Inject IoC Service into field

Yourcode

Tapestry Services

Page 16: Tapestry: State of the Union

© 2009 Formos www.formos.com

Meta-Programming

public class Login{ @Property private String userId;

@Property private String password;

@InjectPage private UserProfile userProfilePage; …

@Inject private Session session;

@CommitAfter Object onSuccess() { …

User user = (User) session. …

user.setLastLogin(new Date());

return userProfilePage; }}

Login.java

Generate getter & setter

Commit Hibernate transaction

Page 17: Tapestry: State of the Union

© 2009 Formos www.formos.com

State Management

public class UserProfile{ @Property @SessionState private UserEntity user;

@Property @Persist private Date searchStart;

}

UserProfile.java

Shared global value (any page)

This page only

Page 18: Tapestry: State of the Union

© 2009 Formos www.formos.com

Component

Template

Java Class

Message Catalog

Meta-Programming

Injections

Page 19: Tapestry: State of the Union

© 2009 Formos www.formos.com

❝Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves.❞

Alan Kay, co-designer of the Smalltalk programming language

Page 20: Tapestry: State of the Union

© 2009 Formos www.formos.com

Developer Productivity© 2006 Martino Sabiahttp://www.flickr.com/photos/ezu/297634534/

Page 21: Tapestry: State of the Union

© 2009 Formos www.formos.com

Page 22: Tapestry: State of the Union

© 2009 Formos www.formos.com

Non-Tapestry Exception Reporting

Page 23: Tapestry: State of the Union

© 2009 Formos www.formos.com

Index does not contain a property named 'now'

Available properties: class, componentResources, currentTime

Page 24: Tapestry: State of the Union

© 2009 Formos www.formos.com

Page 25: Tapestry: State of the Union

© 2009 Formos www.formos.com

Page 26: Tapestry: State of the Union

© 2009 Formos www.formos.com

Scaffolding

Page 27: Tapestry: State of the Union

@Entitypublic class BoardGame{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @NonVisual private long id;

@Validate("required") private String title;

private String creator;

private String publisher;

private Date published;

private boolean inPrint;

@Validate("required") @Column(nullable = false) private Genre genre;

@Validate("required") @Column(nullable = false) private Theme theme;

@Validate("min=1") private Integer minPlayers;

@Validate("min=1") private Integer maxPlayers;

@Validate("min=1,max=5") private Integer rating;

@DataType("longtext") private String notes;

© 2009 Formos www.formos.com

BoardGame.java

Page 28: Tapestry: State of the Union

© 2009 Formos www.formos.com

Page 29: Tapestry: State of the Union

© 2009 Formos www.formos.com

Property Types

Naming Conventions

Annotations

Explicit Overrides

Localized Messages

Bea

nEd

itFo

rm

Parameters

Page 30: Tapestry: State of the Union

© 2009 Formos www.formos.com

Feedback &Exploration

© 2008 Alan Grinberghttp://www.flickr.com/photos/agrinberg/2465119180/

Page 31: Tapestry: State of the Union

© 2009 Formos www.formos.com

Flow

© 2008 Manu Gómezhttp://www.flickr.com/photos/manugomi/2884678938/

Page 32: Tapestry: State of the Union

© 2009 Formos www.formos.com

❝PHP and Rails have taught us that development speed is more important than we thought it was ... you really don’t understand a feature till you’ve built it, so the faster you can build them the faster you understand them.❞

Tim Bray, Director of Web Technologies, Sun Microsystems

Page 33: Tapestry: State of the Union

© 2009 Formos www.formos.com

Internationalization

© 2006 Tom Maglieryhttp://www.flickr.com/photos/mag3737/267638148/

Page 34: Tapestry: State of the Union

© 2009 Formos www.formos.com

Page 35: Tapestry: State of the Union

© 2009 Formos www.formos.com

page-title=Erstellen Sie eine neue Brettspieladd-game=Spiel hinzufŸgen

modern=Modernenmedieval=Mittelalterbible=Bibelabstract=Zusammenfassung

war_game=Kriegsspielcard=Karterole_playing=Rollenspielecooperative=Genossenschaft

creator-label=Schšpferpublisher-label=Verlagpublished-label=Veršffentlichtinprint-label=Im Drucktheme-label=Themaminplayers-label=Mindest-Spielermaxplayers-label=Maximale Spielernotes-label=Notation

Index_de.properties

<html t:type="layout" title="message:page-title" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">

<t:beaneditform submitlabel="message:add-game" object="game"/> </html>

Index.tml

Page 36: Tapestry: State of the Union

© 2009 Formos www.formos.com

Tapestry Components

Copyright © A. Lipson 2003http://www.andrewlipson.com/escher/relativity.html

Page 37: Tapestry: State of the Union

© 2009 Formos www.formos.com

Intrinsic

Page 38: Tapestry: State of the Union

© 2009 Formos www.formos.com

Inheritance

Page 39: Tapestry: State of the Union

© 2009 Formos www.formos.com

Composition

Page 40: Tapestry: State of the Union

© 2009 Formos www.formos.com

POJO

Page 41: Tapestry: State of the Union

© 2009 Formos www.formos.com

Events

Page 42: Tapestry: State of the Union

© 2009 Formos www.formos.com

Consistency!

http://flickr.com/photos/kylemay/1430449350/

Page 43: Tapestry: State of the Union

© 2009 Formos www.formos.com

Nested Components

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter"> <head> <title>${title}</title> </head> <body> … <div id="menu"> <ul> <li t:type="loop" source="pageNames" value="pageName" class="prop:classForPageName"> <t:pagelink page="prop:pageName">${pageName}</t:pagelink> </li> </ul> </div>

Layout.tml

Layout

title : StringpageNames : List

pageName : String

Index

Layout

Loop PageLink

Page 44: Tapestry: State of the Union

© 2009 Formos www.formos.com

Layout Components

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter"> <head> <title>${title}</title> </head> <body>

. . .

<t:body/>

. . .

</body></html>

Layout.tml

<html t:type="layout" title="message:page-title" xmlns:t="http://tapestry.apache.org/schema/ ↵ tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">

<t:beaneditform submitlabel="message:add-game" object="game" />

</html>

Index.tml

Page 45: Tapestry: State of the Union

© 2009 Formos www.formos.com

Component Parameters

public class Layout{ /** The page title, for the <title> element and the <h1> element. */ @Property @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL) private String title;

@Property @Parameter(defaultPrefix = BindingConstants.LITERAL) private String sidebarTitle;

@Property @Parameter(defaultPrefix = BindingConstants.LITERAL) private Block sidebar;

@Property private String pageName;

Layout.java

Page 46: Tapestry: State of the Union

© 2009 Formos www.formos.com

Non-Template Components

public class OutputDate{ private final DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);

@Parameter(required = true, allowNull = false) private Date date;

void beginRender(MarkupWriter writer) { writer.write(formatter.format(date)); }}

OutputDate.java

Page 47: Tapestry: State of the Union

© 2009 Formos www.formos.com

Component Rendering

Start

SetupRender

BeginRender

Render Template

Render Body

AfterRender

CleanupRender

End

true

falsetrue

true

false

false

false

true

void beginRender(MarkupWriter writer) { writer.write(formatter.format(date)); }

RichOutput.java

Page 48: Tapestry: State of the Union

© 2009 Formos www.formos.com

Page 49: Tapestry: State of the Union

© 2009 Formos www.formos.com

TapestryPerformance

© 2009 viernesthttp://www.flickr.com/photos/viernest/3380560365/

Page 50: Tapestry: State of the Union

© 2009 Formos www.formos.com

Request Processing Speed

© 2007 Jojo Cencehttp://www.flickr.com/photos/jojocence/1372693375/

Page 51: Tapestry: State of the Union

© 2009 Formos www.formos.com

Java == Fast

Page 52: Tapestry: State of the Union

© 2009 Formos www.formos.com

No Reflection

Page 53: Tapestry: State of the Union

© 2009 Formos www.formos.com

Page Pooling

Page 54: Tapestry: State of the Union

© 2009 Formos www.formos.com

GZIP Compression

Page 55: Tapestry: State of the Union

© 2009 Formos www.formos.com

Scalability© 2007 Patrick Dirdenhttp://www.flickr.com/photos/sp8254/2052236004/

Page 56: Tapestry: State of the Union

© 2009 Formos www.formos.com

YSlow!

Page 57: Tapestry: State of the Union

© 2009 Formos www.formos.com

JavaScript Aggregation

Page 58: Tapestry: State of the Union

© 2009 Formos www.formos.com

Far Future Expires Header

Page 59: Tapestry: State of the Union

© 2009 Formos www.formos.com

Versioned URLs

Page 60: Tapestry: State of the Union

© 2009 Formos www.formos.com

Content Delivery Network

Page 61: Tapestry: State of the Union

© 2009 Formos www.formos.com

Correct HttpSession

Usage

Page 62: Tapestry: State of the Union

© 2009 Formos www.formos.com

❝Architecture is the decisions that you wish you could get right early in a project.❞

Martin Fowler, Chief Scientist, ThoughtWorks

Page 63: Tapestry: State of the Union

© 2009 Formos www.formos.com

Conclusion

Page 64: Tapestry: State of the Union

© 2009 Formos www.formos.com

© 2009 Dani Ihtathohttp://www.flickr.com/photos/ihtatho/627226315/

Page 65: Tapestry: State of the Union

© 2009 Formos www.formos.com

© 2008 Christophe Delaerehttp://www.flickr.com/photos/delaere/2514143242/

Infrastructure

Page 66: Tapestry: State of the Union

© 2009 Formos www.formos.com

Performance

© 2007 Marina Campos Vinhalhttp://www.flickr.com/photos/marinacvinhal/379111290/

Page 67: Tapestry: State of the Union

© 2009 Formos www.formos.com

© 2006 kris247http://www.flickr.com/photos/kris247/86924080/

Tapestry: The Expert is Built In

Page 68: Tapestry: State of the Union

© 2009 Formos www.formos.com

Tapestry 5 In Production

Page 69: Tapestry: State of the Union

© 2009 Formos www.formos.com

Adoption

© 2007 seth mhttp://www.flickr.com/photos/thalamus/469762314/

Page 70: Tapestry: State of the Union

© 2009 Formos www.formos.com

Page Views / Month

0

175,000

350,000

525,000

700,000

03-2008 04-2008 05-2008 06-2008 07-2008 08-2008 09-200810-2008

11-2008 12-200801-2009

02-200903-2009

04-2009

Wicket Tapestry

Tapestry 5.0.18

Page 71: Tapestry: State of the Union

© 2009 Formos www.formos.com

Page Views / Month

0

750,000

1,500,000

2,250,000

3,000,000

03-2008 04-2008 05-2008 06-2008 07-2008 08-200809-2008

10-200811-2008

12-200801-2009

02-200903-2009

04-2009

Wicket Tapestry Struts

Page 72: Tapestry: State of the Union

© 2009 Formos www.formos.com

Downloads / Month

0

22,500

45,000

67,500

90,000

03-2008 04-2008 05-2008 06-2008 07-2008 08-200809-2008 10-2008

11-200812-2008

01-200902-2009

03-200904-2009

Wicket Tapestry

Tapestry 5.0.18

Page 73: Tapestry: State of the Union

© 2009 Formos www.formos.com

Downloads / Month

0

1,250,000

2,500,000

3,750,000

5,000,000

03-2008 04-2008 05-2008 06-200807-2008 08-2008

09-2008 10-200811-2008

12-200801-2009

02-200903-2009

04-2009

Wicket Tapestry Struts

Page 74: Tapestry: State of the Union

© 2009 Formos www.formos.com

Meet the Team

© 2009 sponghttp://www.flickr.com/photos/sponng/3206728292/

Page 75: Tapestry: State of the Union

© 2009 Formos www.formos.com

Dan AdamsBoston, MA, USA

❝Tapestry has allowed us achieve higher code re-use and deliver higher-quality, better-

tested solutions to clients with more modern interfaces. It's

also fun to work in which makes life better for our engineers.❞

Goals:•Increase support for general development including DOM manipulation and utility components

•Feed back in features and improvements from our real world projects

Page 76: Tapestry: State of the Union

© 2009 Formos www.formos.com

Andreas AndreouAthens, Greece

❝I first came across Tapestry at the second half of 2004... it was love at

first sight!❞

Goals:•Release AmpFlow, a project that works at the component level... it is to flows what BeanEditForm is to Forms

Page 77: Tapestry: State of the Union

© 2009 Formos www.formos.com

Ben DotteMadison, WI, USA

❝Tapestry has served as a solid base for our suite of digital asset

management applications since Tapestry version 2❞

Goals:•As we convert our Tapestry 4 application to Tapestry 5 ... contribute any changes we make to ensure that our applications are performant and customizable, and that deployment processes are as streamlined as possible

Page 78: Tapestry: State of the Union

© 2009 Formos www.formos.com

Daniel GredlerAtlanta, GA, USA

❝I know it sounds blasé, but Tapestry is hands down the best

web framework out there❞

Goals:•Integrate HtmlUnit testing

Page 79: Tapestry: State of the Union

© 2009 Formos www.formos.com

Daniel JueFrederick, MD, US

❝When I tell the other developers I chose Tapestry 5

for my project's web framework, I get the jealous nod. The

dependency injection alone is a joy to work with. Tapestry 5 is amazingly stable and succinct,

allowing me to stay focused on optimizing my own code and

expanding the app's capabilitieswith less effort than my

colleagues.❞ Goals:•Provide a wider range of samples apps to help new users get up to speed

•Google Web Toolkit / Tapestry IoC Integration

Page 80: Tapestry: State of the Union

© 2009 Formos www.formos.com

Thiago H. de Paula FigueiredoBelo Horizonte, Minas Gerais, Brazil

❝No Java Web framework is so clean, elegant, flexible, and

productive as Tapestry❞

Goals:•Add transaction management and other features… towards a full application stack, like Spring

•Raise awareness and increase adoption of Tapestry

Page 81: Tapestry: State of the Union

© 2009 Formos www.formos.com

Marcus SchulteZürich, Switzerland

❝Tapestry stands for simple components and an elegance andconsistency of design that I have

yet to find in another web-framework❞

Goals:•Provide improved Tapestry / Google Web Toolkit integration

Page 82: Tapestry: State of the Union

© 2009 Formos www.formos.com

Robert ZeiglerSaint Louis, MO, USA

❝Tapestry 5-IOC is IOC done right: concise and easy to use,

with plenty of power when you need it. Tapestry takes code

reuse from aspired-to ideal to practical inevitability.❞

Goals:•Improved Tapestry/Cayenne integration

•Improve and Simplify Ajax support, especially Ajax with Forms

•Detailed Tapestry Tutorial (using Cayenne)

Page 83: Tapestry: State of the Union

© 2009 Formos www.formos.com

Howard M. Lewis ShipPortland, OR, USA

❝There will never need to be a Tapestry 6❞

Goals:•Spring Web Flow Integration•Portlet Support•More and better Ajax•Better documentation•Towards a fuller stack

Page 84: Tapestry: State of the Union

© 2009 Formos www.formos.com

http://tapestry.apache.org

Page 85: Tapestry: State of the Union

© 2009 Formos www.formos.com

http://tapestry.formos.com

Page 86: Tapestry: State of the Union

© 2009 Formos www.formos.com

http://formos.com

[email protected]