public class DefaultChannelConfig extends Object implements ChannelConfig
SocketChannelConfig
implementation.ChannelConfig.ChannelHandlerByteBufType
Constructor and Description |
---|
DefaultChannelConfig(Channel channel) |
Modifier and Type | Method and Description |
---|---|
ByteBufAllocator |
getAllocator()
Returns
ByteBufAllocator which is used for the channel
to allocate buffers. |
int |
getConnectTimeoutMillis()
Returns the connect timeout of the channel in milliseconds.
|
ChannelConfig.ChannelHandlerByteBufType |
getDefaultHandlerByteBufType()
Returns the
ChannelConfig.ChannelHandlerByteBufType which is used to determine what kind of ByteBuf will
be created by the ChannelInboundByteHandler.newInboundBuffer(ChannelHandlerContext) and
ChannelOutboundByteHandler.newOutboundBuffer(ChannelHandlerContext) methods. |
<T> T |
getOption(ChannelOption<T> option)
Return the value of the given
ChannelOption |
Map<ChannelOption<?>,Object> |
getOptions()
Return all set
ChannelOption 's. |
protected Map<ChannelOption<?>,Object> |
getOptions(Map<ChannelOption<?>,Object> result,
ChannelOption<?>... options) |
int |
getWriteSpinCount()
Returns the maximum loop count for a write operation until
WritableByteChannel.write(ByteBuffer) returns a non-zero value. |
boolean |
isAutoRead()
Returns
true if and only if ChannelOutboundInvoker.read() will be invoked automatically so that
a user application doesn't need to call it at all. |
ChannelConfig |
setAllocator(ByteBufAllocator allocator)
Set the
ByteBufAllocator which is used for the channel
to allocate buffers. |
ChannelConfig |
setAutoRead(boolean autoRead)
Sets if
ChannelOutboundInvoker.read() will be invoked automatically so that a user application doesn't
need to call it at all. |
ChannelConfig |
setConnectTimeoutMillis(int connectTimeoutMillis)
Sets the connect timeout of the channel in milliseconds.
|
ChannelConfig |
setDefaultHandlerByteBufType(ChannelConfig.ChannelHandlerByteBufType handlerByteBufType)
Sets the
ChannelConfig.ChannelHandlerByteBufType which is used to determine what kind of ByteBuf will
be created by the ChannelInboundByteHandler.newInboundBuffer(ChannelHandlerContext) and
ChannelOutboundByteHandler.newOutboundBuffer(ChannelHandlerContext) methods. |
<T> boolean |
setOption(ChannelOption<T> option,
T value)
Sets a configuration property with the specified name and value.
|
boolean |
setOptions(Map<ChannelOption<?>,?> options)
Sets the configuration properties from the specified
Map . |
ChannelConfig |
setWriteSpinCount(int writeSpinCount)
Sets the maximum loop count for a write operation until
WritableByteChannel.write(ByteBuffer) returns a non-zero value. |
protected <T> void |
validate(ChannelOption<T> option,
T value) |
protected final Channel channel
public DefaultChannelConfig(Channel channel)
public Map<ChannelOption<?>,Object> getOptions()
ChannelConfig
ChannelOption
's.getOptions
in interface ChannelConfig
protected Map<ChannelOption<?>,Object> getOptions(Map<ChannelOption<?>,Object> result, ChannelOption<?>... options)
public boolean setOptions(Map<ChannelOption<?>,?> options)
ChannelConfig
Map
.setOptions
in interface ChannelConfig
public <T> T getOption(ChannelOption<T> option)
ChannelConfig
ChannelOption
getOption
in interface ChannelConfig
public <T> boolean setOption(ChannelOption<T> option, T value)
ChannelConfig
public boolean setOption(ChannelOption<T> option, T value) { if (super.setOption(option, value)) { return true; } if (option.equals(additionalOption)) { .... return true; } return false; }
setOption
in interface ChannelConfig
true
if and only if the property has been setprotected <T> void validate(ChannelOption<T> option, T value)
public int getConnectTimeoutMillis()
ChannelConfig
Channel
does not support connect operation, this property is not
used at all, and therefore will be ignored.getConnectTimeoutMillis
in interface ChannelConfig
0
if disabled.public ChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis)
ChannelConfig
Channel
does not support connect operation, this property is not
used at all, and therefore will be ignored.setConnectTimeoutMillis
in interface ChannelConfig
connectTimeoutMillis
- the connect timeout in milliseconds.
0
to disable.public int getWriteSpinCount()
ChannelConfig
WritableByteChannel.write(ByteBuffer)
returns a non-zero value.
It is similar to what a spin lock is used for in concurrency programming.
It improves memory utilization and write throughput depending on
the platform that JVM runs on. The default value is 16
.getWriteSpinCount
in interface ChannelConfig
public ChannelConfig setWriteSpinCount(int writeSpinCount)
ChannelConfig
WritableByteChannel.write(ByteBuffer)
returns a non-zero value.
It is similar to what a spin lock is used for in concurrency programming.
It improves memory utilization and write throughput depending on
the platform that JVM runs on. The default value is 16
.setWriteSpinCount
in interface ChannelConfig
public ByteBufAllocator getAllocator()
ChannelConfig
ByteBufAllocator
which is used for the channel
to allocate buffers.getAllocator
in interface ChannelConfig
public ChannelConfig setAllocator(ByteBufAllocator allocator)
ChannelConfig
ByteBufAllocator
which is used for the channel
to allocate buffers.setAllocator
in interface ChannelConfig
public boolean isAutoRead()
ChannelConfig
true
if and only if ChannelOutboundInvoker.read()
will be invoked automatically so that
a user application doesn't need to call it at all. The default value is true
.isAutoRead
in interface ChannelConfig
public ChannelConfig setAutoRead(boolean autoRead)
ChannelConfig
ChannelOutboundInvoker.read()
will be invoked automatically so that a user application doesn't
need to call it at all. The default value is true
.setAutoRead
in interface ChannelConfig
public ChannelConfig.ChannelHandlerByteBufType getDefaultHandlerByteBufType()
ChannelConfig
ChannelConfig.ChannelHandlerByteBufType
which is used to determine what kind of ByteBuf
will
be created by the ChannelInboundByteHandler.newInboundBuffer(ChannelHandlerContext)
and
ChannelOutboundByteHandler.newOutboundBuffer(ChannelHandlerContext)
methods.
The implementation of ChannelInboundByteHandler
or ChannelOutboundByteHandler
may still return
another ByteBuf
if it depends on a special type.
The default is ChannelConfig.ChannelHandlerByteBufType.PREFER_DIRECT
.
getDefaultHandlerByteBufType
in interface ChannelConfig
public ChannelConfig setDefaultHandlerByteBufType(ChannelConfig.ChannelHandlerByteBufType handlerByteBufType)
ChannelConfig
ChannelConfig.ChannelHandlerByteBufType
which is used to determine what kind of ByteBuf
will
be created by the ChannelInboundByteHandler.newInboundBuffer(ChannelHandlerContext)
and
ChannelOutboundByteHandler.newOutboundBuffer(ChannelHandlerContext)
methods.setDefaultHandlerByteBufType
in interface ChannelConfig
Copyright © 2008-2013 The Netty Project. All Rights Reserved.