users@grizzly.java.net

Re: Patch for com.sun.grizzlyController...

From: Erik Svensson <erik.svensson_at_six.se>
Date: Mon, 11 Feb 2008 15:53:41 +0100

Howdy all,

My patch below does not work if you want to add more than one protocol
filter to the chain. This is due to the behaviour of the
DefaultProtocolChainInstanceHandler. If DefaultProtocolChainInstanceHandler
is modified according to my previous mail it will work.

cheers

Erik Svensson, SIX AB

> Howdy all!
>
> In an effort to make my life easier I've patched Controller with two
> AddProtocolFilter() methods and one RemoveProtocolFilter().
> Code snippet below.
> The addProtocolFilter():s check for the presence of a
> ProtocolChainInstanceHandler and if there isn't one, creates a new
> DefaultProtocolChainInstanceHandler and add the protocol filter to it.
> A question: in ProtocolChain there are two add methods:
>
> public boolean addFilter(ProtocolFilter protocolFilter);
> public void addFilter(int pos, ProtocolFilter protocolFilter);
>
> Should the second really return void, shouldn't it return boolean?
>
>
> code snippet:
>
> public boolean addProtocolFilter(ProtocolFilter protocolFilter) {
> if (null == instanceHandler ) {
> instanceHandler = new DefaultProtocolChainInstanceHandler();
> }
> return instanceHandler.poll().addFilter(protocolFilter);
> }
>
> public void addProtocolFilter(ProtocolFilter protocolFilter, int position)
> {
> if (null == instanceHandler) {
> instanceHandler = new DefaultProtocolChainInstanceHandler();
> }
> instanceHandler.poll().addFilter(position, protocolFilter);
> }
>
> public boolean removeProtocolFilter(ProtocolFilter protocolFilter) {
> if (instanceHandler != null) {
> return instanceHandler.poll().removeFilter(protocolFilter);
> }
> return false;
> }
>
>
> cheers
> Erik Svensson, SIX AB
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>