Apache Tapestry

Apache Tapestry

Table of Contents

Apache Tapestry is known as an open-source component-based web framework that is used to develop Java-based web applications. Tapestry will be developed by “Howard Lewis ship” and open-sourced and also included in the Apache project in 2006. Tapestry components are java classes. They are not inherited from the framework-specific base class or implementation of an interface and they can be just plain POJOs.(Plain old java objects). This is an important feature of the old java used by tapestry is Annotation. Tapestry web pages will be constructed by using one or more components, where each will be having an XML based template and component class that is well designed with many Tapestry Annotations.

Benefits of Tapestry:

There are many benefits of Tapestry like

  1. They are highly scalable web applications
  2. They are Adaptive API
  3. They are a fast and mature framework.
  4. They are persistent in-state storage management.
  5. They have a built-in inversion of control.

Features of Tapestry

Tapestry will be having following features

  1. It will be having live class reloading
  2. It has clear and detailed exception reporting.
  3. It has a static structure and dynamic behaviours.
  4. It has extensive use of Plain Old Java Objects(POJOs).
  5. It has code less and delivers more.

Why do we have use Tapestry?

Java is having a lot of Tapestry web frameworks like JSP, struts etc. Tapestry gives a modern approach to web application programming by providing live class reloading. Other frameworks are introducing a lot of interfaces, abstract and base classes. Tapestry just introduces a small set of annotations and also provides the ability to give a large application with AJAX support. 

Tapestry Architecture

Tapestry will try to use the necessary features of Java as much as possible. All the tapestry pages will be simply POJOs. It does not force any custom interfaces or base class to write an application. It uses Annotation to give any features. It is based on the battle-tested Java servlet API and will be implemented as a Servlet Filter. It will give a new dimension to the web application and programming is quite simple, flexible, Understandable and Robust.

Workflow

Step 1: Java Servlet will accept the page request.This Java Servlet will be configured in a way where incoming request will be forwarded to tapestry. The configuration is done in the web.xml like the example

<!DOCTYPE web-app PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN” 

   “http://java.sun.com/dtd/web-app_2_3.dtd”> 

<web-app> 

   <display-name>My Tapestry Application</display-name> 

   <context-param> 

      <param-name>tapestry.app-package </param-name> 

      <param-value>NSS.example.myapp </param-value> 

   </context-param> 

   <filter> 

      <filter-name>app</filter-name> 

      <filter-class>org.apache.tapestry5.TapestryFilter</filter-class> 

   </filter> 

   <filter-mapping> 

      <filter-name>app</filter-name> 

      <url-pattern>/*</url-pattern> 

   </filter-mapping> 

</web-app> 

Step 2: Tapestry filter will call the HttpServletRequestHandler Service by its Service() method.

Step 3: HttpServletRequestHandler will store the request and response in RequestGlobals.It also surrounds the request and response as a Request and Response object and also sends it to the RequestHandler.

Step 4: The RequestHandler will be an abstraction on top of the HttpServletRequest of Servlet API. There are features of tapestry which are done in the RequestHandler section.RequestHandler will provide many built-in filters that include

  • CheckForUpdates Filter- This will be responsible for any live class reloading. This filter will check the java classes for any changes and update the application which is necessary.
  • Localization Filter-It will identify the location of the user and provide localisation support for the application.
  • StaticFiles Filter-This will identify the static request and aborts the process. As the process will be aborted, Java Servlet controls and process the request.
  • Error Filter-It will catch the unidentified exception and also presents the exception report page.

Step 5: MasterDispatcher can be held responsible for providing the page by calling several dispatchers that are more specific order. There are main four Dispatchers called by MasterDispatcher is

  • RootPath Dispatcher- It recognises the root path “/” of the request and renders the same as Start Page.
  • Asset Dispatcher – It will be recognised the asset request by checking the URL pattern/assets and also sends the wanted assets by the byte streams.
  • PageRender Dispatcher- It is used for bulk tapestry operations and also component Dispatcher as a dispatcher that will recognise the particular page of that request and also its activation context. It also then renders the particular page and also sends it to the client.
  • Component Dispatcher- Component Dispatcher will match the URL of the page with pattern /<class_name>/<component_id>:<event_type>/<activation_context>. The response  component dispatcher will send a redirect to the client.

Questions

  1. What is Tapestry? Explain
  2. Why do we have to use Tapestry Framework?

One Response

  1. 1.What is Tapestry? Explain.
    Apache Tapestry is an open-source framework for creating dynamic, robust, highly scalable web applications in Java.Tapestry can work under any application server and easily integrate with all back ends like Spring, Hibernate, etc. 
    2.Why do we have to use Tapestry Framework?
     Tapestry gives a modern approach to web application programming by providing live class reloading.Other frameworks are introducing a lot of interfaces, abstract and base classes. Tapestry just introduces a small set of annotations and also provides the ability to give a large application with AJAX support. 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share this article
Subscribe
By pressing the Subscribe button, you confirm that you have read our Privacy Policy.
Need a Free Demo Class?
Join H2K Infosys IT Online Training
Enroll Free demo class