ResultSet Framework

From Gcube Wiki
Revision as of 11:28, 7 February 2007 by Gpapanikos (Talk | contribs) (Creating an RS)

Jump to: navigation, search

ResultSet Framework

Introduction

The ResultSet Framework provides the enabling mechanism to pass by reference data between components and / or services that can be hosted in the same or remote nodes. It utilizes the WSRF Framework for keeping state and offers value adding opeartions for encapsulating remote and local calls, paging of content, data movement, remote processing and much more fun stuf which you can discover your self instead of me having to right them down you lazy bum (J).......

Implementation Overview

The framework consists of 4 sub components :

  1. the ResultSet library
  2. the ResultSet Service
  3. the ResultSet Client
  4. the ResultSet Garbage Collector


  • The ResultSet is the enabling element that creates a linked list of pages holding the records that are part of the specific result set. It can iterate over the created parts and perform various operations on the structure of the list and the contents themselves. Its operations are mosty part specific bu they can also affect the entire result chain. Once a page of content has been created and the next in line has been initialized the part cannot be altered. Once it has been declared that the authoring of a result set has finished, the entire chain of it is immutible.
  • The ResultSet Service is merely a WS front-end to the ResultSet library. It creates and manages WS-Resources holding rferences to instances of the ResultSet components. These instances are responsible to hold state regarding the iteration over the chain of pages and for accessing / modifying / querying the data held.
  • The ResultSet Client is a library giving access to both high and low level operations that can be performed on a specific ResultSet component instance and its underlying data. It enables handling of ResultSets that are both wrapped through a WS front-end and that are locally manipulated though direct java invocations (within JVM).
  • The ResultSet Garbage Collector is a deamon-like program that can be initialized to clear up resources used by the ResultSet Framework (removing filesystem resources and destroying created WS-Resources)

Dependencies

  • ResultSetLibrary
    • jdk 1.5
    • WS-Core
  • ResultSetService
    • jdk 1.5
    • WS-Core
    • ResultSetLibrary
  • ResultSetClient
    • jdk 1.5
    • WS-Core
    • ResultSetLibrary
    • ResultSetService
  • ResultSetGarbageCollector
    • jdk 1.5
    • WS-Core
    • ResultSetLibrary
    • ResultSetService stubs

Usage Example

The ResultSets that can be created are content independent but depending on the content inserted different operations can be performed. So different readers and writers have been implemented to offer different levels of versatility depending on the content. Here he will mainly focus on the XML authoring and retrieving

Creating an RS

/*A method that creates a new RSXMLWriter and populates it with some results*/
public static RSXMLWriter createRSWriter() throws Exception{

/*Create a new writer with the default parametrizable values*/
RSXMLWriter writer=RSXMLWriter.getRSXMLWriter();
/*Create a new writer which should have as a condition for paging inserted results either having
30 records per page or having a total size surpasing 1024 bytes */
//writer=RSXMLWriter.getRSXMLWriter(30,1024);
/*Create a new writer and set a lifetime property of 1000 millisecs. Also set that the paging
condition will be having 10 records per page or a total size surpasing teh default value*/
//writer=RSXMLWriter.getRSXMLWriter(new PropertyElementBase[]{new PropertyElementLifeSpanGC(1000)});
//writer.setRecsPerPart(10);
/*Add a new result with the given id, collection, rank and payload*/
writer.addResults(new ResultElementGeneric("id1","collection1","rank1","payload"));
/*Add a new result with the given id, collection, rank and payload*/
writer.addResults(new ResultElementGeneric("id2","collection1","rank2","payload"));
/*Add an array of results with the given id, collection, rank and payload*/
writer.addResults(new ResultElementBase[]{new ResultElementGeneric("id3","collection1","rank3","payload"),
new ResultElementGeneric("id4","collection1","rank4","payload")});
/*Give back the writer*/
return writer;

}

Retrieving a locator

From a writer

/*This method retrieves an instance of an RSLocator capable of identifying a ResultSet authored by the provided RSXMLWriter. Depending on the type of resource requested, this identifier can either be an identifier pointing to the local node (filesystem) or an idenitfier capable of pinpointing the RS through a web service using the WS-Resource pattern. One can create many locators (of the same or different) type for the same authored RS*/ public static RSLocator getLocator(RSXMLWriter writer) throws Exception{

RSLocator locator=null;
/*Retrieves a locator identifying the RS in the local node*/
//locator=writer.getRSLocator(new RSResourceLocalType());
/*Retrieves a locator identifying the RS through WS-Resource pattern accesible from any node. The
The service pointed to must be in the localhost. This method can be used when manipulating the RSXMLWriter
outside container context. Otherwise the following method can be used*/
//locator=writer.getRSLocator(new RSResourceWSRFType("http://localhost:8080/wsrf/services/diligentproject/searchservice/ResultSetService"));
/*Retrieves a locator identifying the RS through WS-Resource pattern accesible from any node. The
default constructor utilizes the container context (which must be available) to compose the localy hosted
ResultSetService that must be deployed*/
locator=writer.getRSLocator(new RSResourceWSRFType());
return locator;

}

From a reader

/*This method retrieves an instance of an RSLocator capable of identifying the ResultSet read by the provided RSXMLReader. Everythime the method is called the same resource is identified*/ public static RSLocator getLocator(RSXMLReader reader) throws Exception{

RSLocator locator=null;
/*Retrieves a locator identifying the RS. The type is the same as the one used to initialize the RSXMLReader*/
locator=reader.getRSLocator();
return locator;

}

Reading an RS

Extending Base elements

Complex Operations