users@grizzly.java.net

Re: attaching user data to GrizzlyWorkerThread

From: ThanhTran <thanhtb_at_gmail.com>
Date: Mon, 27 Oct 2008 09:56:10 -0700 (PDT)

Hi guys,

I tried as you comment, but, sometime with new connection, AttributeHolder
still has instance and it's not null. I don't know why. Could you suggest a
solution for that ?

Thanks,
Thanh Tran.


Oleksiy Stashok wrote:
>
> Ahoj :)
> Inside your filter please do following:
>
> AttributeHolder connectionAttrs =
>
> ctx.getAttributeHolderByScope(AttributeScope.CONNECTION);
> if (connectionAttrs == null) {
> WorkerThread workerThread = (WorkerThread)
> Thread.currentThread();
> // Detach the current Thread data.
> ThreadAttachment threadAttachment =
> workerThread.getAttachment();
> // Attach it to the SelectionKey so the it can be resumed
> latter.
> key.attach(threadAttachment);
> connectionAttrs =
> ctx.getAttributeHolderByScope(AttributeScope.CONNECTION);
> }
>
> connectionAttrs.get/set
>
> Hope this will help.
>
> WBR,
> Alexey.
>
>

-- 
View this message in context: http://www.nabble.com/attaching-user-data-to-GrizzlyWorkerThread-tp18966029p20191751.html
Sent from the Grizzly - Users mailing list archive at Nabble.com.