2008-08-08 02:37:18 +02:00
|
|
|
/*
|
2011-12-09 06:18:34 +01:00
|
|
|
* Copyright 2011 The Netty Project
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
2011-12-09 06:18:34 +01:00
|
|
|
* The Netty Project licenses this file to you under the Apache License,
|
|
|
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at:
|
2008-08-08 02:37:18 +02:00
|
|
|
*
|
2011-12-09 06:18:34 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2008-08-08 03:27:24 +02:00
|
|
|
*
|
2009-08-28 09:15:49 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
2011-12-09 06:18:34 +01:00
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
2009-08-28 09:15:49 +02:00
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
2011-12-09 04:38:59 +01:00
|
|
|
package io.netty.channel;
|
2008-08-08 02:37:18 +02:00
|
|
|
|
|
|
|
import java.net.SocketAddress;
|
2012-05-01 10:19:41 +02:00
|
|
|
import java.util.AbstractQueue;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Iterator;
|
2008-08-08 02:37:18 +02:00
|
|
|
|
|
|
|
/**
|
2008-09-02 09:13:20 +02:00
|
|
|
* A skeletal server-side {@link Channel} implementation. A server-side
|
2008-11-14 08:45:53 +01:00
|
|
|
* {@link Channel} does not allow the following operations:
|
2008-09-02 09:13:20 +02:00
|
|
|
* <ul>
|
2012-05-01 10:19:41 +02:00
|
|
|
* <li>{@link #connect(SocketAddress, ChannelFuture)}</li>
|
|
|
|
* <li>{@link #disconnect(ChannelFuture)}</li>
|
|
|
|
* <li>{@link #flush(ChannelFuture)}</li>
|
2008-09-02 09:13:20 +02:00
|
|
|
* <li>and the shortcut methods which calls the methods mentioned above
|
|
|
|
* </ul>
|
2008-08-08 02:37:18 +02:00
|
|
|
*/
|
2008-12-03 03:38:32 +01:00
|
|
|
public abstract class AbstractServerChannel extends AbstractChannel implements ServerChannel {
|
2008-08-08 02:37:18 +02:00
|
|
|
|
2012-05-01 10:19:41 +02:00
|
|
|
private final ChannelBufferHolder<Object> out = ChannelBufferHolders.messageBuffer(new NoopQueue());
|
|
|
|
|
2008-09-02 09:13:20 +02:00
|
|
|
/**
|
|
|
|
* Creates a new instance.
|
|
|
|
*/
|
2012-05-01 10:19:41 +02:00
|
|
|
protected AbstractServerChannel() {
|
|
|
|
super(null);
|
2008-08-08 02:37:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-05-01 10:19:41 +02:00
|
|
|
public ChannelBufferHolder<Object> out() {
|
|
|
|
return out;
|
2008-08-08 02:37:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-05-01 10:19:41 +02:00
|
|
|
public SocketAddress remoteAddress() {
|
|
|
|
return null;
|
2008-08-08 02:37:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-05-01 10:19:41 +02:00
|
|
|
protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelFuture future) {
|
|
|
|
future.setFailure(new UnsupportedOperationException());
|
2008-08-08 02:37:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-05-01 10:19:41 +02:00
|
|
|
protected void doDisconnect(ChannelFuture future) {
|
|
|
|
future.setFailure(new UnsupportedOperationException());
|
2008-08-08 02:37:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-05-01 10:19:41 +02:00
|
|
|
protected int doFlush(ChannelFuture future) {
|
|
|
|
future.setFailure(new UnsupportedOperationException());
|
|
|
|
return 0;
|
2008-08-08 02:37:18 +02:00
|
|
|
}
|
|
|
|
|
2012-05-01 10:19:41 +02:00
|
|
|
private static class NoopQueue extends AbstractQueue<Object> {
|
|
|
|
@Override
|
|
|
|
public boolean offer(Object e) {
|
|
|
|
return false;
|
|
|
|
}
|
2008-08-08 02:37:18 +02:00
|
|
|
|
2012-05-01 10:19:41 +02:00
|
|
|
@Override
|
|
|
|
public Object poll() {
|
|
|
|
return null;
|
|
|
|
}
|
2008-08-08 02:37:18 +02:00
|
|
|
|
2012-05-01 10:19:41 +02:00
|
|
|
@Override
|
|
|
|
public Object peek() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Iterator<Object> iterator() {
|
|
|
|
return Collections.emptyList().iterator();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int size() {
|
|
|
|
return 0;
|
|
|
|
}
|
2009-02-21 10:32:29 +01:00
|
|
|
}
|
2008-08-08 02:37:18 +02:00
|
|
|
}
|