directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trustin Lee <>
Subject Re: [mina] Filter management (was Spring Integration)
Date Sun, 13 Nov 2005 01:58:14 GMT

2005/11/13, Jose Alberto Fernandez <>:
> This is just a simple example, for many protocols one could come up with
> several scenarios where you can have similar issues. For example is I want
> to setup a different authentication filter and so on. This is why I think
> you need to provide a way to manipulate the filter chain.
> Now, Niklas could achieve what he wants by just extending the IoHandler:
> Handler = New XYZIoHandler() {
> public void sessionCreated(Session s) {
> super(s);
> s.getFilterChain().addAfter("threadFilter", new SSLFilter(…));
> }
> }
> What's wrong with all this? It does not look too efficient that you need
> to set up the same filters on every session creation. It seems to me much
> more efficient to configure them once when binding to the port and reuse it
> for every session. Now to do that you need some event call that allows for
> this global configuration to be set up at binding time.
Your IoFilterChainManager doesn't accept IoSession as a parameter, so it
cannot configure IoSession-level filters, either. Am I missing something

Now let's compare the two by example again:

1) Jose's approach
public class MyFilterChainBuilder implements IoFilterChainBuilder {
private final IoFilter TPF = new ThreadPoolFilter();
private final IoFilter SSLF = new SSLFilter();

public void buildFilterChain(IoFilterChain chain) { // this is a
SessionManager-level chain
chain.addLast( "threadPool", TPF );
chain.addLast( "SSL", SSLF );

acceptor.bind( addr, myFilterChainBuilder, myHandler);

2) Niklas's approach
public class MyFilterChainFactory {
private static final IoFilterChain COMMON_CHAIN;
static {
COMMON_CHAIN = new SimpleIoFilterChain();
COMMON_CHAIN.addLast( "threadPool", new ThreadPoolFilter() );
COMMON_CHAIN.addLast( "SSL", new SSLFilter() );

public static IoFilterChain getInstance() {
return (IoFilterChain) COMMON_CHAIN.clone();

acceptor.bind(add, MyFilterChainFactory.getInstance(), myHandler);

I thought these are identical?

what we call human nature is actually human habit
View raw message