oemware.core.net
Class DatagramServer

java.lang.Object
  extended by java.lang.Thread
      extended by oemware.core.ThreadBase
          extended by oemware.core.net.DatagramServer
All Implemented Interfaces:
java.lang.Runnable

public class DatagramServer
extends ThreadBase

The generic datagram server. The contract is that you must call the startup/shutdown methods.

Version:
$Id: DatagramServer.java 37 2008-07-20 20:27:15Z oemware $

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  java.lang.String mBindAddress
           
protected  int mPort
           
 
Fields inherited from class oemware.core.ThreadBase
mJoinThread, mJoinTimeout, mRunning
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
DatagramServer(DatagramMessageHandler pHandler, DatagramMessageFilter pFilter, int pBufferSize)
          Construct a new server with the params.
DatagramServer(DatagramMessageHandler pHandler, DatagramMessageFilter pFilter, int pBufferSize, int pBufferOffset)
          Construct a new server with the params.
DatagramServer(DatagramMessageHandler pHandler, DatagramMessageFilter pFilter, ServiceConf pServiceConf, int pBufferSize, int pBufferOffset, java.lang.String pBindAddressParamName, java.lang.String pPortParamName, boolean pAppendInstanceId)
          Construct a new server with the params.
DatagramServer(DatagramMessageHandler pHandler, ServiceConf pServiceConf, int pBufferSize, int pBufferOffset, java.lang.String pBindAddressParamName, java.lang.String pPortParamName, boolean pAppendInstanceId)
          Construct a new server with the params.
 
Method Summary
 void beforeStart()
          Bind to the port.
 java.lang.String getBindAddress()
           
 int getBufferSize()
           
 int getPort()
           
 void run()
          This must be implemented for the thread to work.
 void setBindAddress(java.lang.String pBindAddress)
           
 void shutdown()
          Called to shutdown the datagram server :-^
 
Methods inherited from class oemware.core.ThreadBase
afterStart, afterStop, beforeStop, getJoinThread, getJoinTimeout, isRunning, setJoinThread, setJoinTimeout, startup
 
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
 

Field Detail

mBindAddress

protected java.lang.String mBindAddress

mPort

protected int mPort
Constructor Detail

DatagramServer

public DatagramServer(DatagramMessageHandler pHandler,
                      DatagramMessageFilter pFilter,
                      int pBufferSize,
                      int pBufferOffset)
               throws ServiceException
Construct a new server with the params.

Parameters:
pHandler - The message handler.
pFilter - The message filter.
pBufferSize - The message buffer size.
pBufferOffset - The buffer offset.
Throws:
ServiceException

DatagramServer

public DatagramServer(DatagramMessageHandler pHandler,
                      ServiceConf pServiceConf,
                      int pBufferSize,
                      int pBufferOffset,
                      java.lang.String pBindAddressParamName,
                      java.lang.String pPortParamName,
                      boolean pAppendInstanceId)
               throws ServiceException
Construct a new server with the params.

Parameters:
pHandler - The message handler.
pServiceConf - The service configuration object.
pBufferSize - The message buffer size.
pBufferOffset - The buffer offset.
pBindAddressParamName - The key in the config.
pPortParamName - The key in the config.
pAppendInstanceId - If true the instance id is appended to the port number provided.
Throws:
ServiceException

DatagramServer

public DatagramServer(DatagramMessageHandler pHandler,
                      DatagramMessageFilter pFilter,
                      ServiceConf pServiceConf,
                      int pBufferSize,
                      int pBufferOffset,
                      java.lang.String pBindAddressParamName,
                      java.lang.String pPortParamName,
                      boolean pAppendInstanceId)
               throws ServiceException
Construct a new server with the params.

Parameters:
pHandler - The message handler.
pFilter - The message filter.
pServiceConf - The service configuration object.
pBufferSize - The message buffer size.
pBufferOffset - The buffer offset.
pBindAddressParamName - The key in the config.
pPortParamName - The key in the config.
pAppendInstanceId - If true the instance id is appended to the port number provided.
Throws:
ServiceException

DatagramServer

public DatagramServer(DatagramMessageHandler pHandler,
                      DatagramMessageFilter pFilter,
                      int pBufferSize)
               throws ServiceException
Construct a new server with the params.

Parameters:
pHandler - The message handler.
pBufferSize - The message buffer size.
Throws:
ServiceException
Method Detail

beforeStart

public final void beforeStart()
                       throws ServiceException
Bind to the port.

Overrides:
beforeStart in class ThreadBase
Throws:
ServiceException

shutdown

public void shutdown()
              throws ServiceException
Called to shutdown the datagram server :-^

Overrides:
shutdown in class ThreadBase
Throws:
ServiceException

getBindAddress

public final java.lang.String getBindAddress()

setBindAddress

public final void setBindAddress(java.lang.String pBindAddress)

getPort

public final int getPort()

getBufferSize

public final int getBufferSize()

run

public final void run()
Description copied from class: ThreadBase
This must be implemented for the thread to work.

Specified by:
run in interface java.lang.Runnable
Specified by:
run in class ThreadBase


Copyright © 2008 Deft Labs - Released under LGPL, Version 3.0