Package org.jboss.netty.channel
Class AbstractServerChannel
- java.lang.Object
-
- org.jboss.netty.channel.AbstractChannel
-
- org.jboss.netty.channel.AbstractServerChannel
-
- All Implemented Interfaces:
java.lang.Comparable<Channel>,Channel,ServerChannel
- Direct Known Subclasses:
DefaultLocalServerChannel,NioServerSocketChannel,OioServerSocketChannel
public abstract class AbstractServerChannel extends AbstractChannel implements ServerChannel
A skeletal server-sideChannelimplementation. A server-sideChanneldoes not allow the following operations:connect(SocketAddress)disconnect()getInterestOps()setInterestOps(int)write(Object)write(Object, SocketAddress)- and the shortcut methods which calls the methods mentioned above
-
-
Field Summary
-
Fields inherited from class org.jboss.netty.channel.AbstractChannel
allChannels
-
Fields inherited from interface org.jboss.netty.channel.Channel
OP_NONE, OP_READ, OP_READ_WRITE, OP_WRITE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractServerChannel(ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChannelFutureconnect(java.net.SocketAddress remoteAddress)Connects this channel to the specified remote address asynchronously.ChannelFuturedisconnect()Disconnects this channel from the current remote address asynchronously.intgetInterestOps()Returns the currentinterestOpsof this channel.booleanisConnected()Returnstrueif and only if this channel is connected to a remote address.ChannelFuturesetInterestOps(int interestOps)Changes theinterestOpsof this channel asynchronously.protected voidsetInternalInterestOps(int interestOps)Sets theinterestOpsproperty of this channel immediately.ChannelFuturewrite(java.lang.Object message)Sends a message to this channel asynchronously.ChannelFuturewrite(java.lang.Object message, java.net.SocketAddress remoteAddress)Sends a message to this channel asynchronously.-
Methods inherited from class org.jboss.netty.channel.AbstractChannel
bind, close, compareTo, equals, getAttachment, getCloseFuture, getFactory, getId, getInternalInterestOps, getParent, getPipeline, getSucceededFuture, getUnsupportedOperationFuture, getUserDefinedWritability, hashCode, isOpen, isReadable, isWritable, setAttachment, setClosed, setReadable, setUnwritable, setUserDefinedWritability, setWritable, toString, unbind
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jboss.netty.channel.Channel
bind, close, getAttachment, getCloseFuture, getConfig, getFactory, getId, getLocalAddress, getParent, getPipeline, getRemoteAddress, getUserDefinedWritability, isBound, isOpen, isReadable, isWritable, setAttachment, setReadable, setUserDefinedWritability, unbind
-
-
-
-
Constructor Detail
-
AbstractServerChannel
protected AbstractServerChannel(ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink)
Creates a new instance.- Parameters:
factory- the factory which created this channelpipeline- the pipeline which is going to be attached to this channelsink- the sink which will receive downstream events from the pipeline and send upstream events to the pipeline
-
-
Method Detail
-
connect
public ChannelFuture connect(java.net.SocketAddress remoteAddress)
Description copied from interface:ChannelConnects this channel to the specified remote address asynchronously.- Specified by:
connectin interfaceChannel- Overrides:
connectin classAbstractChannel- Parameters:
remoteAddress- where to connect- Returns:
- the
ChannelFuturewhich will be notified when the connection request succeeds or fails
-
disconnect
public ChannelFuture disconnect()
Description copied from interface:ChannelDisconnects this channel from the current remote address asynchronously.- Specified by:
disconnectin interfaceChannel- Overrides:
disconnectin classAbstractChannel- Returns:
- the
ChannelFuturewhich will be notified when the disconnection request succeeds or fails
-
getInterestOps
public int getInterestOps()
Description copied from interface:ChannelReturns the currentinterestOpsof this channel.- Specified by:
getInterestOpsin interfaceChannel- Overrides:
getInterestOpsin classAbstractChannel- Returns:
Channel.OP_NONE,Channel.OP_READ,Channel.OP_WRITE, orChannel.OP_READ_WRITE
-
setInterestOps
public ChannelFuture setInterestOps(int interestOps)
Description copied from interface:ChannelChanges theinterestOpsof this channel asynchronously.- Specified by:
setInterestOpsin interfaceChannel- Overrides:
setInterestOpsin classAbstractChannel- Parameters:
interestOps- the newinterestOps- Returns:
- the
ChannelFuturewhich will be notified when theinterestOpschange request succeeds or fails
-
setInternalInterestOps
protected void setInternalInterestOps(int interestOps)
Description copied from class:AbstractChannelSets theinterestOpsproperty of this channel immediately. This method is intended to be called by an internal component - please do not call it unless you know what you are doing.- Overrides:
setInternalInterestOpsin classAbstractChannel
-
write
public ChannelFuture write(java.lang.Object message)
Description copied from interface:ChannelSends a message to this channel asynchronously. If this channel was created by a connectionless transport (e.g.DatagramChannel) and is not connected yet, you have to callChannel.write(Object, SocketAddress)instead. Otherwise, the write request will fail withNotYetConnectedExceptionand an'exceptionCaught'event will be triggered.- Specified by:
writein interfaceChannel- Overrides:
writein classAbstractChannel- Parameters:
message- the message to write- Returns:
- the
ChannelFuturewhich will be notified when the write request succeeds or fails
-
write
public ChannelFuture write(java.lang.Object message, java.net.SocketAddress remoteAddress)
Description copied from interface:ChannelSends a message to this channel asynchronously. It has an additional parameter that allows a user to specify where to send the specified message instead of this channel's current remote address. If this channel was created by a connectionless transport (e.g.DatagramChannel) and is not connected yet, you must specify non-null address. Otherwise, the write request will fail withNotYetConnectedExceptionand an'exceptionCaught'event will be triggered.- Specified by:
writein interfaceChannel- Overrides:
writein classAbstractChannel- Parameters:
message- the message to writeremoteAddress- where to send the specified message. This method is identical toChannel.write(Object)ifnullis specified here.- Returns:
- the
ChannelFuturewhich will be notified when the write request succeeds or fails
-
isConnected
public boolean isConnected()
Description copied from interface:ChannelReturnstrueif and only if this channel is connected to a remote address.- Specified by:
isConnectedin interfaceChannel
-
-