Help getting started

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Help getting started

Tom Unger

I'm considering using the Grizzly framework to implement some non-HTTP  
protocols, starting with LPR (printing).  We may add some HTTP based  
services in the future and I think that Grizzly will provide a useful  
framework for implementing the communications we need.  I've read  
reference to components which I think I should use to implement my  
protocols, but so far am pretty clueless as to how to put together a  
program.  I've been unable to find a clear explanation of how to  
implement a simple non-http protocol.  The sample code I've read (and  
stepped through) does non-obvious things.  With out understanding the  
intention of the API I'll probably write code that uses it in  
appropriately and end up with a poor implementation.

So far I've downloaded the most recent code (via svn), compiled it in  
eclipse.  Browsed powerpoint slides from several presentations, a few  
other short articles, the javadoc, and wrote a simple example program  
which receives a connection and some data.

The LPR protocol is pretty simple.  The client connects, sends data,  
and the server sends a response.  Most requests require one receive-
respond cycle but submitting a print job requires several receive-
respond cycles.  After the request is complete the connection is closed.

Can you give me any pointers as to how to proceed?

Thanks,

Tom Unger
Seattle




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Help getting started

Jeanfrancois Arcand-2
Hi Tom,

Tom Unger wrote:

>
> I'm considering using the Grizzly framework to implement some non-HTTP
> protocols, starting with LPR (printing).  We may add some HTTP based
> services in the future and I think that Grizzly will provide a useful
> framework for implementing the communications we need.  I've read
> reference to components which I think I should use to implement my
> protocols, but so far am pretty clueless as to how to put together a
> program.  I've been unable to find a clear explanation of how to
> implement a simple non-http protocol.  The sample code I've read (and
> stepped through) does non-obvious things.  With out understanding the
> intention of the API I'll probably write code that uses it in
> appropriately and end up with a poor implementation.

OK I guess you looked at our documentations from here:


I've added some recently, but I agree we have a lot more to do :-)

>
> So far I've downloaded the most recent code (via svn), compiled it in
> eclipse.  Browsed powerpoint slides from several presentations, a few
> other short articles, the javadoc, and wrote a simple example program
> which receives a connection and some data.
>
> The LPR protocol is pretty simple.  The client connects, sends data, and
> the server sends a response.  Most requests require one receive-respond
> cycle but submitting a print job requires several receive-respond
> cycles.  After the request is complete the connection is closed.
>
> Can you give me any pointers as to how to proceed?

 From your description, the only grizzly module you need to consider is the:

module/grizzly

 From that module, all you need to do is to write your protocol parser
logic (LPR). The Read/Write operation can be handled by Grizzly itself.
Below is a simple code snipped that describe what you need to do. The
class you have to write is called LPRProtocolFilter:

>         TCPSelectorHandler selectorHandler = new TCPSelectorHandler();
>         selectorHandler.setPort(port);
>        
>         final Controller controller = new Controller();      
>         controller.setSelectorHandler(selectorHandler);
>        
>         controller.setProtocolChainInstanceHandler(
>                 new DefaultProtocolChainInstanceHandler(){
>             @Override
>             public ProtocolChain poll() {
>                 ProtocolChain protocolChain = protocolChains.poll();
>                 if (protocolChain == null){
>                     protocolChain = new DefaultProtocolChain();
>                     protocolChain.addFilter(new ReadFilter());
>                     protocolChain.addFilter(new LPRProtocolFilter());
>                 }
>                 return protocolChain;
>             }
>         });
>         controller.start();

The only class you should focus on right now is the LPRProtocolFilter().
The LPR protocol doesn't seems to be complicated, but in case I'm wrong,
you might want to use the ProtocolParser interface:

http://weblogs.java.net/blog/sdo/archive/2007/12/grizzly_protoco.html

Hope that help.

-- Jeanfrancois

>
> Thanks,
>
> Tom Unger
> Seattle
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]