Top Description Inners Methods
org.glassfish.grizzly

public Interface Connection<L>

extends Readable<L>, Writeable<L>, Closeable, AttributeStorage, MonitoringAware<ConnectionProbe>
Known Direct Implementers
org.glassfish.grizzly.nio.NIOConnection
Type Parameters
<L>
the Connection address type
Imports
java.io.IOException, java.util.concurrent.Future, .TimeUnit, java.util.function.Supplier, org.glassfish.grizzly.attributes.AttributeStorage, org.glassfish.grizzly.memory.MemoryManager, org.glassfish.grizzly.monitoring.MonitoringAware, .MonitoringConfig

Common interface, which represents any kind of connection.
Author
Alexey Stashok

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Connection.CloseListener

This interface will be removed in 3.0.
public static enum
Connection.CloseType

This enum will be removed in 3.0.

Method Summary

Modifier and TypeMethod and Description
public void
addCloseListener(CloseListener<T extends Closeable, C extends ICloseType> closeListener)

Redeclares org.glassfish.grizzly.Closeable.addCloseListener.

Add the CloseListener, which will be notified once Connection will be closed.

public void
addCloseListener(Connection.CloseListener closeListener)

Add the CloseListener, which will be notified once Connection will be closed.

public void
assertOpen()

Redeclares org.glassfish.grizzly.Closeable.assertOpen.

Checks if this Connection is open and ready to be used.

public GrizzlyFuture<Closeable>

Returns:

Future, which could be checked in case, if close operation will be run asynchronously
close
()

Redeclares org.glassfish.grizzly.Closeable.close.

Gracefully close the Connection

public void
close(CompletionHandler<Closeable>
CompletionHandler to be called, when the connection is closed.
completionHandler
)

Redeclares org.glassfish.grizzly.Closeable.close.

Gracefully close the Connection

public void
closeSilently()

Redeclares org.glassfish.grizzly.Closeable.closeSilently.

Gracefully close the Connection silently, no notification required on completion or failure.

public void
closeWithReason(IOException reason)

Redeclares org.glassfish.grizzly.Closeable.closeWithReason.

Gracefully closes the Connection and provides the reason description.

public void
configureBlocking(boolean
the Connection mode. true, if Connection should operate in blocking mode, or false otherwise.
isBlocking
)

Sets the Connection mode.

public void
configureStandalone(boolean isStandalone)
Deprecated

public void
disableIOEvent(final IOEvent ioEvent)

public void
enableIOEvent(final IOEvent ioEvent)

public void
executeInEventThread(IOEvent
event to get the thread pool from
event
,
Runnable
Runnable to run in the thread
runnable
)

Executes the Runnable in the thread, responsible for running the given type of event on this Connection.

public CloseReason

Returns:

CloseReason if this Connection has been closed, or null otherwise
getCloseReason
()

Returns CloseReason if this Connection has been closed, or null otherwise.

public long

Returns:

id of this instance, never null.
getId
()

Returns id of this instance, unique in the context of the JVM and the implementation class.

public L

Returns:

the connection local address
getLocalAddress
()

Get the connection local address

public int

Returns:

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

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

public MemoryManager<?>
getMemoryManager()

Returns: an associated MemoryManager.

public MonitoringConfig<ConnectionProbe>

Returns:

the Connection monitoring configuration MonitoringConfig.
getMonitoringConfig
()

Redeclares org.glassfish.grizzly.monitoring.MonitoringAware.getMonitoringConfig.

Return the object associated MonitoringConfig.

public L

Returns:

the connection peer address
getPeerAddress
()

Get the connection peer address

public Processor<E extends Context>

Returns:

the default Processor, which will process Connection I/O events.
getProcessor
()

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

public ProcessorSelector

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.
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.

public int

Returns:

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

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

public long

Returns:

the read timeout value
getReadTimeout
(TimeUnit
the TimeUnit to convert the returned result to.
timeUnit
)

