14-Jul-04 (Created: 14-Jul-04) | More in 'OSCON-2004'

Transparent Data Pipelines Pattern: Code Examples

What is TDP

The ability of data to flow from a variety of sources in to a channel that can be tapped in or consumed by a client in a data agnostic horizontal manner.

One such data pipeline


###################################
# This specification produces an ihds
###################################
request.ihdsTest.className=com.ai.htmlgen.DBHashTableFormHandler1
request.ihdsTest.loopNames=loop1,loop2

#section1 - main key value pairs
#Data comes from select statement 
request.ihdsTest.mainDataRequest.classname=com.ai.db.DBRequestExecutor2
request.ihdsTest.mainDataRequest.db=my-database
request.ihdsTest.mainDataRequest.stmt=some-select

#section2 - loop1
#Data comes from a flat file 
request.ihdsTest.loop1.class_request.className=com.ai.htmlgen.GenericTableHandler6
request.ihdsTest.loop1.loopNames=loop11
request.ihdsTest.loop1.query_request.className=com.ai.data.RowFileReader
request.ihdsTest.loop1.query_request.filename=aspire:\\samples
            \\pop-table-tags\\properties\\pop-table.data

         
#section3 - loop2
#Data comes from a stored proc 
request.ihdsTest.loop2.class_request.className=com.ai.htmlgen.GenericTableHandler6
request.ihdsTest.loop2.loopNames=loop11
request.ihdsTest.loop2.query_request.className=com.ai.db.StoredProceExecutor2
request.ihdsTest.loop2.query_request.db=my-database
request.ihdsTest.loop2.query_request.stmt=call pkg.sp_proc1()

#section3 - subloop to loop1
#Data comes from a java class 
request.loop11.class_request.classname=com.ai.htmlgen.GenericTableHandler6
request.loop11.query_request.classname=com.ai.data.MyJavaDataProducer

TDP client data model: A hierarchical data set


<AspireDataSet>
    <!-- A set of key value pairs at the root level -->
    <key1>val1</key1>   
    <key2>val2</key2>

    <!-- A set of named loops -->
    <loop name="loop">
    </loop>
    <loop name="loop2">
    </loop>
</AspireDataSet>

Inner loop further expanded


<loop name="loopname">
    <row>
        <!-- a set of key value pairs -->
        <key1>val1</key1>
        <key2>val2</key2>

        <!-- a set of named loops -->
        <loop name="loopname1">
        </loop>

        <!-- a set of named loops -->
        <loop name="loopname2">
        </loop>
    </row>
    <row>
    </row>
</loop>

How is TDP used by the client


    Ihds myDataAsHds = Utils.executeDataTransaction("ihdsTest",new Hashmap());
	//use myDataAsHds

Reusable parts


com.ai.db.DBRequestExecutor2
com.ai.db.StoredProcRequestExecutor2
com.ai.data.RowFileReader
com.ai.parts.URLReader
com.ai.parts.XMLFileReader

References

1. Transparent Data Pipelines for JSP at OnJava.com, 12/12/2001

2. Using Hierarchical Data Sets with Aspire and Tomcat, at OnJava.com

3. Use Aspire and Tomcat to retrieve XML declaratively from any relational database

4. Code Examples for relational data sets

5. OnJava article on relational data sets

6. Overview of data access using Aspire

7. OSCON 2004 Summary page for Server side patterns session