Support for Push Models

Section - Java Deployment

The common design pattern for supporting push models using the convenience interface TMPipeline and the class ScalingXMLReader are provided to support XML (and other) push models. 

In these models the TM component is part of a pipeline and listens continuously for input events. At intervals these input events are deemed to be complete (for example a complete XML sub tree has arrived). When this happens the pipeline architecture requires that the TM component be asked to transform all the relevant items in the input 'device'.

The interface TMPipeline requires two methods to be present:

void dataAvailable();
void done();
TMDHIterator getObjectsOfInterest(...) // only can be called inside dataAvailable

The interface TMPusher requires these methods to be present:

void AddPipelineName(String theName);
void RemovePipelineName(String theName);
setPushTarget(TMGenericPipeline theTMGenericPipeline);
void start();

Here is an example of how it can used generically. 'MyStuff' is a user written class. ScalingXMLReader is ETL provided implementation of the generic TMPusher interface

class MyImplementation extends TMGenericPipeline
{
  ScalingXMLReader myScalingXMLReader ;
  public MyImplementation ()
  {
    TMPusher myScalingXMLReader = new ScalingXMLReader ;
    myScalingXMLReader.setPushTarget(this); 
    // tell the ScalingXMLReader where to call when it has complete tree of information
    TMSourceQuery aTMSourceQuery = TMQueryObjectsFactory.createTMSourceQuery("Well");
    myScalingXMLReader.AddPipelineName(aTMSourceQuery); 
    // tell the ScalingXMLReader to look for 'Well' objects 
    myScalingXMLReader.start();
  }

  // Thus when running at intervals we expect ScalingXMLReader will call back to   //dataAvailable.
// dataAvailable could look something like:

  public void dataAvailable()
  {
// inside this we can now 'pull' the data 
    TMDHIterator anIt = myScalingXMLReader.getObjectsOfInterest(listOfDomains);
    while (true)
    {
      XMLDH aInputDh = (XMLDH) anIt .getNext();
      if (null==aInputDh)
      {
        break;
      }
      TMWriteElement aOutputDh 
        = (TMWriteElement )myTMTransformExecutor.transform(aInputDh); 
// maybe further user processing such as:
      myUserWrittenTarget.consumeHandle(aOutputDh);
    }
// or alternatively followed by something like flush out this writer 
  }

  public void done()
  { 
//allows us to close down the myUserWrittenTarget if rqd
  }
}