2008-08-08 02:37:18 +02:00
|
|
|
/*
|
2008-08-08 03:27:24 +02:00
|
|
|
* JBoss, Home of Professional Open Source
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
2008-08-08 03:27:24 +02:00
|
|
|
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
|
|
|
|
* by the @author tags. See the COPYRIGHT.txt in the distribution for a
|
|
|
|
* full listing of individual contributors.
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
2008-08-08 03:27:24 +02:00
|
|
|
* This is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2.1 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed in the hope that it will be useful,
|
2008-08-08 02:37:18 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2008-08-08 03:27:24 +02:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2008-08-08 02:37:18 +02:00
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2008-08-08 03:27:24 +02:00
|
|
|
* License along with this software; if not, write to the Free
|
|
|
|
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
|
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
2008-08-08 03:40:10 +02:00
|
|
|
package org.jboss.netty.channel;
|
2008-08-08 02:37:18 +02:00
|
|
|
|
|
|
|
import java.util.Map;
|
2008-09-02 14:04:04 +02:00
|
|
|
import java.util.NoSuchElementException;
|
2008-08-08 02:37:18 +02:00
|
|
|
|
2008-09-01 17:52:26 +02:00
|
|
|
import org.jboss.netty.buffer.ChannelBuffer;
|
|
|
|
import org.jboss.netty.handler.execution.ExecutionHandler;
|
2008-09-02 16:12:56 +02:00
|
|
|
import org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor;
|
2008-09-01 17:19:34 +02:00
|
|
|
import org.jboss.netty.handler.ssl.SslHandler;
|
|
|
|
|
2008-08-08 02:37:18 +02:00
|
|
|
|
|
|
|
/**
|
2008-09-02 14:04:04 +02:00
|
|
|
* A list of {@link ChannelHandler}s which handles or intercepts
|
2008-09-03 03:48:08 +02:00
|
|
|
* {@link ChannelEvent}s of a {@link Channel}. {@link ChannelPipeline}
|
|
|
|
* implements an advanced form of the
|
2008-09-01 17:52:26 +02:00
|
|
|
* <a href="http://java.sun.com/blueprints/corej2eepatterns/Patterns/InterceptingFilter.html">Intercepting
|
|
|
|
* Filter</a> pattern to give a user full control over how an event is handled
|
2008-09-02 14:04:04 +02:00
|
|
|
* and how the {@link ChannelHandler}s in the pipeline interact with each other.
|
2008-09-02 16:12:56 +02:00
|
|
|
*
|
2008-09-03 03:48:08 +02:00
|
|
|
* <h3>Creation of a pipeline</h3>
|
|
|
|
* <p>
|
|
|
|
* It is recommended to create a new pipeline using the helper methods in
|
|
|
|
* {@link Channels} rather than calling an individual implementation's
|
2009-04-08 10:41:22 +02:00
|
|
|
* constructor:
|
|
|
|
* <pre>
|
|
|
|
* import static org.jboss.netty.channel.Channels.*;
|
|
|
|
* ChannelPipeline pipeline = pipeline(); // same with Channels.pipeline()
|
|
|
|
* </pre>
|
2008-09-03 03:48:08 +02:00
|
|
|
*
|
2008-09-01 17:19:34 +02:00
|
|
|
* <h3>How an event flows in a pipeline</h3>
|
|
|
|
* <p>
|
2008-09-01 17:56:45 +02:00
|
|
|
* The following diagram describes how {@link ChannelEvent}s are processed by
|
2008-09-02 15:45:14 +02:00
|
|
|
* {@link ChannelHandler}s in a {@link ChannelPipeline} typically.
|
|
|
|
* A {@link ChannelEvent} can be handled by either a {@link ChannelUpstreamHandler}
|
2008-09-03 03:48:08 +02:00
|
|
|
* or a {@link ChannelDownstreamHandler} and be forwarded to the next or
|
|
|
|
* previous handler by calling {@link ChannelHandlerContext#sendUpstream(ChannelEvent)}
|
|
|
|
* or {@link ChannelHandlerContext#sendDownstream(ChannelEvent)}. The meaning
|
2008-11-14 08:45:53 +01:00
|
|
|
* of the event is interpreted somewhat differently depending on whether it is
|
2008-09-03 03:48:08 +02:00
|
|
|
* going upstream or going downstream. Please refer to {@link ChannelEvent} for
|
2008-11-14 09:02:42 +01:00
|
|
|
* more information.
|
2008-09-01 17:19:34 +02:00
|
|
|
*
|
|
|
|
* <pre>
|
2008-09-03 03:48:08 +02:00
|
|
|
*
|
2008-09-03 04:59:25 +02:00
|
|
|
* I/O Request
|
|
|
|
* via {@link Channel} or
|
|
|
|
* {@link ChannelHandlerContext}
|
|
|
|
* |
|
|
|
|
* +---------------------------------------------+--------------------+
|
|
|
|
* | ChannelPipeline | |
|
|
|
|
* | \|/ |
|
|
|
|
* | +----------------------+ +-----------+------------+ |
|
|
|
|
* | LAST | Upstream Handler N | | Downstream Handler M | LAST |
|
|
|
|
* | . +----------+-----------+ +-----------+------------+ . |
|
|
|
|
* | . /|\ | . |
|
|
|
|
* | . | \|/ . |
|
|
|
|
* | . +----------+-----------+ +-----------+------------+ . |
|
|
|
|
* | . | Upstream Handler N-1 | | Downstream Handler M-1 | . |
|
|
|
|
* | . +----------+-----------+ +-----------+------------+ . |
|
|
|
|
* | . /|\ . . |
|
|
|
|
* | . . . . |
|
|
|
|
* | . [ Going UPSTREAM ] [ Going DOWNSTREAM ] . |
|
|
|
|
* | . . . . |
|
|
|
|
* | . . \|/ . |
|
|
|
|
* | . +----------+-----------+ +-----------+------------+ . |
|
|
|
|
* | . | Upstream Handler 2 | | Downstream Handler 2 | . |
|
|
|
|
* | . +----------+-----------+ +-----------+------------+ . |
|
|
|
|
* | . /|\ | . |
|
|
|
|
* | . | \|/ . |
|
|
|
|
* | . +----------+-----------+ +-----------+------------+ . |
|
|
|
|
* | FIRST | Upstream Handler 1 | | Downstream Handler 1 | FIRST |
|
|
|
|
* | +----------+-----------+ +-----------+------------+ |
|
|
|
|
* | /|\ | |
|
|
|
|
* +------------------+--------------------------+--------------------+
|
|
|
|
* | \|/
|
|
|
|
* +------------------+--------------------------+--------------------+
|
|
|
|
* | I/O Threads (Transport Implementation) |
|
|
|
|
* +------------------------------------------------------------------+
|
2008-09-01 17:19:34 +02:00
|
|
|
* </pre>
|
2008-11-14 09:02:42 +01:00
|
|
|
* Please note that an upstream event flows from the first upstream handler
|
2008-09-03 05:10:00 +02:00
|
|
|
* to the last upstream handler (i.e. to the next) and a downstream event
|
|
|
|
* flows from the last downstream handler to the first downstream handler
|
|
|
|
* (i.e. to the previous).
|
2009-04-08 10:38:06 +02:00
|
|
|
* <p>
|
|
|
|
* For example, let us assume that we created the following pipeline:
|
|
|
|
* <pre>
|
|
|
|
* ChannelPipeline p = Channels.pipeline();
|
|
|
|
* p.addLast("1", new UpstreamHandlerA());
|
|
|
|
* p.addLast("2", new UpstreamHandlerB());
|
|
|
|
*.p.addLast("3", new DownstreamHandlerA());
|
|
|
|
*.p.addLast("4", new DownstreamHandlerB());
|
|
|
|
* p.addLast("5", new UpstreamHandlerX());
|
|
|
|
* </pre>
|
|
|
|
* The class whose name starts with {@code Upstream} means it is an upstream
|
|
|
|
* handler. The class whose name starts with {@code Downstream} means it is a
|
|
|
|
* downstream handler.
|
|
|
|
* <p>
|
|
|
|
* In the given example configuration, the handler evaluation order is 1, 2, 3,
|
|
|
|
* 4, 5 when an event goes upstream. When an event goes downstream, the order
|
|
|
|
* is 5, 4, 3, 2, 1. On top of this principle, {@link ChannelPipeline} skips
|
|
|
|
* the evaluation of certain handlers to shorten the stack depth:
|
|
|
|
* <ul>
|
|
|
|
* <li>3 and 4 don't implement {@link ChannelUpstreamHandler}, and therefore the
|
|
|
|
* actual evaluation order of an upstream event will be: 1, 2, and 5.</li>
|
|
|
|
* <li>1, 2, and 5 don't implement {@link ChannelDownstreamHandler}, and
|
|
|
|
* therefore the actual evaluation order of a downstream event will be:
|
|
|
|
* 4 and 3.</li>
|
|
|
|
* <li>If 5 extended {@link SimpleChannelHandler} which implements both
|
|
|
|
* {@link ChannelUpstreamHandler} and {@link ChannelDownstreamHandler}, the
|
|
|
|
* evaluation order of an upstream and a downstream event could be 125 and
|
|
|
|
* 543 respectively.</li>
|
|
|
|
* </ul>
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
2008-09-03 03:12:37 +02:00
|
|
|
* <h3>Building a pipeline</h3>
|
|
|
|
* <p>
|
|
|
|
* A user is supposed to have one or more {@link ChannelHandler}s in a
|
|
|
|
* pipeline to receive I/O events (e.g. read) and to request I/O operations
|
|
|
|
* (e.g. write and close). For example, a typical server will have the following
|
|
|
|
* handlers in each channel's pipeline, but your mileage may vary depending on
|
|
|
|
* the complexity and characteristics of the protocol and business logic:
|
|
|
|
*
|
|
|
|
* <ol>
|
|
|
|
* <li>Protocol Decoder - translates binary data (e.g. {@link ChannelBuffer})
|
|
|
|
* into a Java object.</li>
|
|
|
|
* <li>Protocol Encoder - translates a Java object into binary data.</li>
|
|
|
|
* <li>{@link ExecutionHandler} - applies a thread model.</li>
|
|
|
|
* <li>Business Logic Handler - performs the actual business logic
|
|
|
|
* (e.g. database access).</li>
|
|
|
|
* </ol>
|
|
|
|
*
|
|
|
|
* and it could be represented as shown in the following example:
|
|
|
|
*
|
|
|
|
* <pre>
|
|
|
|
* ChannelPipeline pipeline = {@link Channels#pipeline() Channels.pipeline()};
|
|
|
|
* pipeline.addLast("decoder", new MyProtocolDecoder());
|
|
|
|
* pipeline.addLast("encoder", new MyProtocolEncoder());
|
|
|
|
* pipeline.addLast("executor", new {@link ExecutionHandler}(new {@link OrderedMemoryAwareThreadPoolExecutor}(16, 1048576, 1048576)));
|
|
|
|
* pipeline.addLast("handler", new MyBusinessLogicHandler());
|
|
|
|
* </pre>
|
|
|
|
*
|
|
|
|
* <h3>Thread safety</h3>
|
|
|
|
* <p>
|
|
|
|
* A {@link ChannelHandler} can be added or removed at any time because a
|
|
|
|
* {@link ChannelPipeline} is thread safe. For example, you can insert a
|
2008-11-14 09:02:42 +01:00
|
|
|
* {@link SslHandler} when sensitive information is about to be exchanged,
|
2008-09-03 03:12:37 +02:00
|
|
|
* and remove it after the exchange.
|
|
|
|
*
|
2008-08-08 03:27:24 +02:00
|
|
|
* @author The Netty Project (netty-dev@lists.jboss.org)
|
|
|
|
* @author Trustin Lee (tlee@redhat.com)
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
|
|
|
* @version $Rev$, $Date$
|
|
|
|
*
|
|
|
|
* @apiviz.landmark
|
2008-08-08 03:40:10 +02:00
|
|
|
* @apiviz.composedOf org.jboss.netty.channel.ChannelHandlerContext
|
|
|
|
* @apiviz.owns org.jboss.netty.channel.ChannelHandler
|
|
|
|
* @apiviz.uses org.jboss.netty.channel.ChannelSink - - sends events downstream
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
|
|
|
public interface ChannelPipeline {
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Inserts a {@link ChannelHandler} at the first position of this pipeline.
|
|
|
|
*
|
|
|
|
* @param name the name of the handler to insert first
|
|
|
|
* @param handler the handler to insert first
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @throws IllegalArgumentException
|
|
|
|
* if there's an entry with the same name already in the pipeline
|
|
|
|
* @throws NullPointerException
|
|
|
|
* if the specified name or handler is {@code null}
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void addFirst (String name, ChannelHandler handler);
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends a {@link ChannelHandler} at the last position of this pipeline.
|
|
|
|
*
|
|
|
|
* @param name the name of the handler to append
|
|
|
|
* @param handler the handler to append
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @throws IllegalArgumentException
|
|
|
|
* if there's an entry with the same name already in the pipeline
|
|
|
|
* @throws NullPointerException
|
|
|
|
* if the specified name or handler is {@code null}
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void addLast (String name, ChannelHandler handler);
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Inserts a {@link ChannelHandler} before an existing handler of this
|
|
|
|
* pipeline.
|
|
|
|
*
|
|
|
|
* @param baseName the name of the existing handler
|
|
|
|
* @param name the name of the handler to insert before
|
|
|
|
* @param handler the handler to insert before
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @throws NoSuchElementException
|
|
|
|
* if there's no such entry with the specified {@code baseName}
|
|
|
|
* @throws IllegalArgumentException
|
|
|
|
* if there's an entry with the same name already in the pipeline
|
|
|
|
* @throws NullPointerException
|
|
|
|
* if the specified baseName, name, or handler is {@code null}
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void addBefore(String baseName, String name, ChannelHandler handler);
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Inserts a {@link ChannelHandler} after an existing handler of this
|
|
|
|
* pipeline.
|
|
|
|
*
|
|
|
|
* @param baseName the name of the existing handler
|
|
|
|
* @param name the name of the handler to insert after
|
|
|
|
* @param handler the handler to insert after
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @throws NoSuchElementException
|
|
|
|
* if there's no such entry with the specified {@code baseName}
|
|
|
|
* @throws IllegalArgumentException
|
|
|
|
* if there's an entry with the same name already in the pipeline
|
|
|
|
* @throws NullPointerException
|
|
|
|
* if the specified baseName, name, or handler is {@code null}
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void addAfter (String baseName, String name, ChannelHandler handler);
|
|
|
|
|
2008-09-02 12:39:57 +02:00
|
|
|
/**
|
|
|
|
* Removes the specified {@link ChannelHandler} from this pipeline.
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @throws NoSuchElementException
|
|
|
|
* if there's no such handler in this pipeline
|
|
|
|
* @throws NullPointerException
|
|
|
|
* if the specified handler is {@code null}
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void remove(ChannelHandler handler);
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the {@link ChannelHandler} with the specified name from this
|
|
|
|
* pipeline.
|
|
|
|
*
|
|
|
|
* @return the removed handler
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @throws NoSuchElementException
|
|
|
|
* if there's no such handler with the specified name in this pipeline
|
|
|
|
* @throws NullPointerException
|
|
|
|
* if the specified name is {@code null}
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelHandler remove(String name);
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the {@link ChannelHandler} of the specified type from this
|
|
|
|
* pipeline
|
|
|
|
*
|
|
|
|
* @param <T> the type of the handler
|
|
|
|
* @param handlerType the type of the handler
|
|
|
|
*
|
|
|
|
* @return the removed handler
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @throws NoSuchElementException
|
|
|
|
* if there's no such handler of the specified type in this pipeline
|
|
|
|
* @throws NullPointerException
|
|
|
|
* if the specified handler type is {@code null}
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
<T extends ChannelHandler> T remove(Class<T> handlerType);
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the first {@link ChannelHandler} in this pipeline.
|
|
|
|
*
|
|
|
|
* @return the removed handler
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @throws NoSuchElementException
|
|
|
|
* if this pipeline is empty
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelHandler removeFirst();
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the last {@link ChannelHandler} in this pipeline.
|
|
|
|
*
|
|
|
|
* @return the removed handler
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @throws NoSuchElementException
|
|
|
|
* if this pipeline is empty
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelHandler removeLast();
|
|
|
|
|
2008-09-02 12:39:57 +02:00
|
|
|
/**
|
|
|
|
* Replaces the specified {@link ChannelHandler} with a new handler in
|
|
|
|
* this pipeline.
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @throws NoSuchElementException
|
2008-11-14 08:45:53 +01:00
|
|
|
* if the specified old handler does not exist in this pipeline
|
2008-09-02 14:04:04 +02:00
|
|
|
* @throws IllegalArgumentException
|
|
|
|
* if a handler with the specified new name already exists in this
|
|
|
|
* pipeline, except for the handler to be replaced
|
|
|
|
* @throws NullPointerException
|
|
|
|
* if the specified old handler, new name, or new handler is
|
|
|
|
* {@code null}
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void replace(ChannelHandler oldHandler, String newName, ChannelHandler newHandler);
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Replaces the {@link ChannelHandler} of the specified name with a new
|
|
|
|
* handler in this pipeline.
|
|
|
|
*
|
|
|
|
* @return the removed handler
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @throws NoSuchElementException
|
2008-11-14 08:45:53 +01:00
|
|
|
* if the handler with the specified old name does not exist in this pipeline
|
2008-09-02 14:04:04 +02:00
|
|
|
* @throws IllegalArgumentException
|
|
|
|
* if a handler with the specified new name already exists in this
|
|
|
|
* pipeline, except for the handler to be replaced
|
|
|
|
* @throws NullPointerException
|
|
|
|
* if the specified old handler, new name, or new handler is
|
|
|
|
* {@code null}
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelHandler replace(String oldName, String newName, ChannelHandler newHandler);
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Replaces the {@link ChannelHandler} of the specified type with a new
|
|
|
|
* handler in this pipeline.
|
|
|
|
*
|
|
|
|
* @return the removed handler
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @throws NoSuchElementException
|
2008-11-14 08:45:53 +01:00
|
|
|
* if the handler of the specified old handler type does not exist
|
2008-09-02 14:04:04 +02:00
|
|
|
* in this pipeline
|
|
|
|
* @throws IllegalArgumentException
|
|
|
|
* if a handler with the specified new name already exists in this
|
|
|
|
* pipeline, except for the handler to be replaced
|
|
|
|
* @throws NullPointerException
|
|
|
|
* if the specified old handler, new name, or new handler is
|
|
|
|
* {@code null}
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
<T extends ChannelHandler> T replace(Class<T> oldHandlerType, String newName, ChannelHandler newHandler);
|
|
|
|
|
2008-09-02 12:39:57 +02:00
|
|
|
/**
|
|
|
|
* Returns the first {@link ChannelHandler} in this pipeline.
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @return the first handler. {@code null} if this pipeline is empty.
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelHandler getFirst();
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the last {@link ChannelHandler} in this pipeline.
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @return the last handler. {@code null} if this pipeline is empty.
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelHandler getLast();
|
|
|
|
|
2008-09-02 12:39:57 +02:00
|
|
|
/**
|
|
|
|
* Returns the {@link ChannelHandler} with the specified name in this
|
|
|
|
* pipeline.
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @return the handler with the specified name.
|
|
|
|
* {@code null} if there's no such handler in this pipeline.
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelHandler get(String name);
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the {@link ChannelHandler} of the specified type in this
|
|
|
|
* pipeline.
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @return the handler of the specified handler type.
|
|
|
|
* {@code null} if there's no such handler in this pipeline.
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
<T extends ChannelHandler> T get(Class<T> handlerType);
|
|
|
|
|
2008-09-02 12:39:57 +02:00
|
|
|
/**
|
|
|
|
* Returns the context object of the specified {@link ChannelHandler} in
|
|
|
|
* this pipeline.
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @return the context object of the specified handler.
|
|
|
|
* {@code null} if there's no such handler in this pipeline.
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelHandlerContext getContext(ChannelHandler handler);
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the context object of the {@link ChannelHandler} with the
|
|
|
|
* specified name in this pipeline.
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @return the context object of the handler with the specified name.
|
|
|
|
* {@code null} if there's no such handler in this pipeline.
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelHandlerContext getContext(String name);
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the context object of the {@link ChannelHandler} of the
|
|
|
|
* specified type in this pipeline.
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @return the context object of the handler of the specified type.
|
|
|
|
* {@code null} if there's no such handler in this pipeline.
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelHandlerContext getContext(Class<? extends ChannelHandler> handlerType);
|
|
|
|
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
2008-09-24 11:48:32 +02:00
|
|
|
* Sends the specified {@link ChannelEvent} to the first
|
2008-09-02 12:39:57 +02:00
|
|
|
* {@link ChannelUpstreamHandler} in this pipeline.
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @throws NullPointerException
|
|
|
|
* if the specified event is {@code null}
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void sendUpstream(ChannelEvent e);
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
2008-09-24 11:48:32 +02:00
|
|
|
* Sends the specified {@link ChannelEvent} to the last
|
2008-09-02 12:39:57 +02:00
|
|
|
* {@link ChannelDownstreamHandler} in this pipeline.
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @throws NullPointerException
|
|
|
|
* if the specified event is {@code null}
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void sendDownstream(ChannelEvent e);
|
|
|
|
|
2008-09-02 12:39:57 +02:00
|
|
|
/**
|
|
|
|
* Returns the {@link Channel} that this pipeline is attached to.
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @return the channel. {@code null} if this pipeline is not attached yet.
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
Channel getChannel();
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the {@link ChannelSink} that this pipeline is attached to.
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @return the sink. {@code null} if this pipeline is not attached yet.
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
ChannelSink getSink();
|
2008-09-02 12:39:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Attaches this pipeline to the specified {@link Channel} and
|
|
|
|
* {@link ChannelSink}. Once a pipeline is attached, it can't be detached
|
|
|
|
* nor attached again.
|
2008-09-02 14:04:04 +02:00
|
|
|
*
|
|
|
|
* @throws IllegalStateException if this pipeline is attached already
|
2008-09-02 12:39:57 +02:00
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
void attach(Channel channel, ChannelSink sink);
|
|
|
|
|
2008-12-03 08:14:22 +01:00
|
|
|
/**
|
|
|
|
* Returns {@code true} if and only if this pipeline is attached to
|
|
|
|
* a {@link Channel}.
|
|
|
|
*/
|
|
|
|
boolean isAttached();
|
|
|
|
|
2008-09-02 12:39:57 +02:00
|
|
|
/**
|
|
|
|
* Converts this pipeline into an ordered {@link Map} whose keys are
|
|
|
|
* handler names and whose values are handlers.
|
|
|
|
*/
|
2008-08-08 02:37:18 +02:00
|
|
|
Map<String, ChannelHandler> toMap();
|
|
|
|
}
|