org.glassfish.grizzly.nio.transport
Class TCPNIOConnection

java.lang.Object
  extended by org.glassfish.grizzly.nio.NIOConnection
      extended by org.glassfish.grizzly.nio.transport.TCPNIOConnection
All Implemented Interfaces:
AttributeStorage, Closeable<Connection>, Connection<SocketAddress>, MonitoringAware<ConnectionProbe>, Readable<SocketAddress>, Writable<SocketAddress>
Direct Known Subclasses:
TCPNIOServerConnection

public class TCPNIOConnection
extends NIOConnection

Connection implementation for the TCPNIOTransport

Author:
Alexey Stashok

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.glassfish.grizzly.Connection
Connection.CloseListener, Connection.CloseType
 
Field Summary
 
Fields inherited from class org.glassfish.grizzly.nio.NIOConnection
asyncReadQueue, asyncWriteQueue, attributes, channel, closeTypeFlag, connectCloseSemaphor, isBlocking, isStandalone, maxAsyncWriteQueueSize, monitoringConfig, NOTIFICATION_CLOSED_COMPLETE, NOTIFICATION_INITIALIZED, processor, processorSelector, readBufferSize, readTimeoutMillis, selectionKey, selectorRunner, transport, writeBufferSize, writeTimeoutMillis, zeroByteReadCount
 
Constructor Summary
TCPNIOConnection(TCPNIOTransport transport, SelectableChannel channel)
           
 
Method Summary
protected  void checkConnectFailed(Throwable failure)
          Method will be called in order to check if failure happened before Connection was reported as connected.
protected  void close0(CompletionHandler<Connection> completionHandler, boolean isClosedLocally)
          
 SocketAddress getLocalAddress()
          Returns the local address of this Connection, or null if it is unconnected.
 SocketAddress getPeerAddress()
          Returns the address of the endpoint this Connection is connected to, or null if it is unconnected.
protected  boolean notifyReady()
           
protected  void onConnect()
          Method will be called, when the connection gets connected.
protected  void onRead(Buffer data, int size)
          Method will be called, when some data was read on the connection
protected  void onWrite(Buffer data, long size)
          Method will be called, when some data was written on the connection
protected  void preClose()
           
protected  void resetProperties()
           
protected  void setConnectCompletionHandler(CompletionHandler<Connection> connectHandler)
           
 void setReadBufferSize(int readBufferSize)
          Set the default size of Buffers, which will be allocated for reading data from Connection.
protected  void setSelectionKey(SelectionKey selectionKey)
           
protected  void setSelectorRunner(SelectorRunner selectorRunner)
           
 void setWriteBufferSize(int writeBufferSize)
          Set the default size of Buffers, which will be allocated for writing data to Connection.
 String toString()
           
 
Methods inherited from class org.glassfish.grizzly.nio.NIOConnection
addCloseListener, attachToSelectorRunner, checkEmptyRead, close, close, closeSilently, configureBlocking, configureStandalone, detachSelectorRunner, disableIOEvent, enableIOEvent, getAsyncReadQueue, getAsyncWriteQueue, getAttributes, getChannel, getMaxAsyncWriteQueueSize, getMonitoringConfig, getProcessor, getProcessorSelector, getReadBufferSize, getReadTimeout, getSelectionKey, getSelectorRunner, getTransport, getWriteBufferSize, getWriteTimeout, isBlocking, isOpen, isStandalone, notifyConnectionError, notifyIOEventDisabled, notifyIOEventEnabled, notifyIOEventReady, notifyProbesAccept, notifyProbesBind, notifyProbesClose, notifyProbesConnect, notifyProbesError, notifyProbesRead, notifyProbesWrite, obtainProcessor, obtainProcessorState, read, read, removeCloseListener, setChannel, setMaxAsyncWriteQueueSize, setProcessor, setProcessorSelector, setReadTimeout, setWriteTimeout, simulateIOEvent, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TCPNIOConnection

public TCPNIOConnection(TCPNIOTransport transport,
                        SelectableChannel channel)
Method Detail

setSelectionKey

protected void setSelectionKey(SelectionKey selectionKey)
Overrides:
setSelectionKey in class NIOConnection

setSelectorRunner

protected void setSelectorRunner(SelectorRunner selectorRunner)
Overrides:
setSelectorRunner in class NIOConnection

preClose

protected void preClose()
Overrides:
preClose in class NIOConnection

notifyReady

protected boolean notifyReady()

getPeerAddress

public SocketAddress getPeerAddress()
Returns the address of the endpoint this Connection is connected to, or null if it is unconnected.

Returns:
the address of the endpoint this Connection is connected to, or null if it is unconnected.

getLocalAddress

public SocketAddress getLocalAddress()
Returns the local address of this Connection, or null if it is unconnected.

Returns:
the local address of this Connection, or null if it is unconnected.

resetProperties

protected final void resetProperties()

setReadBufferSize

public void setReadBufferSize(int readBufferSize)
Description copied from interface: Connection
Set the default size of Buffers, which will be allocated for reading data from Connection.

Specified by:
setReadBufferSize in interface Connection<SocketAddress>
Overrides:
setReadBufferSize in class NIOConnection
Parameters:
readBufferSize - the default size of Buffers, which will be allocated for reading data from Connection.

setWriteBufferSize

public void setWriteBufferSize(int writeBufferSize)
Description copied from interface: Connection
Set the default size of Buffers, which will be allocated for writing data to Connection.

Specified by:
setWriteBufferSize in interface Connection<SocketAddress>
Overrides:
setWriteBufferSize in class NIOConnection
Parameters:
writeBufferSize - the default size of Buffers, which will be allocated for writing data to Connection.

setConnectCompletionHandler

protected final void setConnectCompletionHandler(CompletionHandler<Connection> connectHandler)

onConnect

protected final void onConnect()
                        throws IOException
Method will be called, when the connection gets connected.

Throws:
IOException

checkConnectFailed

protected final void checkConnectFailed(Throwable failure)
Method will be called in order to check if failure happened before Connection was reported as connected.

Throws:
IOException

close0

protected void close0(CompletionHandler<Connection> completionHandler,
                      boolean isClosedLocally)

Overrides:
close0 in class NIOConnection

onRead

protected final void onRead(Buffer data,
                            int size)
Method will be called, when some data was read on the connection


onWrite

protected final void onWrite(Buffer data,
                             long size)
Method will be called, when some data was written on the connection


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012 Oracle Corporation. All Rights Reserved.