QuickServer
v1.4.7

org.quickserver.net.server.impl
Class BlockingClientHandler

java.lang.Object
  extended byorg.quickserver.net.server.impl.BasicClientHandler
      extended byorg.quickserver.net.server.impl.BlockingClientHandler
All Implemented Interfaces:
ClientHandler, java.lang.Runnable

public class BlockingClientHandler
extends BasicClientHandler


Field Summary
 
Fields inherited from class org.quickserver.net.server.impl.BasicClientHandler
appLogger, authenticator, authorised, b_in, b_out, bufferedReader, charset, clientAuthenticationHandler, clientBinaryHandler, clientCommandHandler, clientConnectedTime, clientData, clientEventHandler, clientEvents, clientExtendedEventHandler, clientObjectHandler, closeOrLostNotified, communicationLogging, connection, counAuthTry, dataModeIN, dataModeOUT, in, lastCommunicationTime, lockObj, lost, maxAuthTry, maxAuthTryMsg, maxConnectionMsg, NEW_LINE, NEW_LINE_BYTES, o_in, o_out, out, quickServer, secure, socket, socketTimeout, threadEvent, timeoutMsg, unprocessedClientEvents, willClean
 
Constructor Summary
BlockingClientHandler()
           
BlockingClientHandler(int instanceCount)
           
 
Method Summary
protected  boolean checkReturnClientHandler()
           
 void clean()
           
 void closeConnection()
          Closes client socket associated.
protected  void finalize()
           
 java.io.BufferedReader getBufferedReader()
          Returns the BufferedReader associated with the Client being handled.
 java.nio.channels.SelectionKey getSelectionKey()
          Returns client SelectionKey associated, if any.
 java.nio.channels.SocketChannel getSocketChannel()
          Returns client socket channel associated, if any.
 void handleClient(TheClient theClient)
          Associates the ClientHanlder with the client encapsulated by theClient.
protected  byte[] readInputStream()
          Read the byte input.
 void registerForRead()
          Register OP_READ with the SelectionKey associated with the channel.
 void registerForWrite()
          Register OP_WRITE with the SelectionKey associated with the channel.
protected  void returnClientHandler()
           
 void run()
           
protected  void setClientWriteHandler(ClientWriteHandler handler)
          Sets the ClientWriteHandler class that interacts with client sockets.
 void setDataMode(DataMode dataMode, DataType dataType)
          Sets the DataMode for the ClientHandler Note: When mode is DataMode.OBJECT and type is DataType.IN this call will block until the client ObjectOutputStream has written and flushes the header.
protected  void setInputStream(java.io.InputStream in)
          Sets the InputStream associated with the Client being handled.
 void setSelectionKey(java.nio.channels.SelectionKey selectionKey)
          Sets client SelectionKey associated, if any.
 void setSocketChannel(java.nio.channels.SocketChannel socketChannel)
          Sets client socket channel associated, if any.
 void updateInputOutputStreams()
          Updates the InputStream and OutputStream for the ClientHandler for the set Socket.
 
Methods inherited from class org.quickserver.net.server.impl.BasicClientHandler
addEvent, assertionSystemExit, checkDataModeSet, forceClose, getAppLogger, getBufferedInputStream, getBufferedOutputStream, getBufferedWriter, getCharset, getClientConnectedTime, getClientData, getClientIdentifiable, getCommunicationLogging, getConnection, getDataMode, getHostAddress, getInputStream, getInstanceCount, getLastCommunicationTime, getMaxConnectionMsg, getName, getObjectInputStream, getObjectOutputStream, getOutputStream, getServer, getSocket, getThreadEvent, getTimeout, getWillClean, handleTimeout, hasEvent, info, isClientEventNext, isClosed, isConected, isConnected, isOpen, isSecure, makeSecure, makeSecure, makeSecure, notifyCloseOrLost, prepareForRun, processAuthorisation, processMaxConnection, readBinary, readBytes, readInputStream, removeEvent, returnClientData, sendClientBinary, sendClientBinary, sendClientBytes, sendClientMsg, sendClientObject, sendSystemMsg, sendSystemMsg, sendSystemMsg, setAuthenticator, setCharset, setClientAuthenticationHandler, setClientBinaryHandler, setClientCommandHandler, setClientData, setClientEventHandler, setClientExtendedEventHandler, setClientObjectHandler, setCommunicationLogging, setMaxConnectionMsg, setOutputStream, setSecure, setServer, setSocket, setTimeout, toString, updateLastCommunicationTime
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BlockingClientHandler

public BlockingClientHandler(int instanceCount)

BlockingClientHandler

public BlockingClientHandler()
Method Detail

clean

public void clean()
Specified by:
clean in interface ClientHandler
Overrides:
clean in class BasicClientHandler

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class BasicClientHandler
Throws:
java.lang.Throwable

handleClient

public void handleClient(TheClient theClient)
Description copied from class: BasicClientHandler
Associates the ClientHanlder with the client encapsulated by theClient.

