View Javadoc
1   /*
2    * Copyright 2013 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  
17  package io.netty.channel;
18  
19  import io.netty.util.concurrent.EventExecutor;
20  
21  import java.net.SocketAddress;
22  
23  /**
24   * Invokes the event handler methods of {@link ChannelHandler}.
25   * A user can specify a {@link ChannelHandlerInvoker} to implement a custom thread model unsupported by the default
26   * implementation. Note that the methods in this interface are not intended to be called by a user.
27   */
28  public interface ChannelHandlerInvoker {
29  
30      /**
31       * Returns the {@link EventExecutor} which is used to execute an arbitrary task.
32       */
33      EventExecutor executor();
34  
35      /**
36       * Invokes {@link ChannelHandler#channelRegistered(ChannelHandlerContext)}. This method is not for a user
37       * but for the internal {@link ChannelHandlerContext} implementation. To trigger an event, use the methods in
38       * {@link ChannelHandlerContext} instead.
39       */
40      void invokeChannelRegistered(ChannelHandlerContext ctx);
41  
42      /**
43       * Invokes {@link ChannelHandler#channelUnregistered(ChannelHandlerContext)}. This method is not for a user
44       * but for the internal {@link ChannelHandlerContext} implementation. To trigger an event, use the methods in
45       * {@link ChannelHandlerContext} instead.
46       */
47      void invokeChannelUnregistered(ChannelHandlerContext ctx);
48  
49      /**
50       * Invokes {@link ChannelHandler#channelActive(ChannelHandlerContext)}. This method is not for a user
51       * but for the internal {@link ChannelHandlerContext} implementation. To trigger an event, use the methods in
52       * {@link ChannelHandlerContext} instead.
53       */
54      void invokeChannelActive(ChannelHandlerContext ctx);
55  
56      /**
57       * Invokes {@link ChannelHandler#channelInactive(ChannelHandlerContext)}. This method is not for a user
58       * but for the internal {@link ChannelHandlerContext} implementation. To trigger an event, use the methods in
59       * {@link ChannelHandlerContext} instead.
60       */
61      void invokeChannelInactive(ChannelHandlerContext ctx);
62  
63      /**
64       * Invokes {@link ChannelHandler#exceptionCaught(ChannelHandlerContext, Throwable)}. This method is not for a user
65       * but for the internal {@link ChannelHandlerContext} implementation. To trigger an event, use the methods in
66       * {@link ChannelHandlerContext} instead.
67       */
68      void invokeExceptionCaught(ChannelHandlerContext ctx, Throwable cause);
69  
70      /**
71       * Invokes {@link ChannelHandler#userEventTriggered(ChannelHandlerContext, Object)}. This method is not for
72       * a user but for the internal {@link ChannelHandlerContext} implementation. To trigger an event, use the methods in
73       * {@link ChannelHandlerContext} instead.
74       */
75      void invokeUserEventTriggered(ChannelHandlerContext ctx, Object event);
76  
77      /**
78       * Invokes {@link ChannelHandler#channelRead(ChannelHandlerContext, Object)}. This method is not for a user
79       * but for the internal {@link ChannelHandlerContext} implementation. To trigger an event, use the methods in
80       * {@link ChannelHandlerContext} instead.
81       */
82      void invokeChannelRead(ChannelHandlerContext ctx, Object msg);
83  
84      /**
85       * Invokes {@link ChannelHandler#channelReadComplete(ChannelHandlerContext)}. This method is not for a user
86       * but for the internal {@link ChannelHandlerContext} implementation. To trigger an event, use the methods in
87       * {@link ChannelHandlerContext} instead.
88       */
89      void invokeChannelReadComplete(ChannelHandlerContext ctx);
90  
91      /**
92       * Invokes {@link ChannelHandler#channelWritabilityChanged(ChannelHandlerContext)}. This method is not for
93       * a user but for the internal {@link ChannelHandlerContext} implementation. To trigger an event, use the methods in
94       * {@link ChannelHandlerContext} instead.
95       */
96      void invokeChannelWritabilityChanged(ChannelHandlerContext ctx);
97  
98      /**
99       * Invokes {@link ChannelHandler#bind(ChannelHandlerContext, SocketAddress, ChannelPromise)}.
100      * This method is not for a user but for the internal {@link ChannelHandlerContext} implementation.
101      * To trigger an event, use the methods in {@link ChannelHandlerContext} instead.
102      */
103     void invokeBind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise);
104 
105     /**
106      * Invokes
107      * {@link ChannelHandler#connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)}.
108      * This method is not for a user but for the internal {@link ChannelHandlerContext} implementation.
109      * To trigger an event, use the methods in {@link ChannelHandlerContext} instead.
110      */
111     void invokeConnect(
112             ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise);
113 
114     /**
115      * Invokes {@link ChannelHandler#disconnect(ChannelHandlerContext, ChannelPromise)}.
116      * This method is not for a user but for the internal {@link ChannelHandlerContext} implementation.
117      * To trigger an event, use the methods in {@link ChannelHandlerContext} instead.
118      */
119     void invokeDisconnect(ChannelHandlerContext ctx, ChannelPromise promise);
120 
121     /**
122      * Invokes {@link ChannelHandler#close(ChannelHandlerContext, ChannelPromise)}.
123      * This method is not for a user but for the internal {@link ChannelHandlerContext} implementation.
124      * To trigger an event, use the methods in {@link ChannelHandlerContext} instead.
125      */
126     void invokeClose(ChannelHandlerContext ctx, ChannelPromise promise);
127 
128     /**
129      * Invokes {@link ChannelHandler#deregister(ChannelHandlerContext, ChannelPromise)}.
130      * This method is not for a user but for the internal {@link ChannelHandlerContext} implementation.
131      * To trigger an event, use the methods in {@link ChannelHandlerContext} instead.
132      */
133     void invokeDeregister(ChannelHandlerContext ctx, ChannelPromise promise);
134 
135     /**
136      * Invokes {@link ChannelHandler#read(ChannelHandlerContext)}.
137      * This method is not for a user but for the internal {@link ChannelHandlerContext} implementation.
138      * To trigger an event, use the methods in {@link ChannelHandlerContext} instead.
139      */
140     void invokeRead(ChannelHandlerContext ctx);
141 
142     /**
143      * Invokes {@link ChannelHandler#write(ChannelHandlerContext, Object, ChannelPromise)}.
144      * This method is not for a user but for the internal {@link ChannelHandlerContext} implementation.
145      * To trigger an event, use the methods in {@link ChannelHandlerContext} instead.
146      */
147     void invokeWrite(ChannelHandlerContext ctx, Object msg, ChannelPromise promise);
148 
149     /**
150      * Invokes {@link ChannelHandler#flush(ChannelHandlerContext)}.
151      * This method is not for a user but for the internal {@link ChannelHandlerContext} implementation.
152      * To trigger an event, use the methods in {@link ChannelHandlerContext} instead.
153      */
154     void invokeFlush(ChannelHandlerContext ctx);
155 }