directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jose Alberto Fernandez" <>
Subject RE: [mina] Spring integration
Date Wed, 02 Nov 2005 10:52:55 GMT
Just wondering, 


Here the filters are stored in a Spring Map. But isn't the order of the
filters meaningful? Shouldn't we have to specify the order somewhere?


Jose Alberto




From: Trustin Lee [] 
Sent: 02 November 2005 01:22
To: Apache Directory Developers List
Subject: Re: [mina] Spring integration


Hi Niklas,

2005/11/2, Niklas Therning <>:


I've played around a bit with getting Mina to work nicely with Spring.
Right now the Mina classes are quite Dependency Injection unfriendly.
But by implementing a few Spring FactoryBeans it is possible to make 
Mina easily configurable using Spring, at least for my needs.

Basically what I want is to be able to define the filters used by my
SocketConnector and SocketAcceptor and, for the SocketAcceptor, also the
bindings. This is what it looks like in Spring XML:

<bean id="threadPoolFilter"
  <constructor-arg value="WorkerThread"/><!-- This is the prefix used by

threads in the pool -->
  <property name="maximumPoolSize" value="10"/>

<!-- My SocketAcceptor -->
<bean id="socketAcceptor"
class=" org.apache.mina.spring.SocketAcceptorFactoryBean">
    <property name="filters">
        <entry key="blacklist">
          <bean class="org.apache.mina.filter.BlacklistFilter ">
            <property name="blacklist">
                <!-- Put all hosts to be blacklisted here. -->
                <value> <> </value>
        <entry key="threadPool" value-ref="threadPoolFilter"/>
    <property name="bindings">
        <!-- Bind to port 1234 on and use myHandler as the
        <entry key="" value-ref="myHandler"/>

<!-- My SocketConnector -->
  <bean id="socketConnector"
    <property name="filters"> 
        <entry key="threadPool" value-ref="threadPoolFilter"/>
    <property name="connectTimeout" value="30"/> 

<bean id="myHandler" class="MyHandler"/>

The only thing I've had to change in the original Mina code to make this
work is the "blacklist" property which have been added to the 
BlackListFilter class.

SocketAcceptorFactoryBean will take care of binding and unbinding as the
Spring context is created and destroyed. No need for a ServiceRegistry
as I see it. Both SocketAcceptorFactoryBean and 
SocketConnectorFactoryBean will add all configured filters to the end of
the filter chain.

WDYT? I will happily contribute this code back to the project if you
think it could be useful. The same could also be done for 


Thank you so much for your continuous contribution! :D

We appreciate it, of course!  Please submit your patch to JIRA and I'll
merge it as soon as I make MINA Maven multiproject. 

Thanks again,
what we call human nature is actually human habit

View raw message