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.
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
>
>