tigase.net

## Class IOService<RefObject>

- java.lang.Object
- - 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, IOListener
  Direct Known Subclasses:
    XMPPIOService

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

  `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$
  Author:
    Artur Hefczyc

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected CharBuffer` | `cb` Field description
    `static String` | `CERT_CHECK_RESULT` Field description
    `static String` | `CERT_REQUIRED_DOMAIN` Field description
    `protected CharsetDecoder` | `decoder` Field description
    `protected CharsetEncoder` | `encoder` Field description
    `static String` | `HOSTNAME_KEY` Field description
    `protected byte[]` | `partialCharacterBytes` The saved partial bytes for multi-byte UTF-8 characters between reads
    `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.
    `static String` | `SSL_PROTOCOLS_KEY` Field description

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `IOService()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `accept(SocketChannel socketChannel)` Method `accept` is used to perform
    `protected ByteOrder` | `byteOrder()` Method description
    `IOService<?>` | `call()`
    `boolean` | `checkBufferLimit(int bufferSize)`
    `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
    `long` | `getBuffOverflow(boolean reset)` Method description
    `long` | `getBytesReceived(boolean reset)` Method description
    `long` | `getBytesSent(boolean reset)` Method description
    `JID` | `getConnectionId()`
    `JID` | `getDataReceiver()` Method description
    `long` | `getLastTransferTime()` This method returns the time of last transfer in any direction through this service.
    `String` | `getLocalAddress()` Method description
    `Certificate` | `getLocalCertificate()`
    `int` | `getLocalPort()` Method returns local port of opened socket
    `Certificate` | `getPeerCertificate()`
    `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
    `int` | `getSocketInputSize()`
    `void` | `getStatistics(StatisticsList list, boolean reset)` Method description
    `byte[]` | `getTlsUniqueId()`
    `long` | `getTotalBuffOverflow()` Method description
    `long` | `getTotalBytesReceived()` Method description
    `long` | `getTotalBytesSent()` Method description
    `String` | `getUniqueId()` Method description
    `long[]` | `getWriteCounters()` Method description
    `TrustManager[]` | `getX509TrustManagers()` Method description
    `void` | `handshakeCompleted(TLSWrapper wrapper)`
    `boolean` | `isConnected()` Describe `isConnected` method here.
    `protected boolean` | `isInputBufferEmpty()` Method description
    `protected boolean` | `isSocketServiceReady()`
    `protected abstract void` | `processSocketData()` Method description
    `abstract void` | `processWaitingPackets()` Method description
    `protected ByteBuffer` | `readBytes()` Method description
    `protected void` | `readCompleted()` Method description
    `protected char[]` | `readData()` Describe `readData` method here.
    `protected abstract int` | `receivedPackets()` Method description
    `void` | `setBufferLimit(int bufferLimit)`
    `void` | `setConnectionId(JID connectionId)`
    `void` | `setDataReceiver(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
    `protected void` | `setSocketServiceReady(boolean value)`
    `void` | `setX509TrustManagers(TrustManager[] trustManager)` Method description
    `void` | `startSSL(boolean clientMode, boolean wantClientAuth, boolean needClientAuth)` Method description
    `void` | `startTLS(boolean clientMode, boolean wantClientAuth, boolean needClientAuth)` Method description
    `void` | `startZLib(int level)` Method description
    `void` | `stop()` Describe `stop` method here.
    `String` | `toString()`
    `boolean` | `waitingToRead()` Method description
    `boolean` | `waitingToSend()` Method description
    `int` | `waitingToSendSize()` Method description
    `protected void` | `writeBytes(ByteBuffer data)` 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

    - #### CERT_CHECK_RESULT

          public static final String CERT_CHECK_RESULT

      Field description
      See Also:
        Constant Field Values

    - #### CERT_REQUIRED_DOMAIN

          public static final String CERT_REQUIRED_DOMAIN

      Field description
      See Also:
        Constant Field Values

    - #### HOSTNAME_KEY

          public static final String HOSTNAME_KEY

      Field description
      See Also:
        Constant Field Values

    - #### PORT_TYPE_PROP_KEY

          public static final String PORT_TYPE_PROP_KEY

      Field description
      See Also:
        Constant Field Values

    - #### 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

    - #### SSL_PROTOCOLS_KEY

          public static final String SSL_PROTOCOLS_KEY

      Field description
      See Also:
        Constant Field Values

    - #### partialCharacterBytes

          protected byte[] partialCharacterBytes

      The saved partial bytes for multi-byte UTF-8 characters between reads

    - #### encoder

          protected CharsetEncoder encoder

      Field description

    - #### decoder

          protected CharsetDecoder decoder

      Field description

    - #### cb

          protected CharBuffer cb

      Field description

  - ### Constructor Detail

    - #### IOService

          public IOService()

  - ### Method Detail

    - #### 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

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

    - #### checkBufferLimit

          public boolean checkBufferLimit(int bufferSize)

      Specified by:
        `checkBufferLimit` in interface `IOListener`

    - #### connectionType

          public ConnectionType connectionType()

      Method description

    - #### forceStop

          public void forceStop()

      Method description

    - #### handshakeCompleted

          public void handshakeCompleted(TLSWrapper wrapper)

      Specified by:
        `handshakeCompleted` in interface `TLSEventHandler`

    - #### processWaitingPackets

          public abstract void processWaitingPackets()
                                              throws IOException

      Method description
      Throws:
        `IOException`

    - #### startSSL

          public void startSSL(boolean clientMode,
                               boolean wantClientAuth,
                               boolean needClientAuth)
                        throws IOException

      Method description
      Parameters:
        `clientMode` -
      Throws:
        `IOException`

    - #### startTLS

          public void startTLS(boolean clientMode,
                               boolean wantClientAuth,
                               boolean needClientAuth)
                        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()

      Overrides:
        `toString` in class `Object`

    - #### waitingToRead

          public boolean waitingToRead()

      Method description

    - #### waitingToSend

          public boolean waitingToSend()

      Method description

    - #### waitingToSendSize

          public int waitingToSendSize()

      Method description

    - #### getBuffOverflow

          public long getBuffOverflow(boolean reset)

      Method description
      Parameters:
        `reset` -

    - #### getBytesReceived

          public long getBytesReceived(boolean reset)

      Method description
      Parameters:
        `reset` -

    - #### getBytesSent

          public long getBytesSent(boolean reset)

      Method description
      Parameters:
        `reset` -

    - #### getConnectionId

          public JID getConnectionId()

      Returns:
        the connectionId

    - #### getDataReceiver

          public JID getDataReceiver()

      Method description

    - #### 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.

    - #### getLocalAddress

          public String getLocalAddress()

      Method description

    - #### getTlsUniqueId

          public byte[] getTlsUniqueId()

    - #### getLocalPort

          public int getLocalPort()

      Method returns local port of opened socket
      Returns:

    - #### getReadCounters

          public long[] getReadCounters()

      Method description

    - #### getRefObject

          public RefObject getRefObject()

      Method description

    - #### 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

    - #### getSocketInputSize

          public int getSocketInputSize()

      Specified by:
        `getSocketInputSize` in interface `TLSEventHandler`

    - #### 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` -

    - #### getTotalBuffOverflow

          public long getTotalBuffOverflow()

      Method description

    - #### getTotalBytesReceived

          public long getTotalBytesReceived()

      Method description

    - #### getTotalBytesSent

          public long getTotalBytesSent()

      Method description

    - #### getUniqueId

          public String getUniqueId()

      Method description

    - #### getWriteCounters

          public long[] getWriteCounters()

      Method description

    - #### getX509TrustManagers

          public TrustManager[] getX509TrustManagers()

      Method description

    - #### isConnected

          public boolean isConnected()

      Describe `isConnected` method here.
      Returns:
        a `boolean` value

    - #### setBufferLimit

          public void setBufferLimit(int bufferLimit)

    - #### setConnectionId

          public void setConnectionId(JID connectionId)

      Parameters:
        `connectionId` - the connectionId to set

    - #### setDataReceiver

          public void setDataReceiver(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` -

    - #### setX509TrustManagers

          public void setX509TrustManagers(TrustManager[] trustManager)

      Method description
      Parameters:
        `trustManager` -

    - #### byteOrder

          protected ByteOrder byteOrder()

      Method description

    - #### 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
        `prefix` -
      Returns:
        a `boolean` value

    - #### processSocketData

          protected abstract void processSocketData()
                                             throws IOException

      Method description
      Throws:
        `IOException`

    - #### readBytes

          protected ByteBuffer readBytes()
                                  throws IOException

      Method description
      Throws:
        `IOException`

    - #### readCompleted

          protected void readCompleted()

      Method description

    - #### readData

          protected char[] readData()
                             throws IOException

      Describe `readData` method here.
      Returns:
        a `char[]` value
      Throws:
        `IOException` - if an error occurs

    - #### receivedPackets

          protected abstract int receivedPackets()

      Method description

    - #### writeBytes

          protected void writeBytes(ByteBuffer data)

      Method description
      Parameters:
        `data` -

    - #### writeData

          protected void writeData(String data)

      Describe `writeData` method here.
      Parameters:
        `data` - a `String` value

    - #### isSocketServiceReady

          protected boolean isSocketServiceReady()

    - #### setSocketServiceReady

          protected void setSocketServiceReady(boolean value)

    - #### isInputBufferEmpty

          protected boolean isInputBufferEmpty()

      Method description

    - #### getPeerCertificate

          public Certificate getPeerCertificate()

    - #### getLocalCertificate

          public Certificate getLocalCertificate()

Copyright © 2022 "Tigase, Inc.". All rights reserved.