© 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/
Jan 28, 2015
© 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/
© 2009 Formos www.formos.com
Howard Lewis Ship
• Creator, Apache Tapestry
• Author, "Tapestry in Action"
• Independent Consultant 2003-2007
• Formos 2008-
© 2009 Formos www.formos.com
What is Tapestry?
© 2009 Formos www.formos.com
Java
© 2009 Formos www.formos.com
Open Source
© 2009 Formos www.formos.com
Component Based
© 2009 Formos www.formos.com
Developer Focused
© 2009 Formos www.formos.com
Concise
© 2009 Formos www.formos.com
Fast!
© 2009 Formos www.formos.com
Mature
© 2009 Formos www.formos.com
Tapestry Elements
© 2009 Nataline Funghttp://www.flickr.com/photos/metaphora/3384569933/
© 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
© 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
© 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
© 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
© 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
© 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
© 2009 Formos www.formos.com
Component
Template
Java Class
Message Catalog
Meta-Programming
Injections
© 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
© 2009 Formos www.formos.com
Developer Productivity© 2006 Martino Sabiahttp://www.flickr.com/photos/ezu/297634534/
© 2009 Formos www.formos.com
© 2009 Formos www.formos.com
Non-Tapestry Exception Reporting
© 2009 Formos www.formos.com
Index does not contain a property named 'now'
Available properties: class, componentResources, currentTime
© 2009 Formos www.formos.com
© 2009 Formos www.formos.com
© 2009 Formos www.formos.com
Scaffolding
@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
© 2009 Formos www.formos.com
© 2009 Formos www.formos.com
Property Types
Naming Conventions
Annotations
Explicit Overrides
Localized Messages
Bea
nEd
itFo
rm
Parameters
© 2009 Formos www.formos.com
Feedback &Exploration
© 2008 Alan Grinberghttp://www.flickr.com/photos/agrinberg/2465119180/
© 2009 Formos www.formos.com
Flow
© 2008 Manu Gómezhttp://www.flickr.com/photos/manugomi/2884678938/
© 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
© 2009 Formos www.formos.com
Internationalization
© 2006 Tom Maglieryhttp://www.flickr.com/photos/mag3737/267638148/
© 2009 Formos www.formos.com
© 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
© 2009 Formos www.formos.com
Tapestry Components
Copyright © A. Lipson 2003http://www.andrewlipson.com/escher/relativity.html
© 2009 Formos www.formos.com
Intrinsic
© 2009 Formos www.formos.com
Inheritance
© 2009 Formos www.formos.com
Composition
© 2009 Formos www.formos.com
POJO
© 2009 Formos www.formos.com
Events
© 2009 Formos www.formos.com
Consistency!
http://flickr.com/photos/kylemay/1430449350/
© 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
© 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
❶
❷
❸
❹
❺
© 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
© 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
© 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
© 2009 Formos www.formos.com
© 2009 Formos www.formos.com
TapestryPerformance
© 2009 viernesthttp://www.flickr.com/photos/viernest/3380560365/
© 2009 Formos www.formos.com
Request Processing Speed
© 2007 Jojo Cencehttp://www.flickr.com/photos/jojocence/1372693375/
© 2009 Formos www.formos.com
Java == Fast
© 2009 Formos www.formos.com
No Reflection
© 2009 Formos www.formos.com
Page Pooling
© 2009 Formos www.formos.com
GZIP Compression
© 2009 Formos www.formos.com
Scalability© 2007 Patrick Dirdenhttp://www.flickr.com/photos/sp8254/2052236004/
© 2009 Formos www.formos.com
YSlow!
© 2009 Formos www.formos.com
JavaScript Aggregation
© 2009 Formos www.formos.com
Far Future Expires Header
© 2009 Formos www.formos.com
Versioned URLs
© 2009 Formos www.formos.com
Content Delivery Network
© 2009 Formos www.formos.com
Correct HttpSession
Usage
© 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
© 2009 Formos www.formos.com
Conclusion
© 2009 Formos www.formos.com
© 2009 Dani Ihtathohttp://www.flickr.com/photos/ihtatho/627226315/
© 2009 Formos www.formos.com
© 2008 Christophe Delaerehttp://www.flickr.com/photos/delaere/2514143242/
Infrastructure
© 2009 Formos www.formos.com
Performance
© 2007 Marina Campos Vinhalhttp://www.flickr.com/photos/marinacvinhal/379111290/
© 2009 Formos www.formos.com
© 2006 kris247http://www.flickr.com/photos/kris247/86924080/
Tapestry: The Expert is Built In
© 2009 Formos www.formos.com
Tapestry 5 In Production
© 2009 Formos www.formos.com
Adoption
© 2007 seth mhttp://www.flickr.com/photos/thalamus/469762314/
© 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
© 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
© 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
© 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
© 2009 Formos www.formos.com
Meet the Team
© 2009 sponghttp://www.flickr.com/photos/sponng/3206728292/
© 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
© 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
© 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
© 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
© 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
© 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
© 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
© 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)
© 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
© 2009 Formos www.formos.com
http://tapestry.apache.org
© 2009 Formos www.formos.com
http://tapestry.formos.com