com.partnersoft.net
Class TextServerDaemon

java.lang.Object
  extended by com.partnersoft.net.TextServerDaemon
All Implemented Interfaces:
Daemon

public abstract class TextServerDaemon
extends java.lang.Object
implements Daemon

A simple TCP/IP server that accepts a text request and sends a text response.

Example script:

 daemon = new TextServerDaemon("Example", 8012) {
     public String processRequest(String request) {
         // just send back request in this example
         return "request was " + request;
     }
 }
 
Copyright 2008 Partner Software, Inc.

Version:
$Id$
Author:
Paul Reavis

Constructor Summary
TextServerDaemon(java.lang.String name, int port)
           
 
Method Summary
abstract  java.lang.String processRequest(java.lang.String request)
          Subclasses must implement this to handle incoming requests and generate responses.
 void start()
          Start the daemon process.
 void stop()
          Stop the daemon process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextServerDaemon

public TextServerDaemon(java.lang.String name,
                        int port)
                 throws java.io.IOException
Throws:
java.io.IOException
Method Detail

processRequest

public abstract java.lang.String processRequest(java.lang.String request)
Subclasses must implement this to handle incoming requests and generate responses. Both requests and responses are represented as Strings.


start

public void start()
           throws java.lang.Exception
Description copied from interface: Daemon
Start the daemon process. Acquire needed resources and fire up any associated threads.

Specified by:
start in interface Daemon
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
Description copied from interface: Daemon
Stop the daemon process. Release any resources and shut down any associated threads.

Specified by:
stop in interface Daemon
Throws:
java.lang.Exception