Returns the current value for the blocking read timeout converted to the provided TimeUnit specification.

public Transport

Returns:

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

Get the Transport, to which this Connection belongs to.

public int

Returns:

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

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

public long

Returns:

the write timeout value
getWriteTimeout
(TimeUnit
the TimeUnit to convert the returned result to.
timeUnit
)

Returns the current value for the blocking write timeout converted to the provided TimeUnit specification.

public boolean
isBlocking()

Returns: the Connection mode.

public boolean

Returns:

true, if connection is open and ready, or false otherwise.
isOpen
()

Redeclares org.glassfish.grizzly.Closeable.isOpen.

Is Connection open and ready.

public boolean
isStandalone()
Deprecated

public void
notifyConnectionError(Throwable error)

Method gets invoked, when error occur during the Connection lifecycle.

public Processor<E extends Context>

Returns:

the default Processor, which will process Connection I/O events.
obtainProcessor
(IOEvent
event to obtain the processor for
ioEvent
)

Gets the Processor, which will process Connection I/O event.

public <
state of the Processor
E
>
E

Returns:

the Processor state associated with this Connection.
obtainProcessorState
(Processor<E extends Context> processor, Supplier<E>
factory that is used to initialise the state
factory
)

Returns the Processor state associated with this Connection.

public boolean
public boolean

Returns:

true if listener successfully removed
removeCloseListener
(Connection.CloseListener closeListener)

Remove the CloseListener.

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

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

public void
setProcessor(Processor<E extends Context>
the default Processor, which will process Connection I/O events.
preferableProcessor
)

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

