morphis logo morphis | wax   
morphis manual
manual
 

Processing
   Dispatching
   Requesting
   Translating

Installation
   Requirements
   Instructions
   Config Properties

Dispatching
   Configuration
   Pre/Post Filters

Requestors
   URL Requesting
   Servlet Chaining
   Run-time Instructs
   Custom Requestors

Translators
   Non-Translator
   Custom Translators

SAX Translators
   XSLT Translation
   Custom SAX Filters

Requestors: Writing Custom Requestors

You may write your own requestors to obtain data from any data source. For example, you may wish to obtain a document directly from another application server, or possibly as the result of running a command-line utility.

Custom requestors are implemented by extending the org.morphis.Requestor interface. This interface requires the following methods to be implemented. See the api documentation for more details.

  • open: This method is called to perform any initialization. Class member variables may be set in this method. For example, a socket may be opened up in this method.

  • getInputStream: This method is called in order to retrieve an input stream of data. This stream is then given to the Translator.

  • getExpires: A Requestor is able to specify when its data stream expires. This is used by Translators to determine how long post-translated data should be cached. A Requestor that returns an XML news story that expires in 10 minutes would want to tell the Translator that the HTML version of the story also expires in 10 minutes. Returning 0 means that the stream should never expire, and returning -1 means the default expiration time should be used.

  • close: This method is called when the input stream should be closed, and any transient memory should be cleaned up.

Requestors are stored in an object pool to save memory and increase performance. Individual objects are recycled for subsequent processing. Requestor implementations must have a public constructor with no arguments. All member variables should be set in the open method, and cleared in the close method.

morphis SourceForge Logo