Tapestry

"`Tapestry`_ is an open-source framework for creating dynamic, robust, highly scalable web applications in Java_..."

Description

Integration with the Tapestry framework is done through TapestryConnectionHandler. That class sets up a hivemind registry and substitutes/extends several important service points. There are set of classes that are given instead of original implementations: DanubeActivator, DanubeContext, DanubeCookieSource, DanubeRequest, DanubeResponse and DanubeSession.

Configuration

TapestryConnectionHandler's init method should be called before the class can be used. This class has several important parameters:

  • applicationSpecificationResourceName - name of main .application file. It defaults to "tapestry.application"
  • initialParameters - map of initial parameters.
  • sessionManager - session manager to be used. It must implement HTTPSessionManager. If not set then defaulted to SimpleSessionManager.

Also there are a few parameters that are exposed as a expansion points but there is no reason for them to be set unless some internal behaviour is to be changed. Here there are:

  • classResolver - Class resolver implementation of ClassResolver type.
  • webActivator - web activator implementation of WebActivator type.
  • webContext - web context implementation of WebContext type.

Pages and all other resources are accesses through class loader - so make sure that they are in the classpath.

Aside of org.abstracthorizon.danube.tapestry.TapestryConnectionHandler there is org.abstracthorizon.danube.tapestry.spring.TapestryConnectionHandler supplied as well. Difference is that Spring version uses application context's resource for obtaining Tapestry's application resources (applicationSpecificationName).

Non-Spring version of TapestryConnectionHandler searches for applicationSpecificationResourceName using WebContextResource - in WEB-INF/ path. Spring version of TapestryConnectionHandler first checks for applicationSpecificationResourceName as application context's resource and if failed then as application context's resource at path WEB-INF/.

Example

Here is an example of an configuration of Tapestry taken from supplied demo:

<!--
 * This bean defines beans application context.
 * It references to two components: File component that accepts only file named "style.css" and
 * MVC controller defined at the "/app" path.
-->
<bean name="web-application" class="org.abstracthorizon.danube.http.HTTPContext">
<property name="components">
    <list>
        <bean class="org.abstracthorizon.danube.http.matcher.Pattern">
            <property name="pattern"><value>/style\.css</value></property>
            <property name="connectionHandler"><ref bean="files"/></property>
        </bean>
        <bean class="org.abstracthorizon.danube.http.matcher.Prefix">
            <property name="prefix"><value>/app</value></property>
            <property name="connectionHandler"><ref bean="tapestry-application"/></property>
        </bean>
    </list>
</property>
</bean>

<!--
 * This bean defines serving files from directory "pages" as given file path.
-->
<bean name="files" class="org.abstracthorizon.danube.http.util.FileConnectionHandler">
    <property name="filePath"><value>src/pages</value></property>
</bean>

<!--
 * This is connection handler that handles Tapestry requests.
-->
<bean name="tapestry-application" class="org.abstracthorizon.danube.tapestry.TapestryConnectionHandler"
    init-method="init">
</bean>

Known Issues

Successive requests before a session is created are going to create several sessions. This is due to the bug in the way sessions are created.