Ming Qin
Cell Phone 858-353-2839
--- On Wed, 3/3/10, Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM> wrote:
From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Subject: Re: Grizzly 2dot0 : Smart String Filter with Multiple String Terminator Symbols
To: dev_at_grizzly.dev.java.net
Date: Wednesday, March 3, 2010, 3:11 AM
Hi Ming Qin,
smart filters is something I didn't touch for a long time and wanted to come back to it sometime in future.So if you have interest to reimplement smart filters and make it working - you're welcome, will appreciate that.
I'd look at SmartStringFilter as a part of SmartFilter. SmartFilter was originally intended to hide the parsing process, and make possible to serialize/deserialize POJO objects (sometimes with Java annotations help).So coming back to SmartStringFilter, as part of SmartFilter you can define following class:
class MyCusomPacket { @CharSequence(terminate="\r\n") String a;
@CharSequence(terminate="abc") String b;}
and SmartFilter, using SmartStringFilter, should be able to serialize/deserialize correctly instances of MyCustomPacket class.
Also, talking about SmartFilters, there is project google protobuf [1], which defines general protocol description language. It could be interesting to have Grizzly 2.0 support for that, for example Mina and Netty have it.
Will appreciate your help.
Thanks.
WBR,Alexey.
[1]
http://code.google.com/p/protobuf/
On Mar 3, 2010, at 9:06 , ming qin wrote:
Grizzly 2dot0 : Smart String Filter with Multiple String Terminator Symbols Scenario: In string-based protocol, one intended string request is started with starter symbol-“ watchVideo” and ended with terminator symbol “\r#\n”,
another intended string request is started with started symbol-“listenMusic” and ended with terminator symbol “\r&*ABC” Feature of SmartStringFilter Grizzly 2dot0’s Processor will be driven by SmartStringFiltor to constantly polling a Channel to read bytes till whole intended string request is read into memory-Grizzly CompoisteByte The tricky parts of above processor polling are : Individual string request has unique starter and terminator symbols. String requests are not flowed into server in unpredictable order. Proposal:
Can I implement above feature in Grizzly 2dot0 as SmartStringFilter(Charset. Charset , String … stringStartingTerminatingSymbs ); Below is my server main code to import this kind of smartStringFilter: public static void main(String[] args) throws IOException { // Create a FilterChain using FilterChainBuilder FilterChainBuilder filterChainBuilder = FilterChainBuilder.singleton(); // Add TransportFilter, which is responsible // for reading and writing data to the connection filterChainBuilder.add(new TransportFilter()); // StringFilter is responsible for parsing single string line filterChainBuilder.add(new SmartStringFilter(Charset.forName("US-ASCII"), “ watchVideo|\r#\n “ , …… “listenMusic| r&*ABC “ )); …… filterChainBuilder.add(new
EchoFilter()); ….. transport.start(); ,,,,,, ,,,,,
Ming Qin
Cell Phone 858-353-2839