org.jboss.netty.channel

## Class DefaultChannelPipeline

- java.lang.Object
- - org.jboss.netty.channel.DefaultChannelPipeline

All Implemented Interfaces:
  ChannelPipeline

    public class DefaultChannelPipeline
    extends Object
    implements ChannelPipeline

The default `ChannelPipeline` implementation. It is recommended to use `Channels.pipeline()` to create a new `ChannelPipeline` instance rather than calling the constructor directly.

### Constructor Summary

Constructors
Constructor and Description
`DefaultChannelPipeline()` Creates a new empty pipeline.

### Method Summary

Methods
`void` `addAfter(String baseName, String name, ChannelHandler handler)` Inserts a `ChannelHandler` after an existing handler of this pipeline.
`void` `addBefore(String baseName, String name, ChannelHandler handler)` Inserts a `ChannelHandler` before an existing handler of this pipeline.
`void` `addFirst(String name, ChannelHandler handler)` Inserts a `ChannelHandler` at the first position of this pipeline.
`void` `addLast(String name, ChannelHandler handler)` Appends a `ChannelHandler` at the last position of this pipeline.
`void` `attach(Channel channel, ChannelSink sink)` Attaches this pipeline to the specified `Channel` and `ChannelSink`.
`ChannelFuture` `execute(Runnable task)` Schedules the specified task to be executed in the I/O thread associated with this pipeline's `Channel`.
`<T extends ChannelHandler> T` `get(Class<T> handlerType)` Returns the `ChannelHandler` of the specified type in this pipeline.
`ChannelHandler` `get(String name)` Returns the `ChannelHandler` with the specified name in this pipeline.
`Channel` `getChannel()` Returns the `Channel` that this pipeline is attached to.
`ChannelHandlerContext` `getContext(ChannelHandler handler)` Returns the context object of the specified `ChannelHandler` in this pipeline.
`ChannelHandlerContext` `getContext(Class<? extends ChannelHandler> handlerType)` Returns the context object of the `ChannelHandler` of the specified type in this pipeline.
`ChannelHandlerContext` `getContext(String name)` Returns the context object of the `ChannelHandler` with the specified name in this pipeline.
`ChannelHandler` `getFirst()` Returns the first `ChannelHandler` in this pipeline.
`ChannelHandler` `getLast()` Returns the last `ChannelHandler` in this pipeline.
`List<String>` `getNames()` Returns the `List` of the handler names.
`ChannelSink` `getSink()` Returns the `ChannelSink` that this pipeline is attached to.
`boolean` `isAttached()` Returns `true` if and only if this pipeline is attached to a `Channel`.
`protected void` `notifyHandlerException(ChannelEvent e, Throwable t)`
`void` `remove(ChannelHandler handler)` Removes the specified `ChannelHandler` from this pipeline.
`<T extends ChannelHandler> T` `remove(Class<T> handlerType)` Removes the `ChannelHandler` of the specified type from this pipeline
`ChannelHandler` `remove(String name)` Removes the `ChannelHandler` with the specified name from this pipeline.
`ChannelHandler` `removeFirst()` Removes the first `ChannelHandler` in this pipeline.
`ChannelHandler` `removeLast()` Removes the last `ChannelHandler` in this pipeline.
`void` `replace(ChannelHandler oldHandler, String newName, ChannelHandler newHandler)` Replaces the specified `ChannelHandler` with a new handler in this pipeline.
`<T extends ChannelHandler> T` `replace(Class<T> oldHandlerType, String newName, ChannelHandler newHandler)` Replaces the `ChannelHandler` of the specified type with a new handler in this pipeline.
`ChannelHandler` `replace(String oldName, String newName, ChannelHandler newHandler)` Replaces the `ChannelHandler` of the specified name with a new handler in this pipeline.
`void` `sendDownstream(ChannelEvent e)` Sends the specified `ChannelEvent` to the last `ChannelDownstreamHandler` in this pipeline.
`void` `sendUpstream(ChannelEvent e)` Sends the specified `ChannelEvent` to the first `ChannelUpstreamHandler` in this pipeline.
`Map<String,ChannelHandler>` `toMap()` Converts this pipeline into an ordered `Map` whose keys are handler names and whose values are handlers.
`String` `toString()` Returns the `String` representation of this pipeline.

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

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

### Constructor Detail

#### DefaultChannelPipeline

    public DefaultChannelPipeline()

Creates a new empty pipeline.

### Method Detail

