gnu.xml.pipeline
Class CallFilter

java.lang.Object
  |
  +--gnu.xml.pipeline.CallFilter
All Implemented Interfaces:
EventConsumer

public final class CallFilter
extends java.lang.Object
implements EventConsumer

Input is sent as an XML request to given URI, and the output of this filter is the parsed response to that request. A connection is opened to the remote URI when the startDocument call is issued through this filter, and the request is finished when the endDocument call is issued. Events should be written quickly enough to prevent the remote HTTP server from aborting the connection due to inactivity; you may want to buffer text in an earlier pipeline stage. If your application requires validity checking of such outputs, have the output pipeline include a validation stage.

In effect, this makes a remote procedure call to the URI, with the request and response document syntax as chosen by the application. Note that all the input events must be seen, and sent to the URI, before the first output event can be seen. Clients are delayed at least by waiting for the server to respond, constraining concurrency. Services can thus be used to synchronize concurrent activities, and even to prioritize service among different clients.

You are advised to avoid restricting yourself to an "RPC" model for distributed computation. With a World Wide Web, network latencies and failures (e.g. non-availability) are significant; adopting a "procedure" model, rather than a workflow model where bulk requests are sent and worked on asynchronously, is not generally an optimal system-wide architecture. When the messages may need authentication, such as with an OpenPGP signature, or when server loads don't argue in favor of immediate responses, non-RPC models can be advantageous. (So-called "peer to peer" computing models are one additional type of model, though too often that term is applied to systems that still have a centralized control structure.)

Be strict in what you send, liberal in what you accept, as the Internet tradition goes. Strictly conformant data should never cause problems to its receiver; make your request pipeline be very strict, and don't compromise on that. Make your response pipeline strict as well, but be ready to tolerate specific mild, temporary, and well-documented variations from specific communications peers.

Version:
$Date: 2001/07/11 18:32:10 $
Author:
David Brownell
See Also:
XmlServlet

Constructor Summary
CallFilter(java.lang.String uri, EventConsumer next)
          Initializes a call filter so that its inputs are sent to the specified URI, and its outputs are sent to the next consumer provided.
 
Method Summary
 java.lang.String getCallTarget()
          Returns the call target's URI.
 ContentHandler getContentHandler()
          Returns the content handler currently in use.
 DTDHandler getDTDHandler()
          Returns the DTD handler currently in use.
 java.lang.Object getProperty(java.lang.String id)
          Returns the declaration or lexical handler currently in use, or throws an exception for other properties.
 void setCallTarget(java.lang.String uri)
          Assigns the URI of the call target to be used.
 void setErrorHandler(ErrorHandler handler)
          Assigns the error handler to be used to present most fatal errors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CallFilter

public CallFilter(java.lang.String uri,
                  EventConsumer next)
           throws java.io.IOException
Initializes a call filter so that its inputs are sent to the specified URI, and its outputs are sent to the next consumer provided.
Throws:
java.io.IOException - if the URI isn't accepted as a URL
Method Detail

setCallTarget

public final void setCallTarget(java.lang.String uri)
                         throws java.io.IOException
Assigns the URI of the call target to be used. Does not affect calls currently being made.

setErrorHandler

public void setErrorHandler(ErrorHandler handler)
Assigns the error handler to be used to present most fatal errors.
Specified by:
setErrorHandler in interface EventConsumer
Following copied from interface: gnu.xml.pipeline.EventConsumer
Parameters:
handler - encapsulates error handling policy for this stage

getCallTarget

public final java.lang.String getCallTarget()
Returns the call target's URI.

getContentHandler

public final ContentHandler getContentHandler()
Returns the content handler currently in use.
Specified by:
getContentHandler in interface EventConsumer

getDTDHandler

public final DTDHandler getDTDHandler()
Returns the DTD handler currently in use.
Specified by:
getDTDHandler in interface EventConsumer

getProperty

public final java.lang.Object getProperty(java.lang.String id)
                                   throws SAXNotRecognizedException
Returns the declaration or lexical handler currently in use, or throws an exception for other properties.
Specified by:
getProperty in interface EventConsumer
Following copied from interface: gnu.xml.pipeline.EventConsumer
Parameters:
id - This is a URI identifying the type of property desired.
Returns:
The value of that property, if it is defined.
Throws:
SAXNotRecognizedException - Thrown if the particular pipeline stage does not understand the specified identifier.

Source code is GPL'd in the JAXP subproject at http://savannah.gnu.org/projects/classpathx
This documentation was derived from that source code on 2001-07-12.