mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Ulrich <steve.ulr...@proemion.com>
Subject RE: onPreAdd, PostAdd, remove : correction no---signature
Date Mon, 10 Nov 2008 08:06:08 GMT
> Emmanuel Lecharny [mailto:elecharny@gmail.com] wrote
>
> Hi,

Hi!

I have already used them for some session specific initialization.

> those methods are called when a new filter is registred into the chain.
> However, the few filters implementing those methods typically check
> that
> the added filter is not already present in the chain :
>
> ProtocolCodecFilter, ExecutorFilter, KeepAliveFilter :
>     public void onPreAdd(IoFilterChain parent, String name,
>             NextFilter nextFilter) throws Exception {
>         if (parent.contains(this)) {
>             throw new IllegalArgumentException(
>                     "You can't add the same filter instance more than
> once.  Create another instance and add it.");
>
> but SslFilter does some intrigating things, which seems to me deserves
> to be found in a init() method.

An init() method doesn't know anything about the session so far.

> IMO, pre/post operation are just a bit too much. The way it should be
> done is :
> - init the filter
> - add/remove a filter from the chain

I can't imagine a good reason to use postAdd or preRemove, but a lot for preAdd and postRemove.

> and that's it.
>
> Anyone has a better vision of what those method are good for ?

They are good to initialize or cleanup session specific contexts.

regards

Steve

Mime
View raw message