tigase.net
Class IOService<RefObject>

java.lang.Object
  extended by tigase.net.IOService<RefObject>
Type Parameters:
RefObject - is a reference object stored by this service. This is e reference to higher level data object keeping more information about the connection.
All Implemented Interfaces:
Callable<IOService<?>>, TLSEventHandler
Direct Known Subclasses:
XMPPIOService

public abstract class IOService<RefObject>
extends Object
implements Callable<IOService<?>>, TLSEventHandler

IOService offers thread safe call() method execution, however you must be prepared that other methods can be called simultaneously like stop(), getProtocol() or isConnected().
It is recommended that developers extend AbsractServerService rather then implement ServerService interface directly.

If you directly implement ServerService interface you must take care about SocketChannel I/O, queuing tasks, processing results and thread safe execution of call() method. If you however extend IOService class all this basic operation are implemented and you have only to take care about parsing data received from network socket. Parsing data is expected to be implemented in parseData(char[] data) method.

Created: Tue Sep 28 23:00:34 2004

Version:
$Rev: 2996 $
Author:
Artur Hefczyc

Field Summary
static String CERT_CHECK_RESULT
          Field description
static String HOSTNAME_KEY
          Field description
static String PORT_TYPE_PROP_KEY
          Field description
static String SESSION_ID_KEY
          This is key used to store session ID in temporary session data storage.
 
Constructor Summary
IOService()
           
 
Method Summary
 void accept(SocketChannel socketChannel)
          Method accept is used to perform
 IOService<?> call()
          Method run is used to perform
 ConnectionType connectionType()
          Method description
protected  boolean debug(char[] msg)
          Describe debug method here.
protected  boolean debug(String msg, String prefix)
          Describe debug method here.
 void forceStop()
          Method description
 tigase.xmpp.JID getConnectionId()
           
 tigase.xmpp.JID getDataReceiver()
          Method description
 long getLastTransferTime()
          This method returns the time of last transfer in any direction through this service.
 String getLocalAddress()
          Method description
 long[] getReadCounters()
          Method description
 RefObject getRefObject()
          Method description
 String getRemoteAddress()
          Returns a remote IP address for the TCP/IP connection.
 ConcurrentMap<String,Object> getSessionData()
          Method description
 SocketChannel getSocketChannel()
          Method getSocketChannel is used to perform
 void getStatistics(StatisticsList list, boolean reset)
          Method description
 String getUniqueId()
          Method description
 long[] getWriteCounters()
          Method description
 void handshakeCompleted(TLSWrapper wrapper)
          Method description
 boolean isConnected()
          Describe isConnected method here.
protected  boolean isInputBufferEmpty()
          Method description
protected abstract  void processSocketData()
           
abstract  void processWaitingPackets()
          Method description
protected  ByteBuffer readBytes()
           
protected  void readCompleted()
           
protected  char[] readData()
          Describe readData method here.
protected abstract  int receivedPackets()
           
 void setConnectionId(tigase.xmpp.JID connectionId)
           
 void setDataReceiver(tigase.xmpp.JID address)
          Method description
 void setIOServiceListener(IOServiceListener<IOService<RefObject>> sl)
          Method description
 void setRefObject(RefObject refObject)
          Method description
 void setSessionData(Map<String,Object> props)
          Method description
 void startSSL(boolean clientMode)
          Method description
 void startTLS(boolean clientMode)
          Method description
 void startZLib(int level)
          Method description
 void stop()
          Describe stop method here.
 String toString()
          Method description
 boolean waitingToRead()
          Method description
 boolean waitingToSend()
          Method description
 int waitingToSendSize()
          Method description
protected  void writeBytes(ByteBuffer data)
           
protected  void writeData(String data)
          Describe writeData method here.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SESSION_ID_KEY

public static final String SESSION_ID_KEY
This is key used to store session ID in temporary session data storage. As it is used by many components it is required that all components access session ID with this constant.

See Also:
Constant Field Values

PORT_TYPE_PROP_KEY

public static final String PORT_TYPE_PROP_KEY
Field description

See Also:
Constant Field Values

HOSTNAME_KEY

public static final String HOSTNAME_KEY
Field description

See Also:
Constant Field Values

CERT_CHECK_RESULT

public static final String CERT_CHECK_RESULT
Field description

See Also:
Constant Field Values
Constructor Detail

IOService

public IOService()
Method Detail

processWaitingPackets

public abstract void processWaitingPackets()
                                    throws IOException
Method description

Throws:
IOException

processSocketData

protected abstract void processSocketData()
                                   throws IOException
Throws:
IOException

receivedPackets

protected abstract int receivedPackets()

accept

public void accept(SocketChannel socketChannel)
            throws IOException
Method accept is used to perform

Parameters:
socketChannel - a SocketChannel value
Throws:
IOException

call

public IOService<?> call()
                  throws IOException
Method run is used to perform

Specified by:
call in interface Callable<IOService<?>>
Returns:
Throws:
IOException

connectionType

public ConnectionType connectionType()
Method description

Returns:

forceStop

public void forceStop()
Method description


getDataReceiver

public tigase.xmpp.JID getDataReceiver()
Method description

Returns:

getLastTransferTime

public long getLastTransferTime()
This method returns the time of last transfer in any direction through this service. It is used to help detect dead connections.

Returns:

getLocalAddress

public String getLocalAddress()
Method description

Returns:

getReadCounters

public long[] getReadCounters()
Method description

Returns:

getRefObject

public RefObject getRefObject()
Method description

Returns:

getRemoteAddress

public String getRemoteAddress()
Returns a remote IP address for the TCP/IP connection.

Returns:
a remote IP address for the TCP/IP connection.

getSessionData

public ConcurrentMap<String,Object> getSessionData()
Method description

Returns:

getSocketChannel

public SocketChannel getSocketChannel()
Method getSocketChannel is used to perform

Returns:
a SocketChannel value

getStatistics

public void getStatistics(StatisticsList list,
                          boolean reset)
Method description

Parameters:
list -
reset -

getUniqueId

public String getUniqueId()
Method description

Returns:

getWriteCounters

public long[] getWriteCounters()
Method description

Returns:

handshakeCompleted

public void handshakeCompleted(TLSWrapper wrapper)
Method description

Specified by:
handshakeCompleted in interface TLSEventHandler
Parameters:
wrapper -

isConnected

public boolean isConnected()
Describe isConnected method here.

Returns:
a boolean value

setDataReceiver

public void setDataReceiver(tigase.xmpp.JID address)
Method description

Parameters:
address -

setIOServiceListener

public void setIOServiceListener(IOServiceListener<IOService<RefObject>> sl)
Method description

Parameters:
sl -

setRefObject

public void setRefObject(RefObject refObject)
Method description

Parameters:
refObject -

setSessionData

public void setSessionData(Map<String,Object> props)
Method description

Parameters:
props -

startSSL

public void startSSL(boolean clientMode)
              throws IOException
Method description

Parameters:
clientMode -
Throws:
IOException

startTLS

public void startTLS(boolean clientMode)
              throws IOException
Method description

Parameters:
clientMode -
Throws:
IOException

startZLib

public void startZLib(int level)
Method description

Parameters:
level -

stop

public void stop()
Describe stop method here.


toString

public String toString()
Method description

Overrides:
toString in class Object
Returns:

waitingToRead

public boolean waitingToRead()
Method description

Returns:

waitingToSend

public boolean waitingToSend()
Method description

Returns:

waitingToSendSize

public int waitingToSendSize()
Method description

Returns:

isInputBufferEmpty

protected boolean isInputBufferEmpty()
Method description

Returns:

debug

protected boolean debug(char[] msg)
Describe debug method here.

Parameters:
msg - a char[] value
Returns:
a boolean value

debug

protected boolean debug(String msg,
                        String prefix)
Describe debug method here.

Parameters:
msg - a String value
Returns:
a boolean value

readCompleted

protected void readCompleted()

readData

protected char[] readData()
                   throws IOException
Describe readData method here.

Returns:
a char[] value
Throws:
IOException - if an error occurs

readBytes

protected ByteBuffer readBytes()
                        throws IOException
Throws:
IOException

writeData

protected void writeData(String data)
Describe writeData method here.

Parameters:
data - a String value

writeBytes

protected void writeBytes(ByteBuffer data)

getConnectionId

public tigase.xmpp.JID getConnectionId()
Returns:
the connectionId

setConnectionId

public void setConnectionId(tigase.xmpp.JID connectionId)
Parameters:
connectionId - the connectionId to set


Copyright © 2012 Tigase. All Rights Reserved.