users@grizzly.java.net

Re: ProtocolParser implementation II

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Mon, 19 May 2008 10:32:30 +0200

Hello Ken,

> Can I singleton MyProtocolParser so that I am not required to create
> a new
> instance of MyProtocolParser at ProtocolFiter?
In common it's possible to use ProtocolParser as singleton, when it
doesn't save any state. However in your case ProtocolParser is
stateful, as it saves start, pos, end parameters. So in your case -
it's not possible.
What you can do - is try to create some ProtocolParser instances pool,
so you will not need to create ProtocolParser instance all the time,
but reuse some of them.

Thanks.

WBR,
Alexey.

>
>
>
> private MyProtocolParser() {
> }
>
> private static MyProtocolParser instance = new MyProtocolParser();
>
> public static MyProtocolParser getInstance() {return instance;};
>
>
> // MyParserProtocolFilter
> public class MyParserProtocolFilter extends ParserProtocolFilter {
>
> /**
> * Creates a new instance of MyParserProtocolFilter
> */
> public MyParserProtocolFilter() {
> }
>
> public ProtocolParser newProtocolParser() {
> return MyProtocolParser.getInstance();
> }
> }
>
> --
> View this message in context: http://www.nabble.com/ProtocolParser-implementation-II-tp17152654p17288676.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>