amber.server.manager.handler
Class BaseHandler

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--amber.server.manager.handler.BaseHandler
All Implemented Interfaces:
HandlerInterface, java.lang.Runnable
Direct Known Subclasses:
Application, Browser

public abstract class BaseHandler
extends java.lang.Thread
implements HandlerInterface

This class is a base class extended by the other handler classes. It contains simple support components which are useful to the other handlers.

Version:
1.0.0
Author:
Dr. David J. Knowles
See Also:
Core, HandlerInterface

Field Summary
protected  AmberInputStream dataDecoder
           
protected  AmberOutputStream dataEncoder
           
protected  java.io.ByteArrayOutputStream encoderBytes
          The data encoding data stream that is used by all components to send information.
protected  Packet initPacket
           
protected  Log loggingFile
          Primary logging object.
protected  Core mainServer
          Handle to the Core server.
protected  java.net.Socket socket
          Internal data holders set up by the connectToClient function.
protected  int type
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
BaseHandler()
           
 
Method Summary
 void connectToClient(java.net.Socket socket, Packet initPacket, AmberInputStream dataDecoder, int type)
          This function handles the connection requirements for the specified incoming connection.
 void sendPacket(java.net.Socket socket, Packet packet)
          Sends the specified packet to the defined socket connection.
 void setCore(Core core)
          This sets the parent Core object.
 void setLogger(Log logger)
          This sets the primary logging object.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, 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
 

Field Detail

mainServer

protected Core mainServer
Handle to the Core server.

socket

protected java.net.Socket socket
Internal data holders set up by the connectToClient function.

initPacket

protected Packet initPacket

dataDecoder

protected AmberInputStream dataDecoder

type

protected int type

loggingFile

protected Log loggingFile
Primary logging object.

encoderBytes

protected java.io.ByteArrayOutputStream encoderBytes
The data encoding data stream that is used by all components to send information. THIS MUST BE USED FOR ENCODING INFORMATION TO THE CLIENT!! Owing to the way Java works it is not meaningful to have a corresponding input object statically created.

dataEncoder

protected AmberOutputStream dataEncoder
Constructor Detail

BaseHandler

public BaseHandler()
Method Detail

setCore

public void setCore(Core core)
This sets the parent Core object.
Specified by:
setCore in interface HandlerInterface
Parameters:
core - Core system.

setLogger

public void setLogger(Log logger)
This sets the primary logging object.
Specified by:
setLogger in interface HandlerInterface
Parameters:
logger - Log primary logger.

sendPacket

public void sendPacket(java.net.Socket socket,
                       Packet packet)
Sends the specified packet to the defined socket connection.
Parameters:
socket - Socket to send the packet to.
packet - Packet containing the packet to send.

connectToClient

public void connectToClient(java.net.Socket socket,
                            Packet initPacket,
                            AmberInputStream dataDecoder,
                            int type)
                     throws java.io.IOException
This function handles the connection requirements for the specified incoming connection. In this case the connection is from a Browser based system.
Specified by:
connectToClient in interface HandlerInterface
Parameters:
socket - Socket of the incoming connection.
initPacket - The Packet which is first sent by the page when the connection is opened.
dataDecoder - AmberInputStream with the packet parameters.
type - The type of connection that is attempting to match the packet. This matches the constants in ListenerThread.
Throws:
java.io.IOException - containing decoding errors.


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.