
public interface ChannelFactory extends ExternalResourceReleasable
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
ChannelEvents.
To shut down a network application service which is managed by a factory. you should follow the following steps:
ChannelGroup.close(), andreleaseExternalResources().
For detailed transport-specific information on shutting down a factory,
please refer to the Javadoc of ChannelFactory's subtypes, such as
NioServerSocketChannelFactory.
| Modifier and Type | Method and Description |
|---|---|
Channel |
newChannel(ChannelPipeline pipeline)
|
void |
releaseExternalResources()
Releases the external resources that this factory depends on to function.
|
Channel newChannel(ChannelPipeline pipeline)
pipeline - the ChannelPipeline which is going to be
attached to the new ChannelChannelException - if failed to create and open a new channelvoid releaseExternalResources()
Executors 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.releaseExternalResources in interface ExternalResourceReleasableCopyright © 2008-2013 The Netty Project. All Rights Reserved.