users@grizzly.java.net

Re: attaching user data to GrizzlyWorkerThread

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Thu, 21 Aug 2008 13:42:17 +0200

Ahoj :)

actually there is way...

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.

On Aug 20, 2008, at 16:42 , hsn_at_sendmail.cz wrote:

> > WorkerThread is designed to not hold on to State inbetween different
> > Requests.
> Are there plans to add this functionality? i think i could soubmit
> patch which will adds
> Context.AttributeScope.WORKER, i want to use this for pooling JDBC
> connections.