View Javadoc

1   /*
2    * Copyright 2009 Red Hat, Inc.
3    *
4    * Red Hat licenses this file to you under the Apache License, version 2.0
5    * (the "License"); you may not use this file except in compliance with the
6    * 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  package org.jboss.netty.channel;
17  
18  import java.net.SocketAddress;
19  
20  /**
21   * A skeletal server-side {@link Channel} implementation.  A server-side
22   * {@link Channel} does not allow the following operations:
23   * <ul>
24   * <li>{@link #connect(SocketAddress)}</li>
25   * <li>{@link #disconnect()}</li>
26   * <li>{@link #getInterestOps()}</li>
27   * <li>{@link #setInterestOps(int)}</li>
28   * <li>{@link #write(Object)}</li>
29   * <li>{@link #write(Object, SocketAddress)}</li>
30   * <li>and the shortcut methods which calls the methods mentioned above
31   * </ul>
32   *
33   * @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
34   * @author <a href="http://gleamynode.net/">Trustin Lee</a>
35   *
36   * @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
37   *
38   */
39  public abstract class AbstractServerChannel extends AbstractChannel implements ServerChannel {
40  
41      /**
42       * Creates a new instance.
43       *
44       * @param factory
45       *        the factory which created this channel
46       * @param pipeline
47       *        the pipeline which is going to be attached to this channel
48       * @param sink
49       *        the sink which will receive downstream events from the pipeline
50       *        and send upstream events to the pipeline
51       */
52      protected AbstractServerChannel(
53              ChannelFactory factory,
54              ChannelPipeline pipeline,
55              ChannelSink sink) {
56          super(null, factory, pipeline, sink);
57      }
58  
59      @Override
60      public ChannelFuture connect(SocketAddress remoteAddress) {
61          return getUnsupportedOperationFuture();
62      }
63  
64      @Override
65      public ChannelFuture disconnect() {
66          return getUnsupportedOperationFuture();
67      }
68  
69      @Override
70      public int getInterestOps() {
71          return OP_NONE;
72      }
73  
74      @Override
75      public ChannelFuture setInterestOps(int interestOps) {
76          return getUnsupportedOperationFuture();
77      }
78  
79      @Override
80      protected void setInterestOpsNow(int interestOps) {
81          // Ignore.
82      }
83  
84      @Override
85      public ChannelFuture write(Object message) {
86          return getUnsupportedOperationFuture();
87      }
88  
89      @Override
90      public ChannelFuture write(Object message, SocketAddress remoteAddress) {
91          return getUnsupportedOperationFuture();
92      }
93  
94      public boolean isConnected() {
95          return false;
96      }
97  }