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 CharBufferstatic final Stringstatic final Stringprotected CharsetDecoderprotected CharsetEncoderstatic final Stringstatic final Stringprotected byte[]The saved partial bytes for multi-byte UTF-8 characters between readsstatic final Stringstatic final StringThis is key used to store session ID in temporary session data storage.static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(SocketChannel socketChannel) Deprecated.voidaccept(SocketChannel socketChannel, Integer socketInputSize) protected ByteOrderIOService<?> call()booleancheckBufferLimit(int bufferSize) protected booleandebug(char[] msg) protected booleanvoidlonggetBuffOverflow(boolean reset) longgetBytesReceived(boolean reset) longgetBytesSent(boolean reset) protected IOInterfacegetIO()longThis method returns the time of last transfer in any direction through this service.intMethod returns local port of opened socketlong[]Returns a remote IP address for the TCP/IP connection.intvoidgetStatistics(StatisticsList list, boolean reset) byte[]byte[]longlonglonglong[]protected booleanhandleMalformedInput(ByteBuffer buffer, CharBuffer cb) voidhandshakeCompleted(TLSWrapper wrapper) booleanprotected booleanprotected booleanprotected abstract voidabstract voidprotected ByteBufferprotected voidprotected char[]readData()protected abstract intvoidsetBufferLimit(int bufferLimit) voidsetCertificateContainer(CertificateContainerIfc certificateContainer) voidsetConnectionId(JID connectionId) voidsetDataReceiver(JID address) voidvoidsetRefObject(RefObject refObject) voidsetSessionData(Map<String, Object> props) protected voidsetSocketServiceReady(boolean value) voidsetSslContextContainer(SSLContextContainerIfc sslContextContainer) voidsetX509TrustManagers(TrustManager[] trustManager) voidstartSSL(boolean clientMode, boolean wantClientAuth, boolean needClientAuth) voidstartTLS(boolean clientMode, boolean wantClientAuth, boolean needClientAuth) voidstartZLib(int level) voidstop()toString()booleanbooleanintprotected voidwriteBytes(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:
callin interfaceCallable<RefObject>- Throws:
IOException
-
checkBufferLimit
public boolean checkBufferLimit(int bufferSize) - Specified by:
checkBufferLimitin interfaceIOListener
-
connectionType
-
forceStop
public void forceStop() -
handshakeCompleted
- Specified by:
handshakeCompletedin 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() -
getTlsExporter
public byte[] getTlsExporter() -
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:
getSocketInputSizein 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
-