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
ChannelEvent
s.
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.
|
void |
shutdown()
Shudown the ChannelFactory and all the resource it created internal.
|
Channel newChannel(ChannelPipeline pipeline)
pipeline
- the ChannelPipeline
which is going to be
attached to the new Channel
ChannelException
- if failed to create and open a new channelvoid shutdown()
void releaseExternalResources()
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.
This will also call shutdown()
before do any actionreleaseExternalResources
in interface ExternalResourceReleasable
Copyright © 2008-2015 The Netty Project. All Rights Reserved.