org.jboss.netty.channel
Interface ChannelConfig

All Known Subinterfaces:
DatagramChannelConfig, NioDatagramChannelConfig, NioSocketChannelConfig, ServerSocketChannelConfig, SocketChannelConfig, XnioChannelConfig
All Known Implementing Classes:
DefaultChannelConfig, DefaultDatagramChannelConfig, DefaultServerChannelConfig, DefaultServerSocketChannelConfig, DefaultSocketChannelConfig, HttpTunnelingSocketChannelConfig

public interface ChannelConfig

A set of configuration properties of a Channel.

Please down-cast to more specific configuration type such as SocketChannelConfig or use setOptions(Map) to set the transport-specific properties:

 Channel ch = ...;
 SocketChannelConfig cfg = (SocketChannelConfig) ch.getConfig();
 cfg.setTcpNoDelay(false);
 

Option map

An option map property is a dynamic write-only property which allows the configuration of a Channel without down-casting its associated ChannelConfig. To update an option map, please call setOptions(Map).

All ChannelConfig has the following options:

NameAssociated setter method
"bufferFactory"setBufferFactory(ChannelBufferFactory)
"connectTimeoutMillis"setConnectTimeoutMillis(int)
"pipelineFactory"setPipelineFactory(ChannelPipelineFactory)

More options are available in the sub-types of ChannelConfig. For example, you can configure the parameters which are specific to a TCP/IP socket as explained in SocketChannelConfig or NioSocketChannelConfig.

Version:
$Rev: 1685 $, $Date: 2009-08-28 16:15:49 +0900 (금, 28 8 2009) $
Author:
The Netty Project (netty-dev@lists.jboss.org), Trustin Lee (tlee@redhat.com)

Method Summary
 ChannelBufferFactory getBufferFactory()
          Returns the default ChannelBufferFactory used to create a new ChannelBuffer.
 int getConnectTimeoutMillis()
          Returns the connect timeout of the channel in milliseconds.
 ChannelPipelineFactory getPipelineFactory()
          Returns the ChannelPipelineFactory which will be used when a child channel is created.
 int getWriteTimeoutMillis()
          Deprecated. Use WriteTimeoutHandler instead. Returns the write timeout of the channel in milliseconds. If a write operation is not completed within the write timeout, an IOException will be raised. If the Channel does not support write operation, this property is not used at all, and therefore will be ignored.
 void setBufferFactory(ChannelBufferFactory bufferFactory)
          Sets the default ChannelBufferFactory used to create a new ChannelBuffer.
 void setConnectTimeoutMillis(int connectTimeoutMillis)
          Sets the connect timeout of the channel in milliseconds.
 boolean setOption(String name, Object value)
          Sets a configuration property with the specified name and value.
 void setOptions(Map<String,Object> options)
          Sets the configuration properties from the specified Map.
 void setPipelineFactory(ChannelPipelineFactory pipelineFactory)
          Sets the ChannelPipelineFactory which will be used when a child channel is created.
 void setWriteTimeoutMillis(int writeTimeoutMillis)
          Deprecated. Use WriteTimeoutHandler instead. Sets the write timeout of the channel in milliseconds. If a write operation is not completed within the write timeout, an IOException will be raised. If the Channel does not support write operation, this property is not used at all, and therefore will be ignored.
 

Method Detail

setOptions

void setOptions(Map<String,Object> options)
Sets the configuration properties from the specified Map.


setOption

boolean setOption(String name,
                  Object value)
Sets a configuration property with the specified name and value. To override this method properly, you must call the super class:
 public boolean setOption(String name, Object value) {
     if (super.setOption(name, value)) {
         return true;
     }

     if (name.equals("additionalOption")) {
         ....
         return true;
     }

     return false;
 }
 

Returns:
true if and only if the property has been set

getBufferFactory

ChannelBufferFactory getBufferFactory()
Returns the default ChannelBufferFactory used to create a new ChannelBuffer. The default is HeapChannelBufferFactory. You can specify a different factory to change the default ByteOrder for example.


setBufferFactory

void setBufferFactory(ChannelBufferFactory bufferFactory)
Sets the default ChannelBufferFactory used to create a new ChannelBuffer. The default is HeapChannelBufferFactory. You can specify a different factory to change the default ByteOrder for example.


getPipelineFactory

ChannelPipelineFactory getPipelineFactory()
Returns the ChannelPipelineFactory which will be used when a child channel is created. If the Channel does not create a child channel, this property is not used at all, and therefore will be ignored.


setPipelineFactory

void setPipelineFactory(ChannelPipelineFactory pipelineFactory)
Sets the ChannelPipelineFactory which will be used when a child channel is created. If the Channel does not create a child channel, this property is not used at all, and therefore will be ignored.


getConnectTimeoutMillis

int getConnectTimeoutMillis()
Returns the connect timeout of the channel in milliseconds. If the Channel does not support connect operation, this property is not used at all, and therefore will be ignored.

Returns:
the connect timeout in milliseconds. 0 if disabled.

setConnectTimeoutMillis

void setConnectTimeoutMillis(int connectTimeoutMillis)
Sets the connect timeout of the channel in milliseconds. If the Channel does not support connect operation, this property is not used at all, and therefore will be ignored.

Parameters:
connectTimeoutMillis - the connect timeout in milliseconds. 0 to disable.

getWriteTimeoutMillis

@Deprecated
int getWriteTimeoutMillis()
Deprecated. Use WriteTimeoutHandler instead. Returns the write timeout of the channel in milliseconds. If a write operation is not completed within the write timeout, an IOException will be raised. If the Channel does not support write operation, this property is not used at all, and therefore will be ignored.

Returns:
the write timeout in milliseconds. 0 if disabled.

setWriteTimeoutMillis

@Deprecated
void setWriteTimeoutMillis(int writeTimeoutMillis)
Deprecated. Use WriteTimeoutHandler instead. Sets the write timeout of the channel in milliseconds. If a write operation is not completed within the write timeout, an IOException will be raised. If the Channel does not support write operation, this property is not used at all, and therefore will be ignored.

Parameters:
writeTimeoutMillis - the write timeout in milliseconds. 0 to disable.


Copyright © 2008-2009 JBoss, by Red Hat. All Rights Reserved.