com.epam.common.transport
Class NIOSocketTransport

java.lang.Object
  extended by com.epam.common.transport.NIOSocketTransport
All Implemented Interfaces:
Transport
Direct Known Subclasses:
NIOTCPTransport

public abstract class NIOSocketTransport
extends Object
implements Transport

Abstract socket implementation of transport.


Field Summary
static String BLOCKING_SOCKETS_FLAG
           
protected  InputStream is
           
protected  boolean isBlocking
           
protected  OutputStream os
           
protected  SelectionKey readSelectionKey
           
protected  Selector readSelector
           
protected  Socket socket
           
static int SOCKET_READ_SIZE
           
protected  SocketChannel socketChannel
           
static String SPINNING_READ_FLAG
           
protected  boolean useSpinningReadSelect
           
protected  SelectionKey writeSelectionKey
           
protected  Selector writeSelector
           
 
Constructor Summary
NIOSocketTransport()
           
 
Method Summary
 void close()
          Close the transport.
 String getAddress()
          Getter for address value.
 int getPort()
          Getter for port value.
 boolean isBlockingSocket()
           
 boolean isOpen()
          Returns true 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.
 int read(ByteBuffer buffer)
           
 int read(ByteBuffer buffer, int offset, int length)
           
 void setSessionConnectivityParams(HashMap<String,Object> connectivityParams)
           
 void waitUntilReadyToWrite()
           
 void write(byte[] message)
          Transport dependent write method.
 int write(byte[] buffer, int offset, int length)
          Transport dependent write method.
 int write(ByteBuffer buffer)
           
 int write(ByteBuffer buffer, int offset, int length)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOCKET_READ_SIZE

public static final int SOCKET_READ_SIZE
See Also:
Constant Field Values

BLOCKING_SOCKETS_FLAG

public static final String BLOCKING_SOCKETS_FLAG
See Also:
Constant Field Values

SPINNING_READ_FLAG

public static final String SPINNING_READ_FLAG
See Also:
Constant Field Values

socket

protected Socket socket

is

protected InputStream is

os

protected OutputStream os

readSelector

protected Selector readSelector

writeSelector

protected Selector writeSelector

socketChannel

protected SocketChannel socketChannel

readSelectionKey

protected SelectionKey readSelectionKey

writeSelectionKey

protected SelectionKey writeSelectionKey

isBlocking

protected boolean isBlocking

useSpinningReadSelect

protected boolean useSpinningReadSelect
Constructor Detail

NIOSocketTransport

public NIOSocketTransport()
Method Detail

setSessionConnectivityParams

public void setSessionConnectivityParams(HashMap<String,Object> connectivityParams)

isBlockingSocket

public boolean isBlockingSocket()
Specified by:
isBlockingSocket in interface Transport

write

public int write(ByteBuffer buffer)
          throws IOException
Specified by:
write in interface Transport
Throws:
IOException

waitUntilReadyToWrite

public void waitUntilReadyToWrite()
                           throws IOException
Specified by:
waitUntilReadyToWrite in interface Transport
Throws:
IOException

write

public final int write(byte[] buffer,
                       int offset,
                       int length)
                throws IOException
Description copied from interface: Transport
Transport dependent write method.

Specified by:
write in interface Transport
Parameters:
buffer - actual message
offset - the offset in buffer
length - the num of bytes to write
Throws:
IOException - if unable to write

write

public final int write(ByteBuffer buffer,
                       int offset,
                       int length)
                throws IOException
Specified by:
write in interface Transport
Throws:
IOException

read

public final int read(ByteBuffer buffer,
                      int offset,
                      int length)
               throws IOException
Specified by:
read in interface Transport
Throws:
IOException

read

public final int read(ByteBuffer buffer)
               throws IOException
Specified by:
read in interface Transport
Throws:
IOException

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws IOException
Description copied from interface: Transport
Transport dependent read method.

Specified by:
read in interface Transport
Parameters:
buffer - holder for read bytes
offset - in buffer
length - maximum bytes to be read
Returns:
number of byte actually read
Throws:
IOException - if unable to read
See Also:
Transport.read(byte[], int, int)

read

public int read(byte[] buffer)
         throws IOException
Description copied from interface: Transport
Transport dependent read method.

Specified by:
read in interface Transport
Parameters:
buffer - holder for read bytes
Returns:
number of byte actually read
Throws:
IOException - if unable to read
See Also:
Transport.read(byte[])

write

public void write(byte[] message)
           throws IOException
Description copied from interface: Transport
Transport dependent write method.

Specified by:
write in interface Transport
Parameters:
message - actual message
Throws:
IOException - if unable to write
See Also:
Transport.write(byte[])

getAddress

public String getAddress()
Description copied from interface: Transport
Getter for address value.

Specified by:
getAddress in interface Transport
See Also:
Transport.getAddress()

getPort

public int getPort()
Description copied from interface: Transport
Getter for port value.

Specified by:
getPort in interface Transport
See Also:
Transport.getPort()

close

public void close()
           throws IOException
Description copied from interface: Transport
Close the transport.

Specified by:
close in interface Transport
Throws:
IOException - - throws if error occurred
See Also:
Transport.close()

open

public abstract void open()
                   throws IOException
Description copied from interface: Transport
Open the transport.

Specified by:
open in interface Transport
Throws:
IOException - - throws if error occurred
See Also:
Transport.open()

isOpen

public boolean isOpen()
Description copied from interface: Transport
Returns true if, transport is open.

Specified by:
isOpen in interface Transport
See Also:
Transport.isOpen()


Copyright © 2000-2014 EPAM Systems. All Rights Reserved.