org.glassfish.grizzly
Interface Connection<L>

All Superinterfaces:
AttributeStorage, Closeable<Connection>, MonitoringAware<ConnectionProbe>, Readable<L>, Writable<L>
All Known Implementing Classes:
NIOConnection, TCPNIOConnection, TCPNIOServerConnection, UDPNIOConnection, UDPNIOServerConnection

public interface Connection<L>
extends Readable<L>, Writable<L>, Closeable<Connection>, AttributeStorage, MonitoringAware<ConnectionProbe>

Common interface, which represents any kind of connection.

Author:
Alexey Stashok

Nested Class Summary
static interface Connection.CloseListener
          The listener, which is used to be notified, when Connection gets closed.
static class Connection.CloseType
           
 
Method Summary
 void addCloseListener(Connection.CloseListener closeListener)
          Add the Connection.CloseListener, which will be notified once Connection will be closed.
 GrizzlyFuture<Connection> close()
          Close the Connection
 void close(CompletionHandler<Connection> completionHandler)
          Close the Connection
 void closeSilently()
          Close the Connection silently, no notification required on completion or failure.
 void configureBlocking(boolean isBlocking)
          Sets the Connection mode.
 void configureStandalone(boolean isStandalone)
           
 void disableIOEvent(IOEvent ioEvent)
           
 void enableIOEvent(IOEvent ioEvent)
           
 L getLocalAddress()
          Get the connection local address
 int getMaxAsyncWriteQueueSize()
          Get the max size (in bytes) of asynchronous write queue associated with connection.
 MonitoringConfig<ConnectionProbe> getMonitoringConfig()
          Return the object associated MonitoringConfig.
 L getPeerAddress()
          Get the connection peer address
 Processor getProcessor()
          Gets the default Processor, which will process Connection I/O events.
 ProcessorSelector getProcessorSelector()
          Gets the default ProcessorSelector, which will be used to get Processor to process Connection I/O events, in case if this Connection's Processor is null.
 int getReadBufferSize()
          Get the default size of Buffers, which will be allocated for reading data from Connection.
 long getReadTimeout(TimeUnit timeUnit)
           
 Transport getTransport()
          Get the Transport, to which this Connection belongs to.
 int getWriteBufferSize()
          Get the default size of Buffers, which will be allocated for writing data to Connection.
 long getWriteTimeout(TimeUnit timeUnit)
           
 boolean isBlocking()
           
 boolean isOpen()
          Is Connection open and ready.
 boolean isStandalone()
           
 void notifyConnectionError(Throwable error)
          Method gets invoked, when error occur during the Connection lifecycle.
 Processor obtainProcessor(IOEvent ioEvent)
          Gets the Processor, which will process Connection I/O event.
<E> E
obtainProcessorState(Processor processor, NullaryFunction<E> factory)
          Returns the Processor state associated with this Connection.
 boolean removeCloseListener(Connection.CloseListener closeListener)
          Remove the Connection.CloseListener.
 void setMaxAsyncWriteQueueSize(int maxAsyncWriteQueueSize)
          Set the max size (in bytes) of asynchronous write queue associated with connection.
 void setProcessor(Processor preferableProcessor)
          Sets the default Processor, which will process Connection I/O events.
 void setProcessorSelector(ProcessorSelector preferableProcessorSelector)
          Sets the default ProcessorSelector, which will be used to get Processor to process Connection I/O events, in case if this Connection's Processor is null.
 void setReadBufferSize(int readBufferSize)
          Set the default size of Buffers, which will be allocated for reading data from Connection.
 void setReadTimeout(long timeout, TimeUnit timeUnit)
           
 void setWriteBufferSize(int writeBufferSize)
          Set the default size of Buffers, which will be allocated for writing data to Connection.
 void setWriteTimeout(long timeout, TimeUnit timeUnit)
           
 void simulateIOEvent(IOEvent ioEvent)
           
 
Methods inherited from interface org.glassfish.grizzly.Readable
read, read
 
Methods inherited from interface org.glassfish.grizzly.Writable
write, write, write, write
 
Methods inherited from interface org.glassfish.grizzly.attributes.AttributeStorage
getAttributes
 

Method Detail

getTransport

Transport getTransport()
Get the Transport, to which this Connection belongs to.

Returns:
the Transport, to which this Connection belongs to.

isOpen

boolean isOpen()
Is Connection open and ready. Returns true, if connection is open and ready, or false otherwise.

Returns:
true, if connection is open and ready, or false otherwise.

configureBlocking

void configureBlocking(boolean isBlocking)
Sets the Connection mode.

Parameters:
isBlocking - the Connection mode. true, if Connection should operate in blocking mode, or false otherwise.

isBlocking

boolean isBlocking()
Returns:
the Connection mode. true, if Connection is operating in blocking mode, or false otherwise.

configureStandalone

void configureStandalone(boolean isStandalone)

isStandalone

boolean isStandalone()

obtainProcessor

Processor obtainProcessor(IOEvent ioEvent)
Gets the Processor, which will process Connection I/O event. If Processor is null, - then Transport will try to get Processor using Connection's ProcessorSelector.select(IOEvent, Connection). If ProcessorSelector, associated withthe Connection is also null - will ask Transport for a Processor.

Returns:
the default Processor, which will process Connection I/O events.

getProcessor

