> actually there is way...
> 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
my use case is different, i do not need attribute per user connection. i will explain why: application has about ~1200 - 5000 users connected, users are served by thread pool with size 32. Because every connection to database uses about 4 MB memory, i cant use 1:1 mapping between users and db connections. Using TLS storage as suggested by John would probably work too, but for now i switched to C3P0 connection pooling library.