Class ChannelLocal<T>
java.lang.Object
org.jboss.netty.channel.ChannelLocal<T>
A global variable that is local to a
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentMap<Channel, T> private final booleanprivate final ChannelFutureListener -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of this variable.protected TinitialValue(Channel channel) Returns the initial value of the variable.iterator()Removes the variable and returns the removed value.Sets the value of this variable.setIfAbsent(Channel channel, T value) Sets the value of this variable only when no value was set.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
map
-
remover
-
removeOnClose
private final boolean removeOnClose
-
-
Constructor Details
-
ChannelLocal
public ChannelLocal() -
ChannelLocal
public ChannelLocal(boolean removeOnClose) Creates aChannellocal variable.- Parameters:
removeOnClose- iftruetheChannelLocalwill remove aChannelfrom it own once theChannelwas closed.
-
-
Method Details
-
initialValue
-
get
-
set
-
setIfAbsent
-
remove
Removes the variable and returns the removed value. If no value was set, this method returns the return value ofinitialValue(Channel), which isnullby default.- Returns:
- the removed value.
an initial value (by default
null) if no value was set.
-
iterator
-