Class Channel
java.lang.Object
org.eclipse.net4j.util.event.Notifier
org.eclipse.net4j.util.lifecycle.Lifecycle
org.eclipse.spi.net4j.Channel
- All Implemented Interfaces:
IBufferHandler, IBufferProvider, IChannel, ILocationAware, org.eclipse.net4j.util.collection.Closeable, org.eclipse.net4j.util.concurrent.IExecutorServiceProvider, org.eclipse.net4j.util.container.IManagedContainerProvider, org.eclipse.net4j.util.event.INotifier, org.eclipse.net4j.util.event.INotifier.INotifier2, org.eclipse.net4j.util.lifecycle.IDeactivateable, org.eclipse.net4j.util.lifecycle.ILifecycle, org.eclipse.net4j.util.lifecycle.ILifecycle.DeferrableActivation, org.eclipse.net4j.util.security.IUserAware, InternalChannel
public class Channel
extends org.eclipse.net4j.util.lifecycle.Lifecycle
implements InternalChannel, org.eclipse.net4j.util.concurrent.IExecutorServiceProvider, org.eclipse.net4j.util.container.IManagedContainerProvider
Implements a logical Net4j channel that sends and receives buffers through a channel multiplexer and dispatches received data to its
configured receiver.
- Since:
- 2.0
- Author:
- Eike Stepper
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classDeprecated.As of 4.10 scheduled for future removal.protected classDeprecated.As of 4.4 scheduled for future removal.protected classA queue that holds buffers that shall be sent.Nested classes/interfaces inherited from class org.eclipse.net4j.util.event.Notifier
org.eclipse.net4j.util.event.Notifier.CancelationNested classes/interfaces inherited from interface IBufferProvider
IBufferProvider.Introspection, IBufferProvider.NotificationNested classes/interfaces inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle
org.eclipse.net4j.util.lifecycle.ILifecycle.DeferrableActivationNested classes/interfaces inherited from interface ILocationAware
ILocationAware.LocationNested classes/interfaces inherited from interface org.eclipse.net4j.util.event.INotifier
org.eclipse.net4j.util.event.INotifier.INotifier2Nested classes/interfaces inherited from interface InternalChannel
InternalChannel.CountersChangedEvent, InternalChannel.SendQueueEvent -
Field Summary
Fields inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle
USE_LABEL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected Channel.ReceiverWorkcreateReceiverWork(IBuffer buffer) Deprecated.As of 4.10 scheduled for future removal.protected voidprotected voidprotected voidfinal booleanfinishPinnedSendBuffer(Queue<IBuffer> queue, IBuffer buffer, boolean release) Ends the pin for an asynchronous send.shortReturns the capacity, in bytes, of buffers returned byIBufferProvider.provideBuffer().org.eclipse.net4j.util.container.IManagedContainershortgetID()Returns the ID of this channel.Returns the multiplexer this channel is associated with.longReturns the number ofbuffersthat are received from themultiplexerof this channel and are passed on to thereceive handlerof this channel.final longReturns the number of bytes that are received from themultiplexerof this channel and are passed on to thereceive handlerof this channel.Deprecated.Returns theIBufferHandlerthat handles buffers received from the peer channel.longReturns the number ofbuffersthat are sent to themultiplexerof this channel.final longReturns the number of bytes that are sent to themultiplexerof this channel.voidhandleBuffer(IBuffer buffer) Handles the given buffer.voidhandleBufferFromMultiplexer(IBuffer buffer) Handles a buffer sent by the multiplexer.booleanisClient()booleanisClosed()booleanisServer()final booleanpinSendBuffer(IBuffer buffer) Pins the active send-queue head while an asynchronous transport borrows its storage.Provides a buffer and transfers its current ownership to the caller.voidretainBuffer(IBuffer buffer) Accepts a buffer whose caller has relinquished ownership.voidsendBuffer(IBuffer buffer) Asynchronously sends the given buffer to the receive handler of the peer channel.voidsetID(short id) voidsetMultiplexer(IChannelMultiplexer channelMultiplexer) voidsetReceiveExecutor(ExecutorService receiveExecutor) Deprecated.voidsetReceiveHandler(IBufferHandler receiveHandler) Sets theIBufferHandlerto handle buffers received from the peer channel.voidtoString()protected voidMethods inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle
activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doAfterActivate, doBeforeDeactivate, doCancelActivation, dump, getLifecycleState, isActive, isDeferredActivationMethods inherited from class org.eclipse.net4j.util.event.Notifier
addListener, addUniqueListener, fireEvent, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListener, hasListeners, lastListenerRemoved, listenerAdded, listenerRemoved, removeListenerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle
activate, deactivate, getLifecycleState, isActiveMethods inherited from interface org.eclipse.net4j.util.event.INotifier
addListener, getListeners, hasListeners, removeListener
-
Constructor Details
-
Channel
public Channel()
-
-
Method Details
-
getContainer
public org.eclipse.net4j.util.container.IManagedContainer getContainer()- Specified by:
getContainerin interfaceorg.eclipse.net4j.util.container.IManagedContainerProvider
-
getUserID
- Specified by:
getUserIDin interfaceorg.eclipse.net4j.util.security.IUserAware
-
setUserID
- Specified by:
setUserIDin interfaceInternalChannel
-
getLocation
Description copied from interface:ILocationAware- Specified by:
getLocationin interfaceILocationAware
-
isClient
public boolean isClient()Description copied from interface:ILocationAware- Specified by:
isClientin interfaceILocationAware
-
isServer
public boolean isServer()Description copied from interface:ILocationAware- Specified by:
isServerin interfaceILocationAware
-
getMultiplexer
Description copied from interface:IChannelReturns the multiplexer this channel is associated with. This channel multiplexer can be used, for example, to open additional channels that will be multiplexed through the same transport medium.- Specified by:
getMultiplexerin interfaceIChannel
-
setMultiplexer
- Specified by:
setMultiplexerin interfaceInternalChannel
-
getID
public short getID()Description copied from interface:IChannelReturns the ID of this channel. The ID is unique at any time among all channels of the associatedmultiplexer. -
setID
public void setID(short id) - Specified by:
setIDin interfaceInternalChannel
-
getExecutorService
- Specified by:
getExecutorServicein interfaceorg.eclipse.net4j.util.concurrent.IExecutorServiceProvider- Since:
- 4.5
-
getReceiveExecutor
Deprecated.- Specified by:
getReceiveExecutorin interfaceInternalChannel
-
setReceiveExecutor
Deprecated.- Specified by:
setReceiveExecutorin interfaceInternalChannel
-
getReceiveHandler
Description copied from interface:IChannelReturns theIBufferHandlerthat handles buffers received from the peer channel.- Specified by:
getReceiveHandlerin interfaceIChannel
-
setReceiveHandler
Description copied from interface:IChannelSets theIBufferHandlerto handle buffers received from the peer channel.- Specified by:
setReceiveHandlerin interfaceIChannel
-
getSentBuffers
public long getSentBuffers()Description copied from interface:IChannelReturns the number ofbuffersthat are sent to themultiplexerof this channel.- Specified by:
getSentBuffersin interfaceIChannel- Since:
- 3.0
-
getSentBytes
public final long getSentBytes()Description copied from interface:IChannelReturns the number of bytes that are sent to themultiplexerof this channel.- Specified by:
getSentBytesin interfaceIChannel- Since:
- 4.13
-
getReceivedBuffers
public long getReceivedBuffers()Description copied from interface:IChannelReturns the number ofbuffersthat are received from themultiplexerof this channel and are passed on to thereceive handlerof this channel.- Specified by:
getReceivedBuffersin interfaceIChannel- Since:
- 3.0
-
getReceivedBytes
public final long getReceivedBytes()Description copied from interface:IChannelReturns the number of bytes that are received from themultiplexerof this channel and are passed on to thereceive handlerof this channel.- Specified by:
getReceivedBytesin interfaceIChannel- Since:
- 4.13
-
getSendQueue
- Specified by:
getSendQueuein interfaceInternalChannel
-
pinSendBuffer
Pins the active send-queue head while an asynchronous transport borrows its storage. The pin prevents channel deactivation from releasing a buffer while the transport may still access it.- Parameters:
buffer- the buffer at the head of this channel's send queue- Returns:
trueif the buffer was pinned- Since:
- 4.23
-
finishPinnedSendBuffer
Ends the pin for an asynchronous send. A completed send is removed and released; a rejected send remains queued for retry while the channel is active. The original queue is supplied because the channel may have closed or been activated again since selection.- Parameters:
queue- the queue from which the buffer was selectedbuffer- the buffer whose provider lease has endedrelease- whether a terminally completed send should be removed and released- Returns:
trueif this call removed and released the buffer- Since:
- 4.23
-
sendBuffer
Description copied from interface:IChannelAsynchronously sends the given buffer to the receive handler of the peer channel.- Specified by:
sendBufferin interfaceIChannel
-
handleBuffer
Handles the given buffer. Ensures it is in the PUTTING state (otherwise ignores it) and sends it on behalf of the send queue.- Specified by:
handleBufferin interfaceIBufferHandler- Parameters:
buffer- The buffer to be handled.- See Also:
-
handleBufferFromMultiplexer
Handles a buffer sent by the multiplexer. Adds work to the receive queue or releases the buffer.- Specified by:
handleBufferFromMultiplexerin interfaceInternalChannel- See Also:
-
createReceiverWork
Deprecated.As of 4.10 scheduled for future removal. -
getBufferCapacity
public short getBufferCapacity()Description copied from interface:IBufferProviderReturns the capacity, in bytes, of buffers returned byIBufferProvider.provideBuffer().- Specified by:
getBufferCapacityin interfaceIBufferProvider
-
provideBuffer
Description copied from interface:IBufferProviderProvides a buffer and transfers its current ownership to the caller.- Specified by:
provideBufferin interfaceIBufferProvider
-
retainBuffer
Description copied from interface:IBufferProviderAccepts a buffer whose caller has relinquished ownership. Implementations may keep it for reuse or release its storage; callers must not use the buffer after handing it over.- Specified by:
retainBufferin interfaceIBufferProvider
-
toString
- Overrides:
toStringin classorg.eclipse.net4j.util.lifecycle.Lifecycle
-
doBeforeActivate
-
doActivate
-
doDeactivate
-
unregisterFromMultiplexer
protected void unregisterFromMultiplexer() -
close
public void close()- Specified by:
closein interfaceorg.eclipse.net4j.util.collection.Closeable
-
isClosed
public boolean isClosed()- Specified by:
isClosedin interfaceorg.eclipse.net4j.util.collection.Closeable
-