users@grizzly.java.net

Re: Correct way to save state variable per connection

From: LongkerDandy <longkerdandy_at_gmail.com>
Date: Fri, 13 Jun 2014 13:13:04 +0800

Hi Alexey

So it is expected behavior that:
A new FilterChainContext was created when new message came in.
Different connection share the same Filter instance, and Filter is somehow
singleton.

Regards
LongkerDandy


On Fri, Jun 13, 2014 at 11:43 AM, Oleksiy Stashok <
oleksiy.stashok_at_oracle.com> wrote:

> Hi,
>
> you can associate an Attribute with a Connection like:
>
> private final Attribute<*AttrType*> attribute =
> Grizzly.DEFAULT_ATTRIBUTE_BUILDER.createAttribute(*attributeNameString*);
> ..........
>
> attribute.set(connection, *value*);
> ..........
>
> attribute.get(connection);
> ...........
>
> attribute.remove(connection);
> ............
>
> WBR,
> Alexey.
>
>
>
> On 12.06.14 20:01, LongkerDandy wrote:
>
> Hi
>
> On TCP serevr side, I tried to save some state information per connection.
> Like the user id which already logged in.
> I'm trying use FilterChainContext.getAttributes().getAttribute and
> setAttribute.
> But seems I got a new FilterChainContext and new Filter instances
> everytime new message arrived.
> And my previous setted attributes are gone.
>
> So, what is the correct way to keep this state information?
>
> Regards
> LongkerDandy
>
>
>