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.
 
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
 GrizzlyFuture<Connection> close(CompletionHandler<Connection> completionHandler)
          Close the Connection
 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
 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(java.util.concurrent.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(java.util.concurrent.TimeUnit timeUnit)
           
 boolean isBlocking()
           
 boolean isOpen()
          Is Connection open and ready.
 boolean isStandalone()
           
 void notifyConnectionError(java.lang.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.
 boolean removeCloseListener(Connection.CloseListener closeListener)
          Remove the Connection.CloseListener.
 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, java.util.concurrent.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, java.util.concurrent.TimeUnit timeUnit)
           
 
Methods inherited from interface org.glassfish.grizzly.Readable
read, read
 
Methods inherited from interface org.glassfish.grizzly.Writable
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.

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()
                                throws java.io.IOException
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
Throws:
java.io.IOException - if I/O error was detected during Connection closing.

close

GrizzlyFuture<Connection> close(CompletionHandler<Connection> completionHandler)
                                throws java.io.IOException
Close the Connection

Specified by:
close in interface Closeable<Connection>
Parameters:
completionHandler - CompletionHandler to be called, when the connection is closed.
Returns:
Future, which could be checked in case, if close operation will be run asynchronously
Throws:
java.io.IOException - if I/O error was detected during Connection closing.

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.

getReadTimeout

long getReadTimeout(java.util.concurrent.TimeUnit timeUnit)

setReadTimeout

void setReadTimeout(long timeout,
                    java.util.concurrent.TimeUnit timeUnit)

getWriteTimeout

long getWriteTimeout(java.util.concurrent.TimeUnit timeUnit)

setWriteTimeout

void setWriteTimeout(long timeout,
                     java.util.concurrent.TimeUnit timeUnit)

enableIOEvent

void enableIOEvent(IOEvent ioEvent)
                   throws java.io.IOException
Throws:
java.io.IOException

disableIOEvent

void disableIOEvent(IOEvent ioEvent)
                    throws java.io.IOException
Throws:
java.io.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(java.lang.Throwable error)
Method gets invoked, when error occur during the Connection lifecycle.

Parameters:
error - Throwable.


Copyright © 2011 Oracle Corpration. All Rights Reserved.