Hi John,
IMHO right thing to do - is to store Attributes in ThreadAttachment.
You can set it directly using ThreadAttachment or
ctx.getAttributeHolderByScope(AttributeScope.CONNECTION).
It shouldn't be overwritten :)
Thanks.
WBR,
Alexey.
On May 22, 2008, at 17:45 , John ROM wrote:
> I'm only using the basic grizzly framework module and building an
> server.
>
> I have selectionKeys which (hopefully) often last 12 hours.
>
> With each connection I need to store an Integer (project_id).
>
> This Integer will then be retrieved with code like:
> //iterate over all existings connections and find
> // keys with specific ids.
>
> selector.selectNow()
>
> Set<SelectionKey> selectionKeys = tCPSelectorHandler.keys();
> for (SelectionKey key : selectionKeys) {
> if(key.valid()
> // Get Integer out of maybe ThreadAttachment
> key.attachment();
> }
> }
>
>
> I am a little afraid that Grizzly might overwrite the attachment
> in my keys.
>
> Maybe its better to store the integers somewhere else together with
> selectorKey.hashcode() and hope that two keys will never have the same
> hashcodes...
>
> So....
>
> What is the best way to attach something to an selectorKey or in other
> words what is the pendant to
> AttributeHolder connectionAttrs =
>
> ctx.getAttributeHolderByScope(AttributeScope.CONNECTION);
>
>
> Many Greetings John
>
>
>
>
> --
> Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
> Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>