Package tigase.net

Class 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

    Author:
    Artur Hefczyc
    • Constructor Detail

      • IOService

        public IOService()
    • Method Detail

      • forceStop

        public void forceStop()
      • startSSL

        public void startSSL​(boolean clientMode,
                             boolean wantClientAuth,
                             boolean needClientAuth)
                      throws IOException
        Throws:
        IOException
      • startTLS

        public void startTLS​(boolean clientMode,
                             boolean wantClientAuth,
                             boolean needClientAuth)
                      throws IOException
        Throws:
        IOException
      • startZLib

        public void startZLib​(int level)
      • stop

        public void stop()
      • waitingToRead

        public boolean waitingToRead()
      • waitingToSend

        public boolean waitingToSend()
      • waitingToSendSize

        public int waitingToSendSize()
      • getBuffOverflow

        public long getBuffOverflow​(boolean reset)
      • getBytesReceived

        public long getBytesReceived​(boolean reset)
      • getBytesSent

        public long getBytesSent​(boolean reset)
      • getConnectionId

        public JID getConnectionId()
      • setConnectionId

        public void setConnectionId​(JID connectionId)
      • getDataReceiver

        public JID getDataReceiver()
      • setDataReceiver

        public void setDataReceiver​(JID address)
      • 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()
      • getTlsUniqueId

        public byte[] getTlsUniqueId()
      • getLocalPort

        public int getLocalPort()
        Method returns local port of opened socket
      • getReadCounters

        public long[] getReadCounters()
      • getRefObject

        public RefObject getRefObject()
      • setRefObject

        public void setRefObject​(RefObject refObject)
      • getRemoteAddress

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

        public void setSessionData​(Map<String,​Object> props)
      • getStatistics

        public void getStatistics​(StatisticsList list,
                                  boolean reset)
      • getTotalBuffOverflow

        public long getTotalBuffOverflow()
      • getTotalBytesReceived

        public long getTotalBytesReceived()
      • getTotalBytesSent

        public long getTotalBytesSent()
      • getUniqueId

        public String getUniqueId()
      • getWriteCounters

        public long[] getWriteCounters()
      • isConnected

        public boolean isConnected()
      • setBufferLimit

        public void setBufferLimit​(int bufferLimit)
      • setX509TrustManagers

        public void setX509TrustManagers​(TrustManager[] trustManager)
      • getPeerCertificate

        public Certificate getPeerCertificate()
      • getLocalCertificate

        public Certificate getLocalCertificate()
      • byteOrder

        protected ByteOrder byteOrder()
      • debug

        protected boolean debug​(char[] msg)
      • debug

        protected boolean debug​(String msg,
                                String prefix)
      • readCompleted

        protected void readCompleted()
      • receivedPackets

        protected abstract int receivedPackets()
      • writeBytes

        protected void writeBytes​(ByteBuffer data)
      • writeData

        protected void writeData​(String data)
      • isSocketServiceReady

        protected boolean isSocketServiceReady()
      • setSocketServiceReady

        protected void setSocketServiceReady​(boolean value)
      • handleMalformedInput

        protected boolean handleMalformedInput​(ByteBuffer buffer,
                                               CharBuffer cb)
      • isInputBufferEmpty

        protected boolean isInputBufferEmpty()