Processor getProcessor()
Gets the default Processor, which will process Connection I/O events. If Processor is null, - then Transport will try to get Processor using Connection's ProcessorSelector.select(IOEvent, Connection). If ProcessorSelector, associated withthe Connection is also null - Transport will try to get Processor using own settings.

Returns:
the default Processor, which will process Connection I/O events.

setProcessor

void setProcessor(Processor preferableProcessor)
Sets the default Processor, which will process Connection I/O events. If Processor is null, - then Transport will try to get Processor using Connection's ProcessorSelector.select(IOEvent, Connection). If ProcessorSelector, associated withthe Connection is also null - Transport will try to get Processor using own settings.

Parameters:
preferableProcessor - the default Processor, which will process Connection I/O events.

getProcessorSelector

ProcessorSelector getProcessorSelector()
Gets the default ProcessorSelector, which will be used to get Processor to process Connection I/O events, in case if this Connection's Processor is null.

Returns:
the default ProcessorSelector, which will be used to get Processor to process Connection I/O events, in case if this Connection's Processor is null.

setProcessorSelector

void setProcessorSelector(ProcessorSelector preferableProcessorSelector)
Sets the default ProcessorSelector, which will be used to get Processor to process Connection I/O events, in case if this Connection's Processor is null.

Parameters:
preferableProcessorSelector - the default ProcessorSelector, which will be used to get Processor to process Connection I/O events, in case if this Connection's Processor is null.

obtainProcessorState

<E> E obtainProcessorState(Processor processor,
                           NullaryFunction<E> factory)
Returns the Processor state associated with this Connection.

Parameters:
processor - Processor
Returns:
the Processor state associated with this Connection.

getPeerAddress

L getPeerAddress()
Get the connection peer address

Returns:
the connection peer address

getLocalAddress

L getLocalAddress()
Get the connection local address

Returns:
the connection local address

close

GrizzlyFuture<Connection> close()
Close the Connection

Specified by:
close in interface Closeable<Connection>
Returns:
Future, which could be checked in case, if close operation will be run asynchronously

close

void close(CompletionHandler<Connection> completionHandler)
Close the Connection

Specified by:
close in interface Closeable<Connection>
Parameters:
completionHandler - CompletionHandler to be called, when the connection is closed.

closeSilently

void closeSilently()
Close the Connection silently, no notification required on completion or failure.


getReadBufferSize

int getReadBufferSize()
Get the default size of Buffers, which will be allocated for reading data from Connection.

Returns:
the default size of Buffers, which will be allocated for reading data from Connection.

setReadBufferSize

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

Parameters:
readBufferSize - the default size of Buffers, which will be allocated for reading data from Connection.

getWriteBufferSize

int getWriteBufferSize()
Get the default size of Buffers, which will be allocated for writing data to Connection.

Returns:
the default size of Buffers, which will be allocated for writing data to Connection.

setWriteBufferSize

void setWriteBufferSize(int writeBufferSize)
Set the default size of Buffers, which will be allocated for writing data to Connection.

Parameters:
writeBufferSize - the default size of Buffers, which will be allocated for writing data to Connection.

getMaxAsyncWriteQueueSize

int getMaxAsyncWriteQueueSize()
Get the max size (in bytes) of asynchronous write queue associated with connection.

Returns:
the max size (in bytes) of asynchronous write queue associated with connection.
Since:
2.2

setMaxAsyncWriteQueueSize

void setMaxAsyncWriteQueueSize(int maxAsyncWriteQueueSize)
Set the max size (in bytes) of asynchronous write queue associated with connection.

Parameters:
maxAsyncWriteQueueSize - the max size (in bytes) of asynchronous write queue associated with connection.
Since:
2.2

getReadTimeout

long getReadTimeout(TimeUnit timeUnit)

setReadTimeout

void setReadTimeout(long timeout,
                    TimeUnit timeUnit)

getWriteTimeout

long getWriteTimeout(TimeUnit timeUnit)

setWriteTimeout

void setWriteTimeout(long timeout,
                     TimeUnit timeUnit)

simulateIOEvent

void simulateIOEvent(IOEvent ioEvent)
                     throws IOException
Throws:
IOException

enableIOEvent

void enableIOEvent(IOEvent ioEvent)
                   throws IOException
Throws:
IOException

disableIOEvent

void disableIOEvent(IOEvent ioEvent)
                    throws IOException
Throws:
IOException

getMonitoringConfig

MonitoringConfig<ConnectionProbe> getMonitoringConfig()
Description copied from interface: MonitoringAware
Return the object associated MonitoringConfig.

Specified by:
getMonitoringConfig in interface MonitoringAware<ConnectionProbe>
Returns:
the Connection monitoring configuration MonitoringConfig.

addCloseListener

void addCloseListener(Connection.CloseListener closeListener)
Add the Connection.CloseListener, which will be notified once Connection will be closed.

Parameters:
closeListener - Connection.CloseListener.

removeCloseListener

boolean removeCloseListener(Connection.CloseListener closeListener)
Remove the Connection.CloseListener.

Parameters:
closeListener - Connection.CloseListener.

notifyConnectionError

void notifyConnectionError(Throwable error)
Method gets invoked, when error occur during the Connection lifecycle.

Parameters:
error - Throwable.


Copyright © 2012 Oracle Corporation. All Rights Reserved.