Home arrow Apache arrow Page 2 - Apache Tapestry: ASO and More Components

Creating hivemodule.xml - Apache

We shall continue working on the CelebrityCollector application. The next step is to create a page for adding a new celebrity. While we create that page, I will introduce you to three more components that will add new capabilities to our application and help us get around certain problems.

  1. Apache Tapestry: ASO and More Components
  2. Creating hivemodule.xml
  3. AddCelebrity page
  4. Creating the template with new components
  5. Continuing to configure the application
By: Alexander Kolesnikov
Rating: starstarstarstarstar / 17
May 21, 2007

print this article



Under WEB-INF folder, we need to create a new XML file named hivemodule.xml. Right-click WEB-INF in the Projects view, select New > File/Folder..., then select 'XML' in Categories and 'XML' for file types. Enter 'hivemodule' as the file name on the next page of the wizard; leave the selected 'Well-formed Document' for Document Type.

Now change the contents of the new file to look like this:

<?xml version="1.0" encoding="UTF-8"?>


<module id="com.devshed.tapestry.celebrities" version="1.0.0">



    <state-object name="dataSource" scope="session">






Let's see what we have here. The <module> element is the root of hivemodule.xml; we shall have it in every file like this. Note that the version attribute should look exactly as shown, i.e. it must contain three numbers separated by periods, or the application won't start.

The <contribution> element tells HiveMind that we are going to contribute something of our own to its already existing extensive list of services and objects. The  tapestry.state.ApplicationObjects value for configuration ID explains what we are going to do with this object; it indicates an ASO.

The <state-object> element gives the ASO its name under which we shall be requesting it in the pages. Also we have specified that the scope for this ASO is session. Session is basically a piece of memory associated specifically with the given user; nobody else can access this memory. So in our case there will be a separate instance of DataSource for each user, which makes sense to me, as different collectors will have different collections.

Alternatively, we could use an application scope, and in that case all the users would share the same DataSource.

Finally, the <create-instance> element specifies which class to instantiate to create the desired ASO.

Now that we made available the DataSource as an Application State Object, we don't need to store its instance in the CelebritiesList page class. Remove the line of code where we've instantiated it before:

private DataSource dataSource = new DataSource();

And replace it with the following code:


public abstract DataSource getDataSource();

These two lines of code can be used in any page and any component of the application to obtain a reference to the DataSource. All that remains now is to replace all the references to the removed dataSource property with invocations of the newly created method. Here is the completed code for the DependenciesList class:

public abstract class CelebritiesList extends BasePage {



    public abstract DataSource getDataSource();



    public abstract Details getDetailsPage();


    public List getCelebrities() {

        return getDataSource().getCelebrities();



    public IPage onShowDetails(int id) {


        Celebrity celebrity = getDataSource().getCelebrityById(id);


        Details nextPage = getDetailsPage();



        return nextPage;



Now it is the time to create a page for creating a new Celebrity.

>>> More Apache Articles          >>> More By Alexander Kolesnikov

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Apache Unveils Cassandra 1.2
- Apache on ARM Chips? Dell and Calxeda Help M...
- The Down Side of Open Source Software
- VMware Unveils Serengeti for Apache Hadoop
- SAP Takes Steps to Improve Hadoop Integration
- Looking to Hone Apache Hadoop Skills?
- How to Install Joomla on WAMPP
- Working with XAMPP and Wordpress
- GUI Available for Apache Camel
- Reduce Server Load for Apache and PHP Websit...
- Creating a VAMP (Vista, Apache, MySQL, PHP) ...
- Putting Apache in Jail
- Containing Intrusions in Apache
- Server Limits for Apache Security
- Setting Permissions in Apache

Developer Shed Affiliates


Dev Shed Tutorial Topics: