----- Original Message -----
> From: "Oleksiy Stashok" <oleksiy.stashok_at_oracle.com>
> To: users_at_grizzly.java.net
> Sent: Tuesday, June 28, 2011 10:07:28 AM
> Subject: Re: state machine in grizzly
> Hi Jon,
> > How would I go about building a state machine in Grizzly that could
> > handle incremental processing? Assuming I'm processing HTTP
> > requests, I can create some object and extract some information
> > when
> > the request starts. Then I don't want to have to do all that work
> > again every time handleRead gets called with a new chunk of
> > content.
>
> > Where do I save my stateful objects so that subsequent chunks of a
> > request can be accumulated until the HttpContent.isLast() is seen?
>
> You can try HttpHeader.getAttributes() (which might be either
> HttpRequestPacket or HttpResponsePacket), which will return
> AttributeHolder for this HttpHeader.
> AttributeHolder might be use to store custom attributes.
> For example create static final Attribute:
> private static final Attribute<MyType> MY_ATTR =
> Grizzly.DEFAULT_ATTRIBUTE_BUILDER.createAttribute(MY_ATTRIBUTE_NAME);
> and then get/set attribute on the HttpHeader:
> MY_ATTR.set(httpHeader, value);
> or
> MyType value = MY_ATTR.get(httpHeader);
> Hope this will help.
This should work.
This segregates the data based on request, right? So if I put an attribute onto the request, any other method call that gets this request will have access to that same object, right?
Thanks!
Jon Brisbin
http//jbrisbin.com
> Thanks.
> WBR,
> Alexey.
> PS: sorry don't have time to check the failing test today, will do
> that asap.
> > I need a state machine, basically, but it's not immediately
> > apparent
> > to me how to do that in Grizzly...
>
> > Thanks!
>
> > Jon Brisbin
>
> > http//jbrisbin.com
>