jSyncManager Simple Java Server

org.jSyncManager.SJS.API
Class AbstractRequestResponseAdapter

java.lang.Object
  extended by java.lang.Thread
      extended by org.jSyncManager.SJS.API.AbstractAdapter
          extended by org.jSyncManager.SJS.API.AbstractRequestResponseAdapter
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
AbstractSMTPServer, TestAdapter

public abstract class AbstractRequestResponseAdapter
extends AbstractAdapter

An abstract parent for all Request/Response adapters. This adapter class expands upon the AbstractAdapter to provide request/response style communications. Sub-classes need implement only one method to handle their communications.

Version:
0.1
Author:
Brad BARCLAY <bbarclay@jsyncmanager.org>

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class org.jSyncManager.SJS.API.AbstractAdapter
props
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AbstractRequestResponseAdapter()
          Constructs a new AbstractRequestResponseAdapter instance.
 
Method Summary
protected  void disconnect()
          The disconnect method.
protected  java.lang.String getConnectionHeaderString()
          The Connection Header method.
protected  java.lang.String getTimeoutMessage()
          The timeout error message.
protected  void processConnection(java.io.InputStream in, java.io.OutputStream out)
          The processConnection method.
protected abstract  java.lang.String processRequest(java.lang.String request)
          The processRequest method.
 
Methods inherited from class org.jSyncManager.SJS.API.AbstractAdapter
connectionPermitted, getConnectionManagerInterface, getInetAddress, getLogManager, getProperty, processConnection, run, setLogManager, setThreadGroup
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractRequestResponseAdapter

public AbstractRequestResponseAdapter()
Constructs a new AbstractRequestResponseAdapter instance.

Method Detail

processConnection

protected final void processConnection(java.io.InputStream in,
                                       java.io.OutputStream out)
                                throws java.lang.Exception
The processConnection method. This method is called when a connection for this adapter type is received. Subclasses need to implement this method in order to do anything useful.

Specified by:
processConnection in class AbstractAdapter
Parameters:
in - the InputStream object for communications.
out - the OutputStream object for communications.
Throws:
java.lang.Exception - any checked exception not caught and handled by the adapter.

disconnect

protected final void disconnect()
The disconnect method. Implementations should call this method when it is time to disconnect. Note that this will not cause the adapter to disconnect immediately, but only after the current call to processRequest returns.

Overrides:
disconnect in class AbstractAdapter

processRequest

protected abstract java.lang.String processRequest(java.lang.String request)
                                            throws java.lang.Exception
The processRequest method. This method needs to be implemented by subclasses in order to facilitate the request/response system. This method may return null, in which case no response will be returned to the connecting host for this request.

Parameters:
request - the request to be processed.
Returns:
the response to be sent.
Throws:
java.lang.Exception - any checked exception that goes unhandled.

getConnectionHeaderString

protected java.lang.String getConnectionHeaderString()
The Connection Header method. This method returns the data which should be displayed when a connection is received. If this method returns null, as in the default implementation, no header will be displayed.

Returns:
the connection header string, or null for no connection header message.

getTimeoutMessage

protected java.lang.String getTimeoutMessage()
The timeout error message. This method returns the message to display when the connection times out. The default implementation returns null. Subclasses should override this to display the relevent message when a timeout occurs (if any).

Returns:
the timeout error message.

jSyncManager Simple Java Server

Copyright (c) 2004 Brad BARCLAY. All Rights Reserved.