Package org.jboss.netty.channel
Interface ChannelFactory
- All Superinterfaces:
ExternalResourceReleasable
- All Known Subinterfaces:
ClientSocketChannelFactory
,DatagramChannelFactory
,LocalClientChannelFactory
,LocalServerChannelFactory
,ServerChannelFactory
,ServerSocketChannelFactory
- All Known Implementing Classes:
DefaultLocalClientChannelFactory
,DefaultLocalServerChannelFactory
,EmbeddedChannelFactory
,HttpTunnelingClientSocketChannelFactory
,NioClientSocketChannelFactory
,NioDatagramChannelFactory
,NioServerSocketChannelFactory
,OioClientSocketChannelFactory
,OioDatagramChannelFactory
,OioServerSocketChannelFactory
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:
- close all channels created by the factory and their child channels
usually using
ChannelGroup.close()
, and - 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
Modifier and TypeMethodDescriptionnewChannel
(ChannelPipeline pipeline) void
Releases the external resources that this factory depends on to function.void
shutdown()
Shudown the ChannelFactory and all the resource it created internal.
-
Method Details
-
newChannel
- Parameters:
pipeline
- theChannelPipeline
which is going to be attached to the newChannel
- Returns:
- the newly open channel
- Throws:
ChannelException
- if failed to create and open a new channel
-
shutdown
void shutdown()Shudown the ChannelFactory and all the resource it created internal. -
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. This will also callshutdown()
before do any action- Specified by:
releaseExternalResources
in interfaceExternalResourceReleasable
-