Specified by:
handleClient in interface ClientHandler
Overrides:
handleClient in class BasicClientHandler
Parameters:
theClient - object that encapsulates client socket and its configuration details.

setInputStream

protected void setInputStream(java.io.InputStream in)
                       throws java.io.IOException
Description copied from class: BasicClientHandler
Sets the InputStream associated with the Client being handled.

Specified by:
setInputStream in class BasicClientHandler
Throws:
java.io.IOException
See Also:
BasicClientHandler.getInputStream()

getBufferedReader

public java.io.BufferedReader getBufferedReader()
Description copied from class: BasicClientHandler
Returns the BufferedReader associated with the Client being handled. Note that this is only available under blocking mode.

Specified by:
getBufferedReader in interface ClientHandler
Specified by:
getBufferedReader in class BasicClientHandler
See Also:
BasicClientHandler.getBufferedWriter()

closeConnection

public void closeConnection()
Description copied from class: BasicClientHandler
Closes client socket associated.

Specified by:
closeConnection in interface ClientHandler
Specified by:
closeConnection in class BasicClientHandler

run

public void run()
Specified by:
run in interface ClientHandler
Specified by:
run in class BasicClientHandler

checkReturnClientHandler

protected boolean checkReturnClientHandler()

returnClientHandler

protected void returnClientHandler()
Overrides:
returnClientHandler in class BasicClientHandler

setDataMode

public void setDataMode(DataMode dataMode,
                        DataType dataType)
                 throws java.io.IOException
Description copied from class: BasicClientHandler
Sets the DataMode for the ClientHandler Note: When mode is DataMode.OBJECT and type is DataType.IN this call will block until the client ObjectOutputStream has written and flushes the header.

Specified by:
setDataMode in interface ClientHandler
Specified by:
setDataMode in class BasicClientHandler
Parameters:
dataMode - mode of data exchange - String or Object.
dataType - type of data for which mode has to be set.
Throws:
java.io.IOException - if mode could not be changed.

readInputStream

protected byte[] readInputStream()
                          throws java.io.IOException
Description copied from class: BasicClientHandler
Read the byte input. This will block till some data is received from the stream.

Specified by:
readInputStream in class BasicClientHandler
Returns:
The data as a String
Throws:
java.io.IOException

updateInputOutputStreams

public void updateInputOutputStreams()
                              throws java.io.IOException
Description copied from class: BasicClientHandler
Updates the InputStream and OutputStream for the ClientHandler for the set Socket.

Specified by:
updateInputOutputStreams in interface ClientHandler
Specified by:
updateInputOutputStreams in class BasicClientHandler
Throws:
java.io.IOException
See Also:
BasicClientHandler.setSocket(java.net.Socket)

setSocketChannel

public void setSocketChannel(java.nio.channels.SocketChannel socketChannel)
Description copied from class: BasicClientHandler
Sets client socket channel associated, if any.

Specified by:
setSocketChannel in interface ClientHandler
Specified by:
setSocketChannel in class BasicClientHandler

getSocketChannel

public java.nio.channels.SocketChannel getSocketChannel()
Description copied from class: BasicClientHandler
Returns client socket channel associated, if any.

Specified by:
getSocketChannel in interface ClientHandler
Specified by:
getSocketChannel in class BasicClientHandler

setSelectionKey

public void setSelectionKey(java.nio.channels.SelectionKey selectionKey)
Description copied from class: BasicClientHandler
Sets client SelectionKey associated, if any.

Specified by:
setSelectionKey in interface ClientHandler
Specified by:
setSelectionKey in class BasicClientHandler

getSelectionKey

public java.nio.channels.SelectionKey getSelectionKey()
Description copied from class: BasicClientHandler
Returns client SelectionKey associated, if any.

Specified by:
getSelectionKey in interface ClientHandler
Specified by:
getSelectionKey in class BasicClientHandler

registerForRead

public void registerForRead()
                     throws java.io.IOException,
                            java.nio.channels.ClosedChannelException
Description copied from class: BasicClientHandler
Register OP_READ with the SelectionKey associated with the channel. If SelectionKey is not set then it registers the channel with the Selector.

Specified by:
registerForRead in interface ClientHandler
Specified by:
registerForRead in class BasicClientHandler
Throws:
java.io.IOException
java.nio.channels.ClosedChannelException

registerForWrite

public void registerForWrite()
                      throws java.io.IOException,
                             java.nio.channels.ClosedChannelException
Description copied from class: BasicClientHandler
Register OP_WRITE with the SelectionKey associated with the channel.

Specified by:
registerForWrite in interface ClientHandler
Specified by:
registerForWrite in class BasicClientHandler
Throws:
java.io.IOException
java.nio.channels.ClosedChannelException

setClientWriteHandler

protected void setClientWriteHandler(ClientWriteHandler handler)
Description copied from class: BasicClientHandler
Sets the ClientWriteHandler class that interacts with client sockets.

Specified by:
setClientWriteHandler in class BasicClientHandler
Parameters:
handler - fully qualified name of the class that implements ClientWriteHandler

QuickServer
v1.4.7

Copyright © 2003-2006 QuickServer.org