org.licas.server

## Class ServerConnection

- java.lang.Object
- - java.lang.Thread
  - - org.licas.server.ServerConnection

- All Implemented Interfaces:
    java.lang.Runnable
  Direct Known Subclasses:
    ServerConnectionAsyc, ServerConnectionBlock

      public abstract class ServerConnection
      extends java.lang.Thread

  Base class for runnning a single HTTP transaction on a separate thread. It uses a `Channel` to pass information and a `ServerHandler` to process the message.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.nio.channels.Channel` | `channel` The listener channel
    `protected static java.lang.String` | `HTTPGSTART` Message start and end between HTTP data
    `protected static java.lang.String` | `HTTPMEND`
    `protected static java.lang.String` | `HTTPPSTART`
    `protected int` | `port` The port to listen on
    `protected ServerHandler` | `serverHandler` The server handler that processes the message
    `protected java.lang.Object` | `syncOn` To synchronize on
    `protected long` | `timeOut` Timeout for recieving continuous message

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServerConnection(java.nio.channels.Channel theChannel, long theTimeOut, ServerHandler theServerHandler)` Create a new instance of ServerConnection.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected HttpEntity` | `convertRequest(java.lang.String message)` Parse the input request string to re-construct the MethodInfo objects.
    `protected java.lang.String` | `httpHeaders(HttpEntity request)` Determine of the request is an HTTP-type that requires headers at the start and create them if it does.

    - ### Methods inherited from class java.lang.Thread

      `activeCount, checkAccess, clone, 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, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### HTTPGSTART

          protected static java.lang.String HTTPGSTART

      Message start and end between HTTP data

    - #### HTTPPSTART

          protected static java.lang.String HTTPPSTART

    - #### HTTPMEND

          protected static java.lang.String HTTPMEND

    - #### port

          protected int port

      The port to listen on

    - #### timeOut

          protected long timeOut

      Timeout for recieving continuous message

    - #### serverHandler

          protected ServerHandler serverHandler

      The server handler that processes the message

    - #### channel

          protected java.nio.channels.Channel channel

      The listener channel

    - #### syncOn

          protected final java.lang.Object syncOn

      To synchronize on

  - ### Constructor Detail

    - #### ServerConnection

          public ServerConnection(java.nio.channels.Channel theChannel,
                                  long theTimeOut,
                                  ServerHandler theServerHandler)
                           throws java.lang.Exception

      Create a new instance of ServerConnection.
      Parameters:
        `theChannel` - the listener channel.
        `theTimeOut` - timeout for recieving continuous message.
        `theServerHandler` - the server handler that processes the message.
      Throws:
        `java.lang.Exception` - any error.

  - ### Method Detail

    - #### convertRequest

          protected HttpEntity convertRequest(java.lang.String message)
                                       throws java.lang.Exception

      Parse the input request string to re-construct the MethodInfo objects.
      Parameters:
        `message` - the request message, an be Xml-RPC, or Rest, for example.
      Returns:
        an HttpEntity with MethodInfo objects or Rest string.
      Throws:
        `java.lang.Exception` - any error.

    - #### httpHeaders

          protected java.lang.String httpHeaders(HttpEntity request)

      Determine of the request is an HTTP-type that requires headers at the start and create them if it does.
      Parameters:
        `request` - the message as an HttpEntity.
      Returns:
        http headers if required.