List of usage examples for io.netty.util Attribute get
T get();
From source file:qunar.tc.qmq.util.ChannelUtil.java
License:Apache License
public static boolean setAttributeIfAbsent(Channel channel, Object o) { synchronized (channel) { Attribute<Object> attr = channel.attr(DEFAULT_ATTRIBUTE); if (attr == null || attr.get() == null) { channel.attr(DEFAULT_ATTRIBUTE).set(o); return true; }//w ww . j av a 2 s . c o m return false; } }
From source file:sailfish.remoting.channel.HighPerformanceChannelWriter.java
License:Apache License
private static HighPerformanceChannelWriter getWriter(Channel channel) { Attribute<HighPerformanceChannelWriter> attr = channel.attr(ChannelAttrKeys.highPerformanceWriter); HighPerformanceChannelWriter writer = attr.get(); if (null == writer) { HighPerformanceChannelWriter old = attr.setIfAbsent(writer = new HighPerformanceChannelWriter(channel)); if (null != old) { writer = old;/*from ww w . j a v a 2s .co m*/ } } return writer; }
From source file:sailfish.remoting.utils.ChannelUtil.java
License:Apache License
public static boolean clientSide(ChannelHandlerContext ctx) { Attribute<Boolean> clientSideAttr = ctx.channel().attr(ChannelAttrKeys.clientSide); return (null != clientSideAttr && null != clientSideAttr.get() && clientSideAttr.get()); }