1 /*
2 * Copyright 2012 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 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 public abstract class AbstractServerChannel extends AbstractChannel implements ServerChannel {
34
35 /**
36 * Creates a new instance.
37 *
38 * @param factory
39 * the factory which created this channel
40 * @param pipeline
41 * the pipeline which is going to be attached to this channel
42 * @param sink
43 * the sink which will receive downstream events from the pipeline
44 * and send upstream events to the pipeline
45 */
46 protected AbstractServerChannel(
47 ChannelFactory factory,
48 ChannelPipeline pipeline,
49 ChannelSink sink) {
50 super(null, factory, pipeline, sink);
51 }
52
53 @Override
54 public ChannelFuture connect(SocketAddress remoteAddress) {
55 return getUnsupportedOperationFuture();
56 }
57
58 @Override
59 public ChannelFuture disconnect() {
60 return getUnsupportedOperationFuture();
61 }
62
63 @Override
64 public int getInterestOps() {
65 return OP_NONE;
66 }
67
68 @Override
69 public ChannelFuture setInterestOps(int interestOps) {
70 return getUnsupportedOperationFuture();
71 }
72
73 @Override
74 protected void setInternalInterestOps(int interestOps) {
75 // Ignore.
76 }
77
78 @Override
79 public ChannelFuture write(Object message) {
80 return getUnsupportedOperationFuture();
81 }
82
83 @Override
84 public ChannelFuture write(Object message, SocketAddress remoteAddress) {
85 return getUnsupportedOperationFuture();
86 }
87
88 public boolean isConnected() {
89 return false;
90 }
91 }