public class ChannelLocal<T> extends Object
Channel
. Think of this as a
variation of ThreadLocal
whose key is a Channel
rather than
a Thread.currentThread()
. One difference is that you always have to
specify the Channel
to access the variable.
Alternatively, you might want to use the
ChannelHandlerContext.attachment
property, which performs better.
Constructor and Description |
---|
ChannelLocal()
Creates a
Channel local variable. |
Modifier and Type | Method and Description |
---|---|
T |
get(Channel channel)
Returns the value of this variable.
|
protected T |
initialValue(Channel channel)
Returns the initial value of the variable.
|
T |
remove(Channel channel)
Removes the variable.
|
T |
set(Channel channel,
T value)
Sets the value of this variable.
|
T |
setIfAbsent(Channel channel,
T value)
Sets the value of this variable only when no value was set.
|
public ChannelLocal()
Channel
local variable.protected T initialValue(Channel channel)
null
. Override it to change the initial value.public T set(Channel channel, T value)
null
if there was no old value.public T setIfAbsent(Channel channel, T value)
null
if the specified value was set.
An existing value if failed to set.Copyright © 2008-2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.