Added some links into the example code

This commit is contained in:
Trustin Lee 2008-09-02 14:12:56 +00:00
parent 92ec297756
commit c05a337d74
9 changed files with 69 additions and 30 deletions

View File

@ -24,6 +24,7 @@ package org.jboss.netty.bootstrap;
import static org.jboss.netty.channel.Channels.*;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
@ -53,7 +54,7 @@ import org.jboss.netty.channel.SimpleChannelHandler;
* ClientBootstrap b = ...;
*
* // Options for a new channel
* b.setOption("remoteAddress", new InetSocketAddress("example.com", 8080));
* b.setOption("remoteAddress", new {@link InetSocketAddress}("example.com", 8080));
* b.setOption("tcpNoDelay", true);
* b.setOption("receiveBufferSize", 1048576);
* </pre>
@ -68,7 +69,7 @@ import org.jboss.netty.channel.SimpleChannelHandler;
*
* <pre>
* ClientBootstrap b = ...;
* ChannelPipeline p = b.getPipeline();
* {@link ChannelPipeline} p = b.getPipeline();
*
* // Add handlers to the pipeline.
* p.addLast("encoder", new EncodingHandler());
@ -84,7 +85,7 @@ import org.jboss.netty.channel.SimpleChannelHandler;
* ClientBootstrap b = ...;
* b.setPipelineFactory(new MyPipelineFactory());
*
* public class MyPipelineFactory implements ChannelPipelineFactory {
* public class MyPipelineFactory implements {@link ChannelPipelineFactory} {
* // Create a new pipeline for a new channel and configure it here ...
* }
* </pre>

View File

@ -24,6 +24,7 @@ package org.jboss.netty.bootstrap;
import static org.jboss.netty.channel.Channels.*;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.HashMap;
import java.util.Map;
@ -71,7 +72,7 @@ import org.jboss.netty.channel.SimpleChannelHandler;
* ServerBootstrap b = ...;
*
* // Options for a parent channel
* b.setOption("localAddress", new InetSocketAddress(8080));
* b.setOption("localAddress", new {@link InetSocketAddress}(8080));
* b.setOption("reuseAddress", true);
*
* // Options for its children
@ -102,7 +103,7 @@ import org.jboss.netty.channel.SimpleChannelHandler;
*
* <pre>
* ServerBootstrap b = ...;
* ChannelPipeline p = b.getPipeline();
* {@link ChannelPipeline} p = b.getPipeline();
*
* // Add handlers to the pipeline.
* p.addLast("encoder", new EncodingHandler());
@ -118,7 +119,7 @@ import org.jboss.netty.channel.SimpleChannelHandler;
* ServerBootstrap b = ...;
* b.setPipelineFactory(new MyPipelineFactory());
*
* public class MyPipelineFactory implements ChannelPipelineFactory {
* public class MyPipelineFactory implements {@link ChannelPipelineFactory} {
* // Create a new pipeline for a new child channel and configure it here ...
* }
* </pre>

View File

@ -29,6 +29,8 @@ import java.net.SocketAddress;
* Handles or intercepts a downstream {@link ChannelEvent}, and fires a
* {@link ChannelEvent} to the previous or next handler in a
* {@link ChannelPipeline}.
*
* <h3>Downstream events</h3>
* <p>
* A downstream event is an event which is supposed to be processed from the
* last handler to the first handler in the {@link ChannelPipeline}.
@ -70,11 +72,15 @@ import java.net.SocketAddress;
* </table>
* <p>
* Other event types and conditions which were not addressed here will be
* ignored and discarded. You also might want to refer to {@link ChannelUpstreamHandler}
* to see how a {@link ChannelEvent} is interpreted when going upstream. Also,
* please refer to the {@link ChannelEvent} documentation to find out what a
* upstream event and a downstream event are and what fundamental differences
* they have, if you didn't read yet.
* ignored and discarded.
*
* <h4>Additional resources worth reading</h4>
* <p>
* You might want to refer to {@link ChannelUpstreamHandler} to see how a
* {@link ChannelEvent} is interpreted when going upstream. Also, please refer
* to the {@link ChannelEvent} documentation to find out what a upstream event
* and a downstream event are and what fundamental differences they have, if
* you didn't read yet.
*
* <h3>Firing an event to the previous or next handler</h3>
* <p>
@ -85,19 +91,21 @@ import java.net.SocketAddress;
*
* <pre>
* // Sending the event forward (downstream)
* void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception {
* void handleDownstream({@link ChannelHandlerContext} ctx, {@link ChannelEvent} e) throws Exception {
* ...
* ctx.sendDownstream(e);
* ...
* }
*
* // Sending the event backward (upstream)
* void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception {
* void handleDownstream({@link ChannelHandlerContext} ctx, {@link ChannelEvent} e) throws Exception {
* ...
* ctx.sendUpstream(new DefaultChannelStateEvent(...));
* ...
* }
* </pre>
*
* <h4>Using the helper class to fire an event</h4>
* <p>
* You will also find various helper methods in {@link Channels} to be useful
* to generate and fire an artificial or manipulated event.

View File

@ -46,6 +46,8 @@ package org.jboss.netty.channel;
* in the future. For example, a {@link MessageEvent} represents the
* notification of a received message when it goes upstream, while it
* represents the request of writing a message when it goes downstream.
*
* <h4>Additional resources worth reading</h4>
* <p>
* Please refer to the documentation of {@link ChannelHandler} and its sub-types
* ({@link ChannelUpstreamHandler} for upstream events and

View File

@ -26,17 +26,18 @@ package org.jboss.netty.channel;
* Handles or intercepts a {@link ChannelEvent}, and fires a
* {@link ChannelEvent} to the next or previous handler in a
* {@link ChannelPipeline}.
*
* <h3>Sub-types</h3>
* <p>
* This is a tag interface. There are two sub-interfaces which processes
* a received event actually, one for upstream events and the other for
* downstream events:
* <ul>
* <li>{@link ChannelUpstreamHandler} handles and intercepts
* a {@link ChannelEvent} fired by an I/O thread.</li>
* <li>{@link ChannelDownstreamHandler} handles and intercepts
* a {@link ChannelEvent} fired by a user via the methods in
* the {@link Channel} interface and the {@link Channels} helper class.</li>
* <li>{@link ChannelUpstreamHandler} handles and intercepts a upstream {@link ChannelEvent}.</li>
* <li>{@link ChannelDownstreamHandler} handles and intercepts a downstream {@link ChannelEvent}.</li>
* </ul>
*
* <h3>The context object</h3>
* <p>
* A {@link ChannelHandler} is provided with a {@link ChannelHandlerContext}
* object. The {@link ChannelHandler} is supposed to interact with the
@ -45,6 +46,12 @@ package org.jboss.netty.channel;
* or previous handler or modify the behavior of the pipeline by adding or
* removing a handler for example.
*
* <h3>Additional resources worth reading</h3>
* <p>
* Please refer to the {@link ChannelEvent} documentation to find out what a
* upstream event and a downstream event are and what fundamental differences
* they have, if you didn't read yet.
*
* @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com)
*

View File

@ -27,6 +27,7 @@ import java.util.NoSuchElementException;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.handler.execution.ExecutionHandler;
import org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor;
import org.jboss.netty.handler.ssl.SslHandler;
@ -38,6 +39,8 @@ import org.jboss.netty.handler.ssl.SslHandler;
* <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
* and how the {@link ChannelHandler}s in the pipeline interact with each other.
*
* <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
@ -54,6 +57,16 @@ import org.jboss.netty.handler.ssl.SslHandler;
* (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

View File

@ -35,12 +35,14 @@ import org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor;
* Handles or intercepts a upstream {@link ChannelEvent}, and fires a
* {@link ChannelEvent} to the next or previous handler in a
* {@link ChannelPipeline}.
*
* <h3>Upstream events</h3>
* <p>
* A upstream event is an event which is supposed to be processed from the
* first handler to the last handler in the {@link ChannelPipeline}.
* For example, all events fired by an I/O thread are upstream events, and
* they have the following meaning:
*
* <p>
* <table border="1" cellspacing="0" cellpadding="6">
* <tr>
* <th>Event name</th></th><th>Event type and condition</th><th>Meaning</th>
@ -94,7 +96,7 @@ import org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor;
* <p>
* These two additional event types are used only for a parent channel which
* can have a child channel (e.g. {@link ServerSocketChannel}).
*
* <p>
* <table border="1" cellspacing="0" cellpadding="6">
* <tr>
* <th>Event name</th><th>Event type and condition</th><th>Meaning</th>
@ -110,12 +112,16 @@ import org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor;
* <td>a child {@link Channel} was closed (e.g. the accepted connection was closed.)</td>
* </tr>
* </table>
*
* <h4>Additional resources worth reading</h4>
* <p>
* You also might want to refer to {@link ChannelDownstreamHandler} to see
* how a {@link ChannelEvent} is interpreted when going downstream. Also,
* please refer to the {@link ChannelEvent} documentation to find out what a
* upstream event and a downstream event are and what fundamental differences
* they have, if you didn't read yet.
* You might want to refer to {@link ChannelDownstreamHandler} to see how a
* {@link ChannelEvent} is interpreted when going downstream. Also, please
* refer to the {@link ChannelEvent} documentation to find out what a upstream
* event and a downstream event are and what fundamental differences they have,
* if you didn't read yet.
*
* <h3>{@link SimpleChannelHandler}</h3>
* <p>
* In most cases, you will get to use a {@link SimpleChannelHandler} to
* implement a upstream handler because it provides an individual handler
@ -132,19 +138,21 @@ import org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor;
*
* <pre>
* // Sending the event forward (upstream)
* void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception {
* void handleUpstream({@link ChannelHandlerContext} ctx, {@link ChannelEvent} e) throws Exception {
* ...
* ctx.sendUpstream(e);
* ...
* }
*
* // Sending the event backward (downstream)
* void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception {
* void handleDownstream({@link ChannelHandlerContext} ctx, {@link ChannelEvent} e) throws Exception {
* ...
* ctx.sendDownstream(new MessageEvent(...));
* ...
* }
* </pre>
*
* <h4>Using the helper class to fire an event</h4>
* <p>
* You will also find various helper methods in {@link Channels} to be useful
* to generate and fire an artificial or manipulated event.

View File

@ -44,8 +44,7 @@ import org.jboss.netty.logging.InternalLoggerFactory;
* </p>
* <pre>public class MyChannelHandler extends SimpleChannelHandler {
*
* public void handleUpstream(
* ChannelHandlerContext ctx, ChannelEvent e) throws Exception {
* public void handleUpstream({@link ChannelHandlerContext} ctx, {@link ChannelEvent} e) throws Exception {
*
* // Log all channel state changes.
* if (e instanceof ChannelStateEvent) {

View File

@ -31,7 +31,7 @@ import org.jboss.netty.util.StackTraceSimplifier;
* You can change it to your preferred logging framework before other Netty
* classes are loaded:
* <pre>
* InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory());
* InternalLoggerFactory.setDefaultFactory(new {@link Log4JLoggerFactory}());
* </pre>
* Please note that the new default factory is effective only for the classes
* which were loaded after the default factory is changed. Therefore,