You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Steven <xi...@126.com> on 2008/03/17 03:15:11 UTC

Re:Re: Do I need to call the IoSession.removeAttribute method to remove

 
Trustin Lee,

Thank you very much!

Steven

 
 
 

在2008-03-17,"이희승 (Trustin Lee)" <tr...@gmail.com> 写道:

Hi Steven,

On Sun, 16 Mar 2008 15:05:34 +0900, Steven <xi...@126.com> wrote:

> Or Mina will remove them automatically?

Once a connection is closed, its associated session object will be garbage  
collected, and therefore all related attributes will be cleared by JVM.

> And what should I do if I want to add lots of attributes to one  
> IoSession?
> Should I add them separately like this:
> session.setAttachment(k1,v1);
> session.setAttachment(k2,v2);
> session.setAttachment(k3,v3);
> Or should I create an class that contains all these attributes and then  
> add this class to the IoSession's attribute map?

I recommend you to create a dedicated class that contains all attributes,  
because accessing attributes requires synchronization.

> Is there any way to customize the IoSession class?
> I mean , can I create my own IoSession class that contains all the  
> attributes that I need and then call some methods like this to use it:
> acceptor.SetIoSession(myOwnIoSession);

Please take a look at IoSessionAttributeInitializingFilter or  
IoSessionDataStructureFactory.

HTH,

-- 
Trustin Lee - Principal Software Engineer, JBoss, Red Hat
--
what we call human nature is actually human habit
--
http://gleamynode.net/