infoservice.mailsystem.central.server
Class AbstractServerImplementation

java.lang.Object
  extended by infoservice.mailsystem.central.server.AbstractServerImplementation
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
MailSystemServerImplementation

public abstract class AbstractServerImplementation
extends java.lang.Object
implements java.lang.Runnable

This is a generic implementation for handling client requests which have reached the server.


Field Summary
private  boolean m_alreadyInUse
          Stores whether this AbstractServerImplementation is already in use.
private  SocketContainer m_socketContainer
          Stores the SocketContainer which includes the Socket connected to the client and maybe some alternative datastreams.
private  java.lang.Object m_synchronizer
          This object is used for synchronization purposes to prevent using this server implementation more than once.
 
Constructor Summary
protected AbstractServerImplementation()
          Creates a new AbstractServerImplementation.
 
Method Summary
protected  SocketContainer getSocketContainer()
          Returns the SocketContainer with the connection to the client.
protected abstract  void handleClientRequest()
          This method must be implemented by the children of this class.
 void run()
          This is the generic implementation for handling the connection.
 void setClientConnection(SocketContainer a_socketContainer)
          This will set the SocketContainer with the connection to the client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_socketContainer

private SocketContainer m_socketContainer
Stores the SocketContainer which includes the Socket connected to the client and maybe some alternative datastreams.


m_alreadyInUse

private boolean m_alreadyInUse
Stores whether this AbstractServerImplementation is already in use.


m_synchronizer

private java.lang.Object m_synchronizer
This object is used for synchronization purposes to prevent using this server implementation more than once.

Constructor Detail

AbstractServerImplementation

protected AbstractServerImplementation()
Creates a new AbstractServerImplementation. This constructor is called automatically from the children of this class. Only some initialization is done here.

Method Detail

setClientConnection

public final void setClientConnection(SocketContainer a_socketContainer)
This will set the SocketContainer with the connection to the client. This method must only be called from the ConnectionHandle class. It is called once before the handling-thread calls the run() method.

Parameters:
a_socketContainer - The SocketContainer with the connection to the client.

run

public final void run()
This is the generic implementation for handling the connection. It will check, whether everything is defined correctly and will then start the specific server implementation of the children of this class by calling the handleClientRequest() method.

Specified by:
run in interface java.lang.Runnable

getSocketContainer

protected final SocketContainer getSocketContainer()
Returns the SocketContainer with the connection to the client. This method can be called by children of this class, if they need access to the client connection.

Returns:
The SocketContainer with the connection to the client.

handleClientRequest

protected abstract void handleClientRequest()
This method must be implemented by the children of this class. The request handling must be done here. It's called automatically by the request-handling thread. After it has finished this method, the connection to the client is closed automatically.