org.jboss.netty.channel

## Interface ChannelFactory

All Superinterfaces:
  ExternalResourceReleasable

All Known Subinterfaces:
  ClientSocketChannelFactory, DatagramChannelFactory, LocalClientChannelFactory, LocalServerChannelFactory, ServerChannelFactory, ServerSocketChannelFactory

All Known Implementing Classes:
  DefaultLocalClientChannelFactory, DefaultLocalServerChannelFactory, HttpTunnelingClientSocketChannelFactory, NioClientSocketChannelFactory, NioDatagramChannelFactory, NioServerSocketChannelFactory, OioClientSocketChannelFactory, OioDatagramChannelFactory, OioServerSocketChannelFactory

    public interface ChannelFactory
    extends ExternalResourceReleasable

The main interface to a transport that creates a `Channel` associated with a certain communication entity such as a network socket. For example, the `NioServerSocketChannelFactory` creates a channel which has a NIO-based server socket as its underlying communication entity.

Once a new `Channel` is created, the `ChannelPipeline` which was specified as a parameter in the `newChannel(ChannelPipeline)` is attached to the new `Channel`, and starts to handle all associated `ChannelEvent`s.

### Graceful shutdown

To shut down a network application service which is managed by a factory. you should follow the following steps:

1. close all channels created by the factory and their child channels usually using `ChannelGroup.close()`, and
2. call `releaseExternalResources()`.

For detailed transport-specific information on shutting down a factory, please refer to the Javadoc of `ChannelFactory`'s subtypes, such as `NioServerSocketChannelFactory`.

### Method Summary

Methods
`Channel` `newChannel(ChannelPipeline pipeline)` Creates and opens a new `Channel` and attaches the specified `ChannelPipeline` to the new `Channel`.
`void` `releaseExternalResources()` Releases the external resources that this factory depends on to function.

### Method Detail

#### newChannel

    Channel newChannel(ChannelPipeline pipeline)

Creates and opens a new `Channel` and attaches the specified `ChannelPipeline` to the new `Channel`.

Parameters:
  `pipeline` - the `ChannelPipeline` which is going to be attached to the new `Channel`
Returns:
  the newly open channel
Throws:
  `ChannelException` - if failed to create and open a new channel

#### releaseExternalResources

    void releaseExternalResources()

Releases the external resources that this factory depends on to function. An external resource is a resource that this factory didn't create by itself. For example, `Executor`s that you specified in the factory constructor are external resources. You can call this method to release all external resources conveniently when the resources are not used by this factory or any other part of your application. An unexpected behavior will be resulted in if the resources are released when there's an open channel which is managed by this factory.

Specified by:
  `releaseExternalResources` in interface `ExternalResourceReleasable`