#### getChannel

    public Channel getChannel()

Description copied from interface: `ChannelPipeline`
Returns the `Channel` that this pipeline is attached to.

Specified by:
  `getChannel` in interface `ChannelPipeline`
Returns:
  the channel. `null` if this pipeline is not attached yet.

#### getSink

    public ChannelSink getSink()

Description copied from interface: `ChannelPipeline`
Returns the `ChannelSink` that this pipeline is attached to.

Specified by:
  `getSink` in interface `ChannelPipeline`
Returns:
  the sink. `null` if this pipeline is not attached yet.

#### attach

    public void attach(Channel channel,
              ChannelSink sink)

Description copied from interface: `ChannelPipeline`
Attaches this pipeline to the specified `Channel` and `ChannelSink`. Once a pipeline is attached, it can't be detached nor attached again.

Specified by:
  `attach` in interface `ChannelPipeline`

#### isAttached

    public boolean isAttached()

Description copied from interface: `ChannelPipeline`
Returns `true` if and only if this pipeline is attached to a `Channel`.

Specified by:
  `isAttached` in interface `ChannelPipeline`

#### addFirst

    public void addFirst(String name,
                ChannelHandler handler)

Description copied from interface: `ChannelPipeline`
Inserts a `ChannelHandler` at the first position of this pipeline.

Specified by:
  `addFirst` in interface `ChannelPipeline`
Parameters:
  `name` - the name of the handler to insert first
  `handler` - the handler to insert first

#### addLast

    public void addLast(String name,
               ChannelHandler handler)

Description copied from interface: `ChannelPipeline`
Appends a `ChannelHandler` at the last position of this pipeline.

Specified by:
  `addLast` in interface `ChannelPipeline`
Parameters:
  `name` - the name of the handler to append
  `handler` - the handler to append

#### addBefore

    public void addBefore(String baseName,
                 String name,
                 ChannelHandler handler)

Description copied from interface: `ChannelPipeline`
Inserts a `ChannelHandler` before an existing handler of this pipeline.

Specified by:
  `addBefore` in interface `ChannelPipeline`
Parameters:
  `baseName` - the name of the existing handler
  `name` - the name of the handler to insert before
  `handler` - the handler to insert before

#### addAfter

    public void addAfter(String baseName,
                String name,
                ChannelHandler handler)

Description copied from interface: `ChannelPipeline`
Inserts a `ChannelHandler` after an existing handler of this pipeline.

Specified by:
  `addAfter` in interface `ChannelPipeline`
Parameters:
  `baseName` - the name of the existing handler
  `name` - the name of the handler to insert after
  `handler` - the handler to insert after

#### remove

    public void remove(ChannelHandler handler)

Description copied from interface: `ChannelPipeline`
Removes the specified `ChannelHandler` from this pipeline.

Specified by:
  `remove` in interface `ChannelPipeline`

#### remove

    public ChannelHandler remove(String name)

Description copied from interface: `ChannelPipeline`
Removes the `ChannelHandler` with the specified name from this pipeline.

Specified by:
  `remove` in interface `ChannelPipeline`
Returns:
  the removed handler

#### remove

    public <T extends ChannelHandler> T remove(Class<T> handlerType)

Description copied from interface: `ChannelPipeline`
Removes the `ChannelHandler` of the specified type from this pipeline

Specified by:
  `remove` in interface `ChannelPipeline`
Type Parameters:
  `T` - the type of the handler
Parameters:
  `handlerType` - the type of the handler
Returns:
  the removed handler

#### removeFirst

    public ChannelHandler removeFirst()

Description copied from interface: `ChannelPipeline`
Removes the first `ChannelHandler` in this pipeline.

Specified by:
  `removeFirst` in interface `ChannelPipeline`
Returns:
  the removed handler

#### removeLast

    public ChannelHandler removeLast()

Description copied from interface: `ChannelPipeline`
Removes the last `ChannelHandler` in this pipeline.

Specified by:
  `removeLast` in interface `ChannelPipeline`
Returns:
  the removed handler

#### replace

    public void replace(ChannelHandler oldHandler,
               String newName,
               ChannelHandler newHandler)

Description copied from interface: `ChannelPipeline`
Replaces the specified `ChannelHandler` with a new handler in this pipeline.

Specified by:
  `replace` in interface `ChannelPipeline`

#### replace

    public ChannelHandler replace(String oldName,
                         String newName,
                         ChannelHandler newHandler)

