org.eclipse.spi.net4j

## 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, Closeable, IExecutorServiceProvider, INotifier, IDeactivateable, ILifecycle, ILifecycle.DeferrableActivation, IUserAware, InternalChannel

      public class Channel
      extends Lifecycle
      implements InternalChannel, IExecutorServiceProvider

  If the meaning of this type isn't clear, there really should be more of a description here...
  Since:
    2.0
  Author:
    Eike Stepper

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `Channel.ReceiverWork` If the meaning of this type isn't clear, there really should be more of a description here...
    `protected class` | `Channel.ReceiveSerializer` Deprecated. As of 4.4 scheduled for future removal.
    `protected class` | `Channel.SendQueue` A queue that holds buffers that shall be sent.

    - ### Nested classes/interfaces inherited from interface org.eclipse.spi.net4j.InternalChannel

      `InternalChannel.SendQueueEvent`

    - ### Nested classes/interfaces inherited from interface org.eclipse.net4j.ILocationAware

      `ILocationAware.Location`

    - ### Nested classes/interfaces inherited from interface org.eclipse.net4j.buffer.IBufferProvider

      `IBufferProvider.Introspection, IBufferProvider.Notification`

    - ### Nested classes/interfaces inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle

      `ILifecycle.DeferrableActivation`

  - ### Field Summary

    - ### Fields inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

      `USE_LABEL`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Channel()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `protected Channel.ReceiverWork` | `createReceiverWork(IBuffer buffer)`
    `protected void` | `doActivate()`
    `protected void` | `doBeforeActivate()`
    `protected void` | `doDeactivate()`
    `short` | `getBufferCapacity()` Returns the capacity of the buffers provided by `IBufferProvider.provideBuffer()` .
    `java.util.concurrent.ExecutorService` | `getExecutorService()`
    `short` | `getID()` Returns the ID of this channel.
    `ILocationAware.Location` | `getLocation()` Returns the location of this object in a `client`/`server` scenario.
    `IChannelMultiplexer` | `getMultiplexer()` Returns the multiplexer this channel is associated with.
    `long` | `getReceivedBuffers()`
    `java.util.concurrent.ExecutorService` | `getReceiveExecutor()` Deprecated.
    `IBufferHandler` | `getReceiveHandler()` Returns the `IBufferHandler` that handles buffers received from the peer channel.
    `java.util.Queue<IBuffer>` | `getSendQueue()`
    `long` | `getSentBuffers()`
    `java.lang.String` | `getUserID()`
    `void` | `handleBuffer(IBuffer buffer)` Handles the given buffer.
    `void` | `handleBufferFromMultiplexer(IBuffer buffer)` Handles a buffer sent by the multiplexer.
    `boolean` | `isClient()` Same as ``ILocationAware.getLocation()` == `ILocationAware.Location.CLIENT``.
    `boolean` | `isClosed()`
    `boolean` | `isServer()` Same as ``ILocationAware.getLocation()` == `ILocationAware.Location.SERVER``.
    `IBuffer` | `provideBuffer()` Provides a buffer from this `BufferProvider`.
    `void` | `retainBuffer(IBuffer buffer)` Retains a buffer to this `BufferProvider`.
    `void` | `sendBuffer(IBuffer buffer)` Asynchronously sends the given buffer to the receive handler of the peer channel.
    `void` | `setID(short id)`
    `void` | `setMultiplexer(IChannelMultiplexer channelMultiplexer)`
    `void` | `setReceiveExecutor(java.util.concurrent.ExecutorService receiveExecutor)` Deprecated.
    `void` | `setReceiveHandler(IBufferHandler receiveHandler)` Sets the `IBufferHandler` to handle buffers received from the peer channel.
    `void` | `setUserID(java.lang.String userID)`
    `java.lang.String` | `toString()`
    `protected void` | `unregisterFromMultiplexer()`

    - ### Methods inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

      `activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doAfterActivate, doBeforeDeactivate, dump, getLifecycleState, isActive, isDeferredActivation`

    - ### Methods inherited from class org.eclipse.net4j.util.event.Notifier

      `addListener, fireEvent, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListeners, lastListenerRemoved, removeListener`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle

      `activate, deactivate, getLifecycleState, isActive`

    - ### Methods inherited from interface org.eclipse.net4j.util.event.INotifier

      `addListener, getListeners, hasListeners, removeListener`

