More example and explanation on ChannelPipelineCoverage("one")

This commit is contained in:
Trustin Lee 2009-04-09 07:03:53 +00:00
parent 25a2ade130
commit bd7f8a561a

View File

@ -74,7 +74,8 @@ import java.lang.annotation.Target;
* {@code "one"} means you must create a new instance of the annotated handler
* type for each new channel. It means the member variables of the handler
* instance can not be shared at all, and violating this contract will lead
* the handler to a race condition. The following code shows an example of a
* the handler to a race condition. A new handler instance is usually created
* by {@link ChannelPipelineFactory}. The following code shows an example of a
* handler type annotated with {@code "one"} value:
*
* <pre>
@ -100,6 +101,15 @@ import java.lang.annotation.Target;
* }
* ...
* }
*
* // Create a new handler instance per channel.
* public class MyPipelineFactory implements ChannelPipelineFactory {
*
* public ChannelPipeline getPipeline() {
* ChannelPipeline p = Channels.pipeline();
* p.addLast("handler", new StatefulHandler());
* }
* }
* </pre>
*
* @author The Netty Project (netty-dev@lists.jboss.org)