Package org.jboss.netty.channel
Class AbstractServerChannel
- java.lang.Object
-
- org.jboss.netty.channel.AbstractChannel
-
- org.jboss.netty.channel.AbstractServerChannel
-
- All Implemented Interfaces:
Comparable<Channel>
,Channel
,ServerChannel
public abstract class AbstractServerChannel extends AbstractChannel implements ServerChannel
A skeletal server-sideChannel
implementation. A server-sideChannel
does 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 interface org.jboss.netty.channel.Channel
OP_NONE, OP_READ, OP_READ_WRITE, OP_WRITE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractServerChannel(ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChannelFuture
connect(SocketAddress remoteAddress)
Connects this channel to the specified remote address asynchronously.ChannelFuture
disconnect()
Disconnects this channel from the current remote address asynchronously.int
getInterestOps()
Returns the currentinterestOps
of this channel.boolean
isConnected()
Returnstrue
if and only if this channel is connected to a remote address.ChannelFuture
setInterestOps(int interestOps)
Changes theinterestOps
of this channel asynchronously.protected void
setInternalInterestOps(int interestOps)
Sets theinterestOps
property of this channel immediately.ChannelFuture
write(Object message)
Sends a message to this channel asynchronously.ChannelFuture
write(Object message, 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
-
Methods inherited from interface java.lang.Comparable
compareTo
-
-
-
-
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(SocketAddress remoteAddress)
Description copied from interface:Channel
Connects this channel to the specified remote address asynchronously.- Specified by:
connect
in interfaceChannel
- Overrides:
connect
in classAbstractChannel
- Parameters:
remoteAddress
- where to connect- Returns:
- the
ChannelFuture
which will be notified when the connection request succeeds or fails
-
disconnect
public ChannelFuture disconnect()
Description copied from interface:Channel
Disconnects this channel from the current remote address asynchronously.- Specified by:
disconnect
in interfaceChannel
- Overrides:
disconnect
in classAbstractChannel
- Returns:
- the
ChannelFuture
which will be notified when the disconnection request succeeds or fails
-
getInterestOps
public int getInterestOps()
Description copied from interface:Channel
Returns the currentinterestOps
of this channel.- Specified by:
getInterestOps
in interfaceChannel
- Overrides:
getInterestOps
in 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:Channel
Changes theinterestOps
of this channel asynchronously.- Specified by:
setInterestOps
in interfaceChannel
- Overrides:
setInterestOps
in classAbstractChannel
- Parameters:
interestOps
- the newinterestOps
- Returns:
- the
ChannelFuture
which will be notified when theinterestOps
change request succeeds or fails
-
setInternalInterestOps
protected void setInternalInterestOps(int interestOps)
Description copied from class:AbstractChannel
Sets theinterestOps
property 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:
setInternalInterestOps
in classAbstractChannel
-
write
public ChannelFuture write(Object message)
Description copied from interface:Channel
Sends 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 withNotYetConnectedException
and an'exceptionCaught'
event will be triggered.- Specified by:
write
in interfaceChannel
- Overrides:
write
in classAbstractChannel
- Parameters:
message
- the message to write- Returns:
- the
ChannelFuture
which will be notified when the write request succeeds or fails
-
write
public ChannelFuture write(Object message, SocketAddress remoteAddress)
Description copied from interface:Channel
Sends 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 withNotYetConnectedException
and an'exceptionCaught'
event will be triggered.- Specified by:
write
in interfaceChannel
- Overrides:
write
in classAbstractChannel
- Parameters:
message
- the message to writeremoteAddress
- where to send the specified message. This method is identical toChannel.write(Object)
ifnull
is specified here.- Returns:
- the
ChannelFuture
which will be notified when the write request succeeds or fails
-
isConnected
public boolean isConnected()
Description copied from interface:Channel
Returnstrue
if and only if this channel is connected to a remote address.- Specified by:
isConnected
in interfaceChannel
-
-