Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.netty.channel
Class AbstractChannel

    java.lang.Object
      org.jboss.netty.channel.AbstractChannel

All Implemented Interfaces:
  Comparable<Channel>, Channel

Direct Known Subclasses:
  AbstractServerChannel

    public abstract class AbstractChannel

extends Object
implements Channel

A skeletal `Channel` implementation.

Version:
  $Rev: 2339 $, $Date: 2010-07-07 13:36:25 +0900 (Wed, 07 Jul 2010) $
Author:
  The Netty Project, Trustin Lee

Field Summary

Fields inherited from interface org.jboss.netty.channel.Channel
`OP_NONE, OP_READ, OP_READ_WRITE, OP_WRITE`

Constructor Summary
`protected` | `AbstractChannel(Channel parent, ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink)` Creates a new instance.
`protected` | `AbstractChannel(Integer id, Channel parent, ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink)` (Internal use only) Creates a new temporary instance with the specified ID.

Method Summary
`ChannelFuture` | `bind(SocketAddress localAddress)` Binds this channel to the specified local address asynchronously.
`ChannelFuture` | `close()` Closes this channel asynchronously.
`int` | `compareTo(Channel o)` Compares the ID of the two channels.
`ChannelFuture` | `connect(SocketAddress remoteAddress)` Connects this channel to the specified remote address asynchronously.
`ChannelFuture` | `disconnect()` Disconnects this channel from the current remote address asynchronously.
`boolean` | `equals(Object o)` Returns `true` if and only if the specified object is identical with this channel (i.e: `this == o`).
`ChannelFuture` | `getCloseFuture()` Returns the `ChannelFuture` which will be notified when this channel is closed.
`ChannelFactory` | `getFactory()` Returns the `ChannelFactory` which created this channel.
`Integer` | `getId()` Returns the unique integer ID of this channel.
`int` | `getInterestOps()` Returns the current `interestOps` of this channel.
`Channel` | `getParent()` Returns the parent of this channel.
`ChannelPipeline` | `getPipeline()` Returns the `ChannelPipeline` which handles `ChannelEvent`s associated with this channel.
`protected ChannelFuture` | `getSucceededFuture()` Returns the cached `SucceededChannelFuture` instance.
`protected ChannelFuture` | `getUnsupportedOperationFuture()` Returns the `FailedChannelFuture` whose cause is an `UnsupportedOperationException`.
`int` | `hashCode()` Returns the identity hash code of this channel.
`boolean` | `isOpen()` Returns `true` if and only if this channel is open.
`boolean` | `isReadable()` Returns `true` if and only if the I/O thread will read a message from this channel.
`boolean` | `isWritable()` Returns `true` if and only if the I/O thread will perform the requested write operation immediately.
`protected boolean` | `setClosed()` Marks this channel as closed.
`ChannelFuture` | `setInterestOps(int interestOps)` Changes the `interestOps` of this channel asynchronously.
`protected void` | `setInterestOpsNow(int interestOps)` Sets the `interestOps` property of this channel immediately.
`ChannelFuture` | `setReadable(boolean readable)` Suspends or resumes the read operation of the I/O thread asynchronously.
`String` | `toString()` Returns the `String` representation of this channel.
`ChannelFuture` | `unbind()` Unbinds this channel from the current local address asynchronously.
`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 java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.jboss.netty.channel.Channel
`getConfig, getLocalAddress, getRemoteAddress, isBound, isConnected`

Constructor Detail

### AbstractChannel

    protected AbstractChannel(Channel parent,
                              ChannelFactory factory,
                              ChannelPipeline pipeline,
                              ChannelSink sink)

  Creates a new instance.

  Parameters:
    `parent` - the parent of this channel. `null` if there's no parent.
    `factory` - the factory which created this channel
    `pipeline` - the pipeline which is going to be attached to this channel
    `sink` - the sink which will receive downstream events from the pipeline and send upstream events to the pipeline

### AbstractChannel

    protected AbstractChannel(Integer id,
                              Channel parent,
                              ChannelFactory factory,
                              ChannelPipeline pipeline,
                              ChannelSink sink)

  (Internal use only) Creates a new temporary instance with the specified ID.

  Parameters:
    `parent` - the parent of this channel. `null` if there's no parent.
    `factory` - the factory which created this channel
    `pipeline` - the pipeline which is going to be attached to this channel
    `sink` - the sink which will receive downstream events from the pipeline and send upstream events to the pipeline

Method Detail

### getId

    public final Integer getId()

  Description copied from interface: `Channel`
  Returns the unique integer ID of this channel.

  Specified by:
    `getId` in interface `Channel`

### getParent

    public Channel getParent()

  Description copied from interface: `Channel`
  Returns the parent of this channel.

  Specified by:
    `getParent` in interface `Channel`
  Returns:
    the parent channel. `null` if this channel does not have a parent channel.

### getFactory

    public ChannelFactory getFactory()

  Description copied from interface: `Channel`
  Returns the `ChannelFactory` which created this channel.

  Specified by:
    `getFactory` in interface `Channel`

### getPipeline

    public ChannelPipeline getPipeline()

  Description copied from interface: `Channel`
  Returns the `ChannelPipeline` which handles `ChannelEvent`s associated with this channel.

  Specified by:
    `getPipeline` in interface `Channel`

### getSucceededFuture

    protected ChannelFuture getSucceededFuture()

  Returns the cached `SucceededChannelFuture` instance.

### getUnsupportedOperationFuture

    protected ChannelFuture getUnsupportedOperationFuture()

  Returns the `FailedChannelFuture` whose cause is an `UnsupportedOperationException`.

### hashCode

    public final int hashCode()

  Returns the identity hash code of this channel.

  Overrides:
    `hashCode` in class `Object`

### equals

    public final boolean equals(Object o)

  Returns `true` if and only if the specified object is identical with this channel (i.e: `this == o`).

  Overrides:
    `equals` in class `Object`

### compareTo

    public final int compareTo(Channel o)

  Compares the ID of the two channels.

  Specified by:
    `compareTo` in interface `Comparable<Channel>`

### isOpen

    public boolean isOpen()

  Description copied from interface: `Channel`
  Returns `true` if and only if this channel is open.

  Specified by:
    `isOpen` in interface `Channel`

### setClosed

    protected boolean setClosed()

  Marks this channel as closed. This method is intended to be called by an internal component - please do not call it unless you know what you are doing.

  Returns:
    `true` if and only if this channel was not marked as closed yet

### bind

    public ChannelFuture bind(SocketAddress localAddress)

  Description copied from interface: `Channel`
  Binds this channel to the specified local address asynchronously.

  Specified by:
    `bind` in interface `Channel`
  Parameters:
    `localAddress` - where to bind
  Returns:
    the `ChannelFuture` which will be notified when the bind request succeeds or fails

### unbind

    public ChannelFuture unbind()

  Description copied from interface: `Channel`
  Unbinds this channel from the current local address asynchronously.

  Specified by:
    `unbind` in interface `Channel`
  Returns:
    the `ChannelFuture` which will be notified when the unbind request succeeds or fails

### close

    public ChannelFuture close()

  Description copied from interface: `Channel`
  Closes this channel asynchronously. If this channel is bound or connected, it will be disconnected and unbound first. Once a channel is closed, it can not be open again. Calling this method on a closed channel has no effect. Please note that this method always returns the same future instance.

  Specified by:
    `close` in interface `Channel`
  Returns:
    the `ChannelFuture` which will be notified when the close request succeeds or fails

### getCloseFuture

    public ChannelFuture getCloseFuture()

  Description copied from interface: `Channel`
  Returns the `ChannelFuture` which will be notified when this channel is closed. This method always returns the same future instance.

  Specified by:
    `getCloseFuture` in interface `Channel`

### connect

    public ChannelFuture connect(SocketAddress remoteAddress)

  Description copied from interface: `Channel`
  Connects this channel to the specified remote address asynchronously.

  Specified by:
    `connect` in interface `Channel`
  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 interface `Channel`
  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 current `interestOps` of this channel.

  Specified by:
    `getInterestOps` in interface `Channel`
  Returns:
    `Channel.OP_NONE`, `Channel.OP_READ`, `Channel.OP_WRITE`, or `Channel.OP_READ_WRITE`

### setInterestOps

    public ChannelFuture setInterestOps(int interestOps)

  Description copied from interface: `Channel`
  Changes the `interestOps` of this channel asynchronously.

  Specified by:
    `setInterestOps` in interface `Channel`
  Parameters:
    `interestOps` - the new `interestOps`
  Returns:
    the `ChannelFuture` which will be notified when the `interestOps` change request succeeds or fails

### setInterestOpsNow

    protected void setInterestOpsNow(int interestOps)

  Sets the `interestOps` 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.

### isReadable

    public boolean isReadable()

  Description copied from interface: `Channel`
  Returns `true` if and only if the I/O thread will read a message from this channel. This method is a shortcut to the following code:

       return (getInterestOps() & OP_READ) != 0;

  Specified by:
    `isReadable` in interface `Channel`

### isWritable

    public boolean isWritable()

  Description copied from interface: `Channel`
  Returns `true` if and only if the I/O thread will perform the requested write operation immediately. Any write requests made when this method returns `false` are queued until the I/O thread is ready to process the queued write requests. This method is a shortcut to the following code:

       return (getInterestOps() & OP_WRITE) == 0;

  Specified by:
    `isWritable` in interface `Channel`

### setReadable

    public ChannelFuture setReadable(boolean readable)

  Description copied from interface: `Channel`
  Suspends or resumes the read operation of the I/O thread asynchronously. This method is a shortcut to the following code:

       int interestOps = getInterestOps();
       if (readable) {
           setInterestOps(interestOps | OP_READ);
       } else {
           setInterestOps(interestOps & ~OP_READ);
       }

  Specified by:
    `setReadable` in interface `Channel`
  Parameters:
    `readable` - `true` to resume the read operation and `false` to suspend the read operation
  Returns:
    the `ChannelFuture` which will be notified when the `interestOps` change request succeeds or fails

### 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 call `Channel.write(Object, SocketAddress)` instead. Otherwise, the write request will fail with `NotYetConnectedException` and an `'exceptionCaught'` event will be triggered.

  Specified by:
    `write` in interface `Channel`
  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 with `NotYetConnectedException` and an `'exceptionCaught'` event will be triggered.

  Specified by:
    `write` in interface `Channel`
  Parameters:
    `message` - the message to write
    `remoteAddress` - where to send the specified message. This method is identical to `Channel.write(Object)` if `null` is specified here.
  Returns:
    the `ChannelFuture` which will be notified when the write request succeeds or fails

### toString

    public String toString()

  Returns the `String` representation of this channel. The returned string contains the ID, local address, and remote address of this channel for easier identification.

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2010 JBoss, a division of Red Hat, Inc.. All Rights Reserved.