public void
setProcessorSelector(ProcessorSelector
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.
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.

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

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

public void
setReadTimeout(long
the new timeout value
timeout
,
TimeUnit
the TimeUnit specification of the provided value.
timeUnit
)

Specifies the timeout for the blocking reads.

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

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

public void
setWriteTimeout(long
the new timeout value
timeout
,
TimeUnit
the TimeUnit specification of the provided value.
timeUnit
)

Specifies the timeout for the blocking writes.

public void
simulateIOEvent(final IOEvent ioEvent)

public GrizzlyFuture<Closeable>

Returns:

Future, which could be checked in case, if close operation will be run asynchronously
terminate
()

Redeclares org.glassfish.grizzly.Closeable.terminate.

Close the Connection

public void
terminateSilently()

Redeclares org.glassfish.grizzly.Closeable.terminateSilently.

Close the Connection silently, no notification required on completion or failure.

public void
terminateWithReason(IOException reason)

Redeclares org.glassfish.grizzly.Closeable.terminateWithReason.

Closes the Connection and provides the reason description.

Inherited from org.glassfish.grizzly.attributes.AttributeStorage:
getAttributes
Inherited from org.glassfish.grizzly.Closeable:
closeFuture
Inherited from org.glassfish.grizzly.Readable:
readread
Inherited from org.glassfish.grizzly.Writeable:
writewritewritewritewrite

Method Detail

addCloseListenerback to summary
public void addCloseListener(CloseListener<T extends Closeable, C extends ICloseType> closeListener)

Redeclares org.glassfish.grizzly.Closeable.addCloseListener.

Add the CloseListener, which will be notified once Connection will be closed.

Parameters
closeListener:CloseListener<T extends Closeable, C extends ICloseType>

CloseListener.

Annotations
@Override
Since
2.3
addCloseListenerback to summary
public void addCloseListener(Connection.CloseListener closeListener)

Add the CloseListener, which will be notified once Connection will be closed.

Parameters
closeListener:Connection.CloseListener

CloseListener

Annotations
@Deprecated
assertOpenback to summary
public void assertOpen() throws IOException

Redeclares org.glassfish.grizzly.Closeable.assertOpen.

Checks if this Connection is open and ready to be used. If this Connection is closed - this method throws IOException giving the reason why this Connection was closed.

Annotations
@Override
Exceptions
IOException:

Doc from org.glassfish.grizzly.Closeable.assertOpen.

giving the reason why this Closeable was closed.

closeback to summary
public GrizzlyFuture<Closeable> close()

Redeclares org.glassfish.grizzly.Closeable.close.

Gracefully close the Connection

Returns:GrizzlyFuture<Closeable>

Future, which could be checked in case, if close operation will be run asynchronously

Annotations
@Override
closeback to summary
public void close(CompletionHandler<Closeable> completionHandler)

Redeclares org.glassfish.grizzly.Closeable.close.

Gracefully close the Connection

Parameters
completionHandler:CompletionHandler<Closeable>

CompletionHandler to be called, when the connection is closed.

Annotations
@Deprecated
@Override
closeSilentlyback to summary
public void closeSilently()

Redeclares org.glassfish.grizzly.Closeable.closeSilently.

Gracefully close the Connection silently, no notification required on completion or failure.

Annotations
@Override
closeWithReasonback to summary
public void closeWithReason(IOException reason)

Redeclares org.glassfish.grizzly.Closeable.closeWithReason.

Gracefully closes the Connection and provides the reason description. This method is similar to closeSilently(), but additionally provides the reason why the Connection will be closed.

Annotations
@Override
configureBlockingback to summary
public void configureBlocking(boolean isBlocking)

Sets the Connection mode.

Parameters
isBlocking:boolean

the Connection mode. true, if Connection should operate in blocking mode, or false otherwise.

configureStandaloneback to summary
public void configureStandalone(boolean isStandalone)

Deprecated

Annotations
@Deprecated
disableIOEventback to summary
public void disableIOEvent(final IOEvent ioEvent) throws IOException
enableIOEventback to summary
public void enableIOEvent(final IOEvent ioEvent) throws IOException
executeInEventThreadback to summary
public void executeInEventThread(IOEvent event, Runnable runnable)

Executes the Runnable in the thread, responsible for running the given type of event on this Connection. The thread will be chosen based on Transport settings, especially current I/O strategy.

Parameters
event:IOEvent

event to get the thread pool from

runnable:Runnable

Runnable to run in the thread

getCloseReasonback to summary
public CloseReason getCloseReason()

Returns CloseReason if this Connection has been closed, or null otherwise.

Returns:CloseReason

CloseReason if this Connection has been closed, or null otherwise

getIdback to summary
public long getId()

Returns id of this instance, unique in the context of the JVM and the implementation class.

Returns:long

id of this instance, never null.

getLocalAddressback to summary
public L getLocalAddress()

Get the connection local address

Returns:L

the connection local address

getMaxAsyncWriteQueueSizeback to summary
public int getMaxAsyncWriteQueueSize()

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

Returns:int

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

Since
2.2
getMemoryManagerback to summary
public MemoryManager<?> getMemoryManager()
Returns:MemoryManager<?>

an associated MemoryManager. It's a shortcut for getTransport().getMemoryManager()

Since
2.3.18
getMonitoringConfigback to summary
public MonitoringConfig<ConnectionProbe> getMonitoringConfig()

Redeclares org.glassfish.grizzly.monitoring.MonitoringAware.getMonitoringConfig.

Doc from org.glassfish.grizzly.monitoring.MonitoringAware.getMonitoringConfig.

Return the object associated MonitoringConfig.

Returns:MonitoringConfig<ConnectionProbe>

the Connection monitoring configuration MonitoringConfig.

Annotations
@Override
getPeerAddressback to summary
public L getPeerAddress()

Get the connection peer address

Returns:L

the connection peer address

getProcessorback to summary
public Processor<E extends Context> 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:Processor<E extends Context>

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

getProcessorSelectorback to summary
public 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:ProcessorSelector

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.

getReadBufferSizeback to summary
public int getReadBufferSize()

Get the default size of Buffers, which will be allocated for reading data from Connection. The value less or equal to zero will be ignored.

Returns:int

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

getReadTimeoutback to summary
public long getReadTimeout(TimeUnit timeUnit)

Returns the current value for the blocking read timeout converted to the provided TimeUnit specification. If this value hasn't been explicitly set, it will default to 30 seconds.

Parameters
timeUnit:TimeUnit

the TimeUnit to convert the returned result to.

Returns:long

the read timeout value

Since
2.3
getTransportback to summary
public Transport getTransport()

Get the Transport, to which this Connection belongs to.

Returns:Transport

the Transport, to which this Connection belongs to.

getWriteBufferSizeback to summary
public int getWriteBufferSize()

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

Returns:int

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

getWriteTimeoutback to summary
public long getWriteTimeout(TimeUnit timeUnit)

Returns the current value for the blocking write timeout converted to the provided TimeUnit specification. If this value hasn't been explicitly set, it will default to 30 seconds.

Parameters
timeUnit:TimeUnit

the TimeUnit to convert the returned result to.

Returns:long

the write timeout value

Since
2.3
isBlockingback to summary
public boolean isBlocking()
Returns:boolean

the Connection mode. true, if Connection is operating in blocking mode, or false otherwise.

isOpenback to summary
public boolean isOpen()

Redeclares org.glassfish.grizzly.Closeable.isOpen.

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

Returns:boolean

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

Annotations
@Override
isStandaloneback to summary
public boolean isStandalone()

Deprecated

Annotations
@Deprecated
notifyConnectionErrorback to summary
public void notifyConnectionError(Throwable error)

Method gets invoked, when error occur during the Connection lifecycle.

Parameters
error:Throwable

Throwable.

obtainProcessorback to summary
public Processor<E extends Context> 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.

Parameters
ioEvent:IOEvent

event to obtain the processor for

Returns:Processor<E extends Context>

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

obtainProcessorStateback to summary
public <E> E obtainProcessorState(Processor<E extends Context> processor, Supplier<E> factory)

Returns the Processor state associated with this Connection.

Parameters
<E>
state of the Processor
processor:Processor<E extends Context>

Processor

factory:Supplier<E>

factory that is used to initialise the state

Returns:E

the Processor state associated with this Connection.

removeCloseListenerback to summary
public boolean removeCloseListener(CloseListener<T extends Closeable, C extends ICloseType> closeListener)

Redeclares org.glassfish.grizzly.Closeable.removeCloseListener.

Remove the CloseListener.

Parameters
closeListener:CloseListener<T extends Closeable, C extends ICloseType>

CloseListener.

Annotations
@Override
Since
2.3
removeCloseListenerback to summary
public boolean removeCloseListener(Connection.CloseListener closeListener)

Remove the CloseListener.

Parameters
closeListener:Connection.CloseListener

CloseListener.

Returns:boolean

true if listener successfully removed

Annotations
@Deprecated
setMaxAsyncWriteQueueSizeback to summary
public void setMaxAsyncWriteQueueSize(int maxAsyncWriteQueueSize)

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

Parameters
maxAsyncWriteQueueSize:int

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

Since
2.2
setProcessorback to summary
public void setProcessor(Processor<E extends Context> 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:Processor<E extends Context>

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

setProcessorSelectorback to summary
public 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:ProcessorSelector

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.

setReadBufferSizeback to summary
public void setReadBufferSize(int readBufferSize)

Set the default size of Buffers, which will be allocated for reading data from Connection. The value less or equal to zero will be ignored.

Parameters
readBufferSize:int

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

setReadTimeoutback to summary
public void setReadTimeout(long timeout, TimeUnit timeUnit)

Specifies the timeout for the blocking reads. This may be overridden on a per-connection basis. A value of zero or less effectively disables the timeout.

Parameters
timeout:long

the new timeout value

timeUnit:TimeUnit

the TimeUnit specification of the provided value.

Since
2.3
See Also
Connection#setReadTimeout(long, java.util.concurrent.TimeUnit)
setWriteBufferSizeback to summary
public void setWriteBufferSize(int writeBufferSize)

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

Parameters
writeBufferSize:int

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

setWriteTimeoutback to summary
public void setWriteTimeout(long timeout, TimeUnit timeUnit)

Specifies the timeout for the blocking writes. This may be overridden on a per-connection basis. A value of zero or less effectively disables the timeout.

Parameters
timeout:long

the new timeout value

timeUnit:TimeUnit

the TimeUnit specification of the provided value.

Since
2.3
See Also
Connection#setWriteTimeout(long, java.util.concurrent.TimeUnit)
simulateIOEventback to summary
public void simulateIOEvent(final IOEvent ioEvent) throws IOException
terminateback to summary
public GrizzlyFuture<Closeable> terminate()

Redeclares org.glassfish.grizzly.Closeable.terminate.

Close the Connection

Returns:GrizzlyFuture<Closeable>

Future, which could be checked in case, if close operation will be run asynchronously

Annotations
@Override
terminateSilentlyback to summary
public void terminateSilently()

Redeclares org.glassfish.grizzly.Closeable.terminateSilently.

Close the Connection silently, no notification required on completion or failure.

Annotations
@Override
terminateWithReasonback to summary
public void terminateWithReason(IOException reason)

Redeclares org.glassfish.grizzly.Closeable.terminateWithReason.

Closes the Connection and provides the reason description. This method is similar to terminateSilently(), but additionally provides the reason why the Connection will be closed.

Annotations
@Override
org.glassfish.grizzly back to summary

public Interface Connection.CloseListener

extends CloseListener<Connection<L>, Connection.CloseType>
Annotations
@Deprecated

Deprecated

use org.glassfish.grizzly.CloseListener

This interface will be removed in 3.0.
See Also
GenericCloseListener

Method Summary

Modifier and TypeMethod and Description
public void
onClosed(Connection<L> connection, Connection.CloseType type)

Redeclares org.glassfish.grizzly.CloseListener.onClosed.

References Deprecated Connection.CloseType is deprecated or references (maybe indirectly) at least one deprecated element.

Method Detail

onClosedback to summary
public void onClosed(Connection<L> connection, Connection.CloseType type) throws IOException

Redeclares org.glassfish.grizzly.CloseListener.onClosed.

References Deprecated

Connection.CloseType is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Annotations
@Override
org.glassfish.grizzly back to summary

public final Enum Connection.CloseType

extends Enum<Connection.CloseType>
implements ICloseType
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.ICloseType
Annotations
@Deprecated

Deprecated

use org.glassfish.grizzly.CloseType

This enum will be removed in 3.0.

Field Summary

Modifier and TypeField and Description
public static final Connection.CloseType
LOCALLY

References Deprecated Connection.CloseType is deprecated or references (maybe indirectly) at least one deprecated element.
public static final Connection.CloseType
REMOTELY

References Deprecated Connection.CloseType is deprecated or references (maybe indirectly) at least one deprecated element.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Connection.CloseType
valueOf(String name)
References Deprecated Connection.CloseType is deprecated or references (maybe indirectly) at least one deprecated element.

public static Connection.CloseType[]
values()
References Deprecated Connection.CloseType is deprecated or references (maybe indirectly) at least one deprecated element.

Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

LOCALLYback to summary
public static final Connection.CloseType LOCALLY

References Deprecated

Connection.CloseType is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

REMOTELYback to summary
public static final Connection.CloseType REMOTELY

References Deprecated

Connection.CloseType is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Constructor Detail

CloseTypeback to summary
private CloseType()

Method Detail

valueOfback to summary
public static Connection.CloseType valueOf(String name)

References Deprecated

Connection.CloseType is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

valuesback to summary
public static Connection.CloseType[] values()

References Deprecated

Connection.CloseType is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.