Package com.epam.common.transport
Class NIOSocketTransport
java.lang.Object
com.epam.common.transport.NIOSocketTransport
- All Implemented Interfaces:
NIOTransport
,Transport
- Direct Known Subclasses:
NIOTCPTransport
Abstract socket implementation of transport.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
protected boolean
protected SelectionKey
protected Selector
protected int
protected int
protected Socket
static final int
protected SocketChannel
static final String
protected boolean
protected SelectionKey
protected Selector
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
NIOSocketTransport
(int sendBufferSize, int receiveBufferSize) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the transport.Getter for address value.Getter for address value.int
Getter for local port value.int
getPort()
Getter for port value.Getter for certificates from sessionGetter for cipher suite from sessionGetter for ssl protocol from sessionboolean
boolean
isOpen()
Returnstrue
if, transport is open.abstract void
open()
Open the transport.int
read
(byte[] buffer) Transport dependent read method.int
read
(byte[] buffer, int offset, int length) Transport dependent read method.final int
read
(ByteBuffer buffer) final int
read
(ByteBuffer buffer, int offset, int length) void
setSessionConnectivityParams
(Map<String, Object> connectivityParams) void
void
write
(byte[] message) Transport dependent write method.final int
write
(byte[] buffer, int offset, int length) Transport dependent write method.int
write
(ByteBuffer buffer) final int
write
(ByteBuffer buffer, int offset, int length)
-
Field Details
-
SOCKET_READ_SIZE
public static final int SOCKET_READ_SIZE- See Also:
-
BLOCKING_SOCKETS_FLAG
- See Also:
-
SPINNING_READ_FLAG
- See Also:
-
socket
-
sendBufferSize
protected int sendBufferSize -
receiveBufferSize
protected int receiveBufferSize -
readSelector
-
writeSelector
-
socketChannel
-
readSelectionKey
-
writeSelectionKey
-
isBlocking
protected boolean isBlocking -
useSpinningReadSelect
protected boolean useSpinningReadSelect
-
-
Constructor Details
-
NIOSocketTransport
protected NIOSocketTransport(int sendBufferSize, int receiveBufferSize)
-
-
Method Details
-
setSessionConnectivityParams
- Specified by:
setSessionConnectivityParams
in interfaceNIOTransport
-
isBlockingSocket
public boolean isBlockingSocket()- Specified by:
isBlockingSocket
in interfaceTransport
-
write
- Specified by:
write
in interfaceTransport
- Throws:
IOException
-
waitUntilReadyToWrite
- Specified by:
waitUntilReadyToWrite
in interfaceTransport
- Throws:
IOException
-
write
Description copied from interface:Transport
Transport dependent write method.- Specified by:
write
in interfaceTransport
- Parameters:
buffer
- actual messageoffset
- the offset in bufferlength
- the num of bytes to write- Throws:
IOException
- if unable to write
-
write
- Specified by:
write
in interfaceTransport
- Throws:
IOException
-
read
- Specified by:
read
in interfaceTransport
- Throws:
IOException
-
read
- Specified by:
read
in interfaceTransport
- Throws:
IOException
-
read
Description copied from interface:Transport
Transport dependent read method.- Specified by:
read
in interfaceTransport
- Parameters:
buffer
- holder for read bytesoffset
- in bufferlength
- maximum bytes to be read- Returns:
- number of byte actually read
- Throws:
IOException
- if unable to read- See Also:
-
read
Description copied from interface:Transport
Transport dependent read method.- Specified by:
read
in interfaceTransport
- Parameters:
buffer
- holder for read bytes- Returns:
- number of byte actually read
- Throws:
IOException
- if unable to read- See Also:
-
write
Description copied from interface:Transport
Transport dependent write method.- Specified by:
write
in interfaceTransport
- Parameters:
message
- actual message- Throws:
IOException
- if unable to write- See Also:
-
getAddress
Description copied from interface:Transport
Getter for address value.- Specified by:
getAddress
in interfaceTransport
- See Also:
-
getInetAddress
Description copied from interface:Transport
Getter for address value.- Specified by:
getInetAddress
in interfaceTransport
-
getPort
public int getPort()Description copied from interface:Transport
Getter for port value. -
getLocalPort
public int getLocalPort()Description copied from interface:Transport
Getter for local port value.- Specified by:
getLocalPort
in interfaceTransport
-
close
Description copied from interface:Transport
Close the transport.- Specified by:
close
in interfaceTransport
- Throws:
IOException
- - throws if error occurred- See Also:
-
open
Description copied from interface:Transport
Open the transport.- Specified by:
open
in interfaceTransport
- Throws:
IOException
- - throws if error occurred- See Also:
-
isOpen
public boolean isOpen()Description copied from interface:Transport
Returnstrue
if, transport is open. -
getSSLProtocol
Description copied from interface:Transport
Getter for ssl protocol from session- Specified by:
getSSLProtocol
in interfaceTransport
-
getSSLCipherSuite
Description copied from interface:Transport
Getter for cipher suite from session- Specified by:
getSSLCipherSuite
in interfaceTransport
-
getSSLCertificates
Description copied from interface:Transport
Getter for certificates from session- Specified by:
getSSLCertificates
in interfaceTransport
-