RefObject
- is a reference object stored by this service. This is e
reference to higher level data object keeping more information about the
connection.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()
. 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
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 and Description |
---|
IOService() |
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. |
public static final String CERT_CHECK_RESULT
public static final String CERT_REQUIRED_DOMAIN
public static final String HOSTNAME_KEY
public static final String PORT_TYPE_PROP_KEY
public static final String SESSION_ID_KEY
public static final String SSL_PROTOCOLS_KEY
protected byte[] partialCharacterBytes
protected CharsetEncoder encoder
protected CharsetDecoder decoder
protected CharBuffer cb
public void accept(SocketChannel socketChannel) throws IOException
accept
is used to performsocketChannel
- a
SocketChannel
valueIOException
public IOService<?> call() throws IOException
call
in interface Callable<IOService<?>>
IOException
public boolean checkBufferLimit(int bufferSize)
checkBufferLimit
in interface IOListener
public ConnectionType connectionType()
public void forceStop()
public void handshakeCompleted(TLSWrapper wrapper)
handshakeCompleted
in interface TLSEventHandler
public abstract void processWaitingPackets() throws IOException
IOException
public void startSSL(boolean clientMode, boolean wantClientAuth, boolean needClientAuth) throws IOException
clientMode
- IOException
public void startTLS(boolean clientMode, boolean wantClientAuth, boolean needClientAuth) throws IOException
clientMode
- IOException
public void startZLib(int level)
level
- public void stop()
stop
method here.public boolean waitingToRead()
public boolean waitingToSend()
public int waitingToSendSize()
public long getBuffOverflow(boolean reset)
reset
- public long getBytesReceived(boolean reset)
reset
- public long getBytesSent(boolean reset)
reset
- public JID getConnectionId()
public JID getDataReceiver()
public long getLastTransferTime()
public String getLocalAddress()
public byte[] getTlsUniqueId()
public int getLocalPort()
public long[] getReadCounters()
public RefObject getRefObject()
public String getRemoteAddress()
public ConcurrentMap<String,Object> getSessionData()
public int getSocketInputSize()
getSocketInputSize
in interface TLSEventHandler
public SocketChannel getSocketChannel()
getSocketChannel
is used to performSocketChannel
valuepublic void getStatistics(StatisticsList list, boolean reset)
list
- reset
- public long getTotalBuffOverflow()
public long getTotalBytesReceived()
public long getTotalBytesSent()
public String getUniqueId()
public long[] getWriteCounters()
public TrustManager[] getX509TrustManagers()
public boolean isConnected()
isConnected
method here.boolean
valuepublic void setBufferLimit(int bufferLimit)
public void setConnectionId(JID connectionId)
connectionId
- the connectionId to setpublic void setDataReceiver(JID address)
address
- public void setIOServiceListener(IOServiceListener<IOService<RefObject>> sl)
sl
- public void setRefObject(RefObject refObject)
refObject
- public void setSessionData(Map<String,Object> props)
props
- public void setX509TrustManagers(TrustManager[] trustManager)
trustManager
- protected ByteOrder byteOrder()
protected boolean debug(char[] msg)
debug
method here.msg
- a
char[]
valueboolean
valueprotected boolean debug(String msg, String prefix)
debug
method here.msg
- a
String
valueprefix
- boolean
valueprotected abstract void processSocketData() throws IOException
IOException
protected ByteBuffer readBytes() throws IOException
IOException
protected void readCompleted()
protected char[] readData() throws IOException
readData
method here.char[]
valueIOException
- if an error occursprotected abstract int receivedPackets()
protected void writeBytes(ByteBuffer data)
data
- protected void writeData(String data)
writeData
method here.data
- a
String
valueprotected boolean isSocketServiceReady()
protected void setSocketServiceReady(boolean value)
protected boolean isInputBufferEmpty()
public Certificate getPeerCertificate()
public Certificate getLocalCertificate()
Copyright © 2018 "Tigase, Inc.". All rights reserved.