Description copied from interface: `ChannelPipeline`
Replaces the `ChannelHandler` of the specified name with a new handler in this pipeline.

Specified by:
  `replace` in interface `ChannelPipeline`
Returns:
  the removed handler

#### replace

    public <T extends ChannelHandler> T replace(Class<T> oldHandlerType,
                                       String newName,
                                       ChannelHandler newHandler)

Description copied from interface: `ChannelPipeline`
Replaces the `ChannelHandler` of the specified type with a new handler in this pipeline.

Specified by:
  `replace` in interface `ChannelPipeline`
Returns:
  the removed handler

#### getFirst

    public ChannelHandler getFirst()

Description copied from interface: `ChannelPipeline`
Returns the first `ChannelHandler` in this pipeline.

Specified by:
  `getFirst` in interface `ChannelPipeline`
Returns:
  the first handler. `null` if this pipeline is empty.

#### getLast

    public ChannelHandler getLast()

Description copied from interface: `ChannelPipeline`
Returns the last `ChannelHandler` in this pipeline.

Specified by:
  `getLast` in interface `ChannelPipeline`
Returns:
  the last handler. `null` if this pipeline is empty.

#### get

    public ChannelHandler get(String name)

Description copied from interface: `ChannelPipeline`
Returns the `ChannelHandler` with the specified name in this pipeline.

Specified by:
  `get` in interface `ChannelPipeline`
Returns:
  the handler with the specified name. `null` if there's no such handler in this pipeline.

#### get

    public <T extends ChannelHandler> T get(Class<T> handlerType)

Description copied from interface: `ChannelPipeline`
Returns the `ChannelHandler` of the specified type in this pipeline.

Specified by:
  `get` in interface `ChannelPipeline`
Returns:
  the handler of the specified handler type. `null` if there's no such handler in this pipeline.

#### getContext

    public ChannelHandlerContext getContext(String name)

Description copied from interface: `ChannelPipeline`
Returns the context object of the `ChannelHandler` with the specified name in this pipeline.

Specified by:
  `getContext` in interface `ChannelPipeline`
Returns:
  the context object of the handler with the specified name. `null` if there's no such handler in this pipeline.

#### getContext

    public ChannelHandlerContext getContext(ChannelHandler handler)

Description copied from interface: `ChannelPipeline`
Returns the context object of the specified `ChannelHandler` in this pipeline.

Specified by:
  `getContext` in interface `ChannelPipeline`
Returns:
  the context object of the specified handler. `null` if there's no such handler in this pipeline.

#### getContext

    public ChannelHandlerContext getContext(Class<? extends ChannelHandler> handlerType)

Description copied from interface: `ChannelPipeline`
Returns the context object of the `ChannelHandler` of the specified type in this pipeline.

Specified by:
  `getContext` in interface `ChannelPipeline`
Returns:
  the context object of the handler of the specified type. `null` if there's no such handler in this pipeline.

#### getNames

    public List<String> getNames()

Description copied from interface: `ChannelPipeline`
Returns the `List` of the handler names.

Specified by:
  `getNames` in interface `ChannelPipeline`

#### toMap

    public Map<String,ChannelHandler> toMap()

Description copied from interface: `ChannelPipeline`
Converts this pipeline into an ordered `Map` whose keys are handler names and whose values are handlers.

Specified by:
  `toMap` in interface `ChannelPipeline`

#### toString

    public String toString()

Returns the `String` representation of this pipeline.

Overrides:
  `toString` in class `Object`

#### sendUpstream

    public void sendUpstream(ChannelEvent e)

Description copied from interface: `ChannelPipeline`
Sends the specified `ChannelEvent` to the first `ChannelUpstreamHandler` in this pipeline.

Specified by:
  `sendUpstream` in interface `ChannelPipeline`

#### sendDownstream

    public void sendDownstream(ChannelEvent e)

Description copied from interface: `ChannelPipeline`
Sends the specified `ChannelEvent` to the last `ChannelDownstreamHandler` in this pipeline.

Specified by:
  `sendDownstream` in interface `ChannelPipeline`

#### execute

    public ChannelFuture execute(Runnable task)

Description copied from interface: `ChannelPipeline`
Schedules the specified task to be executed in the I/O thread associated with this pipeline's `Channel`.

Specified by:
  `execute` in interface `ChannelPipeline`

#### notifyHandlerException

    protected void notifyHandlerException(ChannelEvent e,
                              Throwable t)