Package 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
- Author:
- Artur Hefczyc
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CharBuffer
static final String
static final String
protected CharsetDecoder
protected CharsetEncoder
static final String
static final String
protected byte[]
The saved partial bytes for multi-byte UTF-8 characters between readsstatic final String
static final String
This is key used to store session ID in temporary session data storage.static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(SocketChannel socketChannel) Deprecated.void
accept
(SocketChannel socketChannel, Integer socketInputSize) protected ByteOrder
IOService<?>
call()
boolean
checkBufferLimit
(int bufferSize) protected boolean
debug
(char[] msg) protected boolean
void
long
getBuffOverflow
(boolean reset) long
getBytesReceived
(boolean reset) long
getBytesSent
(boolean reset) protected IOInterface
getIO()
long
This method returns the time of last transfer in any direction through this service.int
Method returns local port of opened socketlong[]
Returns a remote IP address for the TCP/IP connection.int
void
getStatistics
(StatisticsList list, boolean reset) byte[]
long
long
long
long[]
protected boolean
handleMalformedInput
(ByteBuffer buffer, CharBuffer cb) void
handshakeCompleted
(TLSWrapper wrapper) boolean
protected boolean
protected boolean
protected abstract void
abstract void
protected ByteBuffer
protected void
protected char[]
readData()
protected abstract int
void
setBufferLimit
(int bufferLimit) void
setCertificateContainer
(CertificateContainerIfc certificateContainer) void
setConnectionId
(JID connectionId) void
setDataReceiver
(JID address) void
void
setRefObject
(RefObject refObject) void
setSessionData
(Map<String, Object> props) protected void
setSocketServiceReady
(boolean value) void
setSslContextContainer
(SSLContextContainerIfc sslContextContainer) void
setX509TrustManagers
(TrustManager[] trustManager) void
startSSL
(boolean clientMode, boolean wantClientAuth, boolean needClientAuth) void
startTLS
(boolean clientMode, boolean wantClientAuth, boolean needClientAuth) void
startZLib
(int level) void
stop()
toString()
boolean
boolean
int
protected void
writeBytes
(ByteBuffer data) protected void
-
Field Details
-
CERT_CHECK_RESULT
- See Also:
-
LOCAL_CERT_CHECK_RESULT
- See Also:
-
CERT_REQUIRED_DOMAIN
- See Also:
-
HOSTNAME_KEY
- See Also:
-
PORT_TYPE_PROP_KEY
- See Also:
-
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:
-
SSL_PROTOCOLS_KEY
- See Also:
-
cb
-
decoder
-
encoder
-
partialCharacterBytes
protected byte[] partialCharacterBytesThe saved partial bytes for multi-byte UTF-8 characters between reads
-
-
Constructor Details
-
IOService
public IOService()
-
-
Method Details
-
accept
Deprecated.- Throws:
IOException
-
accept
- Throws:
IOException
-
call
- Specified by:
call
in interfaceCallable<RefObject>
- Throws:
IOException
-
checkBufferLimit
public boolean checkBufferLimit(int bufferSize) - Specified by:
checkBufferLimit
in interfaceIOListener
-
connectionType
-
forceStop
public void forceStop() -
handshakeCompleted
- Specified by:
handshakeCompleted
in interfaceTLSEventHandler
-
processWaitingPackets
- Throws:
IOException
-
startSSL
public void startSSL(boolean clientMode, boolean wantClientAuth, boolean needClientAuth) throws IOException - Throws:
IOException
-
getCertificateContainer
-
setCertificateContainer
-
startTLS
public void startTLS(boolean clientMode, boolean wantClientAuth, boolean needClientAuth) throws IOException - Throws:
IOException
-
startZLib
public void startZLib(int level) -
stop
public void stop() -
toString
-
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
-
setConnectionId
-
getDataReceiver
-
setDataReceiver
-
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
-
getTlsUniqueId
public byte[] getTlsUniqueId() -
getLocalPort
public int getLocalPort()Method returns local port of opened socket -
getReadCounters
public long[] getReadCounters() -
getRefObject
-
setRefObject
-
getRemoteAddress
Returns a remote IP address for the TCP/IP connection.- Returns:
- a remote IP address for the TCP/IP connection.
-
getSessionData
-
setSessionData
-
getSocketInputSize
public int getSocketInputSize()- Specified by:
getSocketInputSize
in interfaceTLSEventHandler
-
getSocketChannel
-
getStatistics
-
getTotalBuffOverflow
public long getTotalBuffOverflow() -
getTotalBytesReceived
public long getTotalBytesReceived() -
getTotalBytesSent
public long getTotalBytesSent() -
getUniqueId
-
getWriteCounters
public long[] getWriteCounters() -
isConnected
public boolean isConnected() -
setBufferLimit
public void setBufferLimit(int bufferLimit) -
setIOServiceListener
-
setSslContextContainer
-
setX509TrustManagers
-
getPeerCertificate
-
getLocalCertificate
-
byteOrder
-
debug
protected boolean debug(char[] msg) -
debug
-
processSocketData
- Throws:
IOException
-
readBytes
- Throws:
IOException
-
readCompleted
protected void readCompleted() -
readData
- Throws:
IOException
-
receivedPackets
protected abstract int receivedPackets() -
writeBytes
-
writeData
-
isSocketServiceReady
protected boolean isSocketServiceReady() -
setSocketServiceReady
protected void setSocketServiceReady(boolean value) -
handleMalformedInput
-
isInputBufferEmpty
protected boolean isInputBufferEmpty() -
getIO
-