per session attributes

"Trustin Lee (이희승)" trustin at gmail.com
Wed Mar 17 01:41:49 EDT 2010


Hi,

It seemed to me that not everyone wants to use a Map-like data
structure.  You can simply attach a Map to the context and use some
utility methods to get the map.

Sorry about a not-very-helpful answer.
Trustin

falconair wrote:
> Hi Trustin,
> I've come across the need to access session variables again.  Wouldn't it be
> cleaner to add a Map to the context object?
> 
> In other words, in any handler, I could do the following:
> ...
> String myvar = ctx.getEnvironment("myvar");
> ...
> ctx.setEnvironment("myvar2","sessionID123");
> ...
> 
> I naturally keep expecting the context to provide such a
> functionality--variables set in one handler can be accessed by subsequent
> handlers.
> 
> 
> Trustin Lee wrote:
>> Hi falconair,
>>
>> myAttr (i.e. a ChannelLocal instance) is supposed to be accessible from
>> any handlers, so I would expose it as a public static final member
>> variable of some class.  For example:
>>
>>     public class MyChannelAttrs {
>>         public static final ChannelLocal<String> myAttr = ...;
>>     }
>>
>> HTH,
>> Trustin
>>
>> falconair wrote:
>>> I am trying to figure out how to set variables per connection.  Once a
>>> client
>>> connects to my server, they send a log on message with some attributes. 
>>> I'd
>>> like to make those attributes available to every filter/handler in my
>>> pipeline.
>>>
>>> Previous messages in the mailing list point to ChannelLocal, such as the
>>> following example:
>>>
>>> final ChannelLocal<String> myAttr = new ChannelLocal<String>(); 
>>>   ... 
>>>   String a = myAttr.get(channel); 
>>>   myAttr.set(channel, "newValue"); 
>>>   myAttr.remove(channel); 
>>>
>>> But I'm not sure how to use it exactly.  Am I supposed to 'put' myAttr in
>>> the ChannelHandlerContext?  In other words, say my logon handler
>>> retrieves
>>> my attribute, how do I make it available to subsequent handlers?
>>>
>>> Thanks
>>
>>  
>> _______________________________________________
>> netty-users mailing list
>> netty-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/netty-users
>>
>>

-- 
what we call human nature in actuality is human habit
http://gleamynode.net/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100317/b85ddc35/attachment.bin 


More information about the netty-users mailing list