Interface | Description |
---|---|
Service |
is a
Runnable that catches and stores exceptions
thrown in its run() method such that Service.getException() can return it. |
ServiceFactory |
Class | Description |
---|---|
DfaRunService |
convenience class which makes a
DfaRun into a
service that can be returned by a ServiceFactory . |
DistPipeFilter |
is a communication endpoint for a distributed pipe of
(text) filters.
|
FilterServiceFactory |
sets up a filter service as returned by any
ServiceFactory as an element of a distributed pipe. |
FilterSvrInfo |
describes a filter server running somewhere on the
network.
|
PipelineRequest |
Encapsulates a request for contact to a
FilterServiceFactory . |
TcpServer |
a simple socket server able to serve multiple client
connections in parallel.
|
Exception | Description |
---|---|
ServiceCreateException |
thrown if something goes wrong when creating a service.
|
ServiceUnavailException |
thrown if something goes wrong when creating a service because the
service is currently unavailable, but is expected to work again in
further requests.
|
Simple tcp server and clients.
TcpServer
, Service
and
ServiceFactory
The most basic class provided is TcpServer
which handles all the nasty bits of setting up a network
connection. For every incoming connection it asks a ServiceFactory
to generate a Service
. The Service
is then plumbed up
with the I/O streams of the network connection and its
run()
method called. When that finishes, the
TcpServer
cleans up the remains of the thread and
closes the connection.
DfaService
and DfaRunService
If you have a class that creates a DfaRun
object, it can implement the interface ServiceFactory
by wrapping the DfaRun
into a into a DfaRunService
.
Example
public createService(java.io.InputStream in, java.io.OutputStream out) { DfaRun r = ... // do whatever is necessary // to create a DfaRun r.setIn(in); return new DfaRunService(r, new PrintStream(out)); }
FilterServiceFactory
and
DistPipeFilter
To set up one element of a distributed filter pipeline, use
a FilterServiceFactory
. Suppose you have a
ServiceFactory
object called
mySF
. Then do the
following:
FilterServiceFactory fsf = new FilterServiceFactory(mySF); int port = 3456; new TcpServer(port, fsf).serve();As a result, the service created for connections on the given port will read from its input stream instructions of how to fetch input data, normally from another upstream server. It establishes the connection and plumbs up your underlying service with the input from upstream and the output to downstream, all fully automatic.
To access a pipeline of filter services as described above, use
DistPipeFilter
or its command line wrapper
DistFilter
.