- - ### Constructor Detail

    - #### Channel

          public Channel()

  - ### Method Detail

    - #### getUserID

          public java.lang.String getUserID()

      Specified by:
        `getUserID` in interface `IUserAware`

    - #### setUserID

          public void setUserID(java.lang.String userID)

      Specified by:
        `setUserID` in interface `InternalChannel`

    - #### getLocation

          public ILocationAware.Location getLocation()

      Description copied from interface: `ILocationAware`
      Returns the location of this object in a `client`/`server` scenario.
      Specified by:
        `getLocation` in interface `ILocationAware`

    - #### isClient

          public boolean isClient()

      Description copied from interface: `ILocationAware`
      Same as ``ILocationAware.getLocation()` == `ILocationAware.Location.CLIENT``.
      Specified by:
        `isClient` in interface `ILocationAware`

    - #### isServer

          public boolean isServer()

      Description copied from interface: `ILocationAware`
      Same as ``ILocationAware.getLocation()` == `ILocationAware.Location.SERVER``.
      Specified by:
        `isServer` in interface `ILocationAware`

    - #### getMultiplexer

          public IChannelMultiplexer getMultiplexer()

      Description copied from interface: `IChannel`
      Returns 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:
        `getMultiplexer` in interface `IChannel`

    - #### setMultiplexer

          public void setMultiplexer(IChannelMultiplexer channelMultiplexer)

      Specified by:
        `setMultiplexer` in interface `InternalChannel`

    - #### getID

          public short getID()

      Description copied from interface: `IChannel`
      Returns the ID of this channel. The ID is unique at any time among all channels of the associated `multiplexer`.
      Specified by:
        `getID` in interface `IChannel`

    - #### setID

          public void setID(short id)

      Specified by:
        `setID` in interface `InternalChannel`

    - #### getExecutorService

          public java.util.concurrent.ExecutorService getExecutorService()

      Specified by:
        `getExecutorService` in interface `IExecutorServiceProvider`
      Since:
        4.5

    - #### getReceiveExecutor

          @Deprecated
          public java.util.concurrent.ExecutorService getReceiveExecutor()

      Deprecated.
      Specified by:
        `getReceiveExecutor` in interface `InternalChannel`

    - #### setReceiveExecutor

          @Deprecated
          public void setReceiveExecutor(java.util.concurrent.ExecutorService receiveExecutor)

      Deprecated.
      Specified by:
        `setReceiveExecutor` in interface `InternalChannel`

    - #### getReceiveHandler

          public IBufferHandler getReceiveHandler()

      Description copied from interface: `IChannel`
      Returns the `IBufferHandler` that handles buffers received from the peer channel.
      Specified by:
        `getReceiveHandler` in interface `IChannel`

    - #### setReceiveHandler

          public void setReceiveHandler(IBufferHandler receiveHandler)

      Description copied from interface: `IChannel`
      Sets the `IBufferHandler` to handle buffers received from the peer channel.
      Specified by:
        `setReceiveHandler` in interface `IChannel`

    - #### getSentBuffers

          public long getSentBuffers()

      Specified by:
        `getSentBuffers` in interface `InternalChannel`
      Since:
        3.0

    - #### getReceivedBuffers

          public long getReceivedBuffers()

      Specified by:
        `getReceivedBuffers` in interface `InternalChannel`
      Since:
        3.0

    - #### getSendQueue

          public java.util.Queue<IBuffer> getSendQueue()

      Specified by:
        `getSendQueue` in interface `InternalChannel`

    - #### sendBuffer

          public void sendBuffer(IBuffer buffer)

      Description copied from interface: `IChannel`
      Asynchronously sends the given buffer to the receive handler of the peer channel.
      Specified by:
        `sendBuffer` in interface `IChannel`

    - #### handleBuffer

          public void handleBuffer(IBuffer buffer)

      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:
        `handleBuffer` in interface `IBufferHandler`
      Parameters:
        `buffer` - The buffer to be handled and otionally released.
      See Also:
        `IBuffer.getState()`, `BufferState.PUTTING`, `sendQueue`

    - #### handleBufferFromMultiplexer

          public void handleBufferFromMultiplexer(IBuffer buffer)

      Handles a buffer sent by the multiplexer. Adds work to the receive queue or releases the buffer.
      Specified by:
        `handleBufferFromMultiplexer` in interface `InternalChannel`
      See Also:
        `InternalChannelMultiplexer.multiplexChannel(org.eclipse.spi.net4j.InternalChannel)`

    - #### createReceiverWork

          protected Channel.ReceiverWork createReceiverWork(IBuffer buffer)

    - #### getBufferCapacity

          public short getBufferCapacity()

      Description copied from interface: `IBufferProvider`
      Returns the capacity of the buffers provided by `IBufferProvider.provideBuffer()` .
      Specified by:
        `getBufferCapacity` in interface `IBufferProvider`

    - #### provideBuffer

          public IBuffer provideBuffer()

      Description copied from interface: `IBufferProvider`
      Provides a buffer from this `BufferProvider`.
      Specified by:
        `provideBuffer` in interface `IBufferProvider`

    - #### retainBuffer

          public void retainBuffer(IBuffer buffer)

      Description copied from interface: `IBufferProvider`
      Retains a buffer to this `BufferProvider`.
      Specified by:
        `retainBuffer` in interface `IBufferProvider`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `Lifecycle`

    - #### doBeforeActivate

          protected void doBeforeActivate()
                                   throws java.lang.Exception

      Overrides:
        `doBeforeActivate` in class `Lifecycle`
      Throws:
        `java.lang.Exception`

    - #### doActivate

          protected void doActivate()
                             throws java.lang.Exception

      Overrides:
        `doActivate` in class `Lifecycle`
      Throws:
        `java.lang.Exception`

    - #### doDeactivate

          protected void doDeactivate()
                               throws java.lang.Exception

      Overrides:
        `doDeactivate` in class `Lifecycle`
      Throws:
        `java.lang.Exception`

    - #### unregisterFromMultiplexer

          protected void unregisterFromMultiplexer()

    - #### close

          public void close()

      Specified by:
        `close` in interface `Closeable`

    - #### isClosed

          public boolean isClosed()

      Specified by:
        `isClosed` in interface `Closeable`

Copyright (c) 2004-2019 Eike Stepper (Loehne, Germany) and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html