tigase.net
Class IOService<RefObject>

java.lang.Object
  extended by tigase.net.IOService<RefObject>
Type Parameters:
RefObject - is a refrence 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>
Direct Known Subclasses:
XMPPIOService

public abstract class IOService<RefObject>
extends Object
implements Callable<IOService>

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

If you directly implement ServerService interface you must take care about SocketChannel I/O, queueing 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$
Author:
Artur Hefczyc

Field Summary
 long empty_read_call_count
          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 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()
          Method description
 ConcurrentMap<String,Object> getSessionData()
          Method description
 SocketChannel getSocketChannel()
          Method getSocketChannel is used to perform
 void getStatistics(StatisticsList list)
          Method description
 String getUniqueId()
          Method description
 long[] getWriteCounters()
          Method description
 boolean isConnected()
          Describe isConnected method here.
protected abstract  void processSocketData()
           
abstract  void processWaitingPackets()
          Method description
protected  void readCompleted()
           
protected  char[] readData()
          Describe readData method here.
protected abstract  int receivedPackets()
           
 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 setSSLId(String id)
          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 waitingToSend()
          Method description
 int waitingToSendSize()
          Method description
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

empty_read_call_count

public long empty_read_call_count
Field description

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()
Method description

Returns:

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)
Method description

Parameters:
list -

getUniqueId

public String getUniqueId()
Method description

Returns:

getWriteCounters

public long[] getWriteCounters()
Method description

Returns:

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 -

setSSLId

public void setSSLId(String id)
Method description

Parameters:
id -

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:

waitingToSend

public boolean waitingToSend()
Method description

Returns:

waitingToSendSize

public int waitingToSendSize()
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

writeData

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

Parameters:
data - a String value


Copyright © 2001-2006 Tigase Developers Team. All rights Reserved.