directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niklas Therning <>
Subject Re: MINA FactoryBeans
Date Thu, 22 Dec 2005 06:53:09 GMT
Chris Allen wrote:
> Hi Niklas,
> I took a look at the Spring integration package today as you suggested,
> and it looks very promising. 
> One of my implementations of MINA is as a client, so I assume that the
> *SocketConnectorFactoryBean *class is what I would need to use to get my
> Socket connection going.  It looks kind of incomplete at the moment.  Is
> that the case?  I couldn't find the |AbstractIoConnectorFactoryBean
> |class in the JavaDocs and so therefore I'm not sure how you would
> configure it.  Also, will there be a way to add a custom
> ProtocolCodecFactory to the filterChain and configure that with Spring?
> Any information on this would be extremely appreciated.

The SocketConnectorFactoryBean lets you configure the filter chain of
your SocketConnector and set the connection timeout. Unfortunately the
Javadocs for the package
don't seem to be included when the docs are generated for the web page.
Any reason for that, Trustin? (I can see that all 'support' packages
have been left out)

In the meantime you can have a look at the code instead. What you need
are these classes:

The filter chain of a SocketConnectorFactoryBean is configured exactly
like a SocketAcceptorFactoryBean's chain. To use a ProtocolCodecFactory
your Spring config should look something like:

<bean id="myProtocolCodecFactory" class="MyProtocolCodecFactory">

<bean id="protocolCodecFilter"
  <constructor-arg ref="myProtocolCodecFactory"/>

<bean id="socketConnector"
  <property name="filters">
      <ref local="threadPoolFilter"/>
      <ref local="protocolCodecFilter"/>
  <property name="connectTimeout" value="30"/>

Then all you need to do is to call connect() on the Spring configured
connector in your Java code.

Please let me know if there are things which could be improved here.

> Another thing that I would love to see happen is for you guys to add
> some complete Spring examples on the website here:

Yes, we should definitely do that. I will add an issue to JIRA.


> All in good time I'm sure. ;-)
> Anyway, keep up the great work!
> -Chris
> On 12/21/05, *Niklas Therning* <
> <>> wrote:
>     Ither Seed wrote:
>     >>From: Niklas Therning < <>>
>     >>To: Apache Directory Developers List <
>     <>>
>     >>Date: Wed, 21 Dec 2005 07:38:20 +0100
>     >>Subject: Re: [MINA] getting accesss to the IoSession from another
>     Thread
>     >>Chris Allen wrote:
>     >>
>     >>>...
>     >>>
>     >>>In another topic, I'm curious about what you guys are doing in terms
>     >>>of Spring integration.  I saw that this was listed on your road map
>     >>>and I would like to learn more about it.
>     >>
>     >>Hi Chris,
>     >>
>     >>At the moment there are a number of Spring FactoryBeans in
>     >>org.apache.mina.integration.spring which simplifies the
>     >>configuration of
>     >>IoAcceptors and IoConnectors using Spring. There are also some
>     >>FactoryBeans which helps you set up KeyStores and SSLContexts for use
>     >>with the SSLFilter. Have a look at the Javadocs for
>     >>SocketAcceptorFactoryBean for a short example on how to use it. If
>     you
>     >>have any further questions or suggestions for improvements please
>     let me
>     >>know.
>     >>
>     >>BTW, the Spring integration package was introduced in 0.9.0.
>     >>
>     >>/Niklas
>     >
>     >
>     > Hi, people. I'm trying to use the FactoryBeans of MINA 0.9.0. I read
>     > the javadoc in the SocketAcceptorFactoryBean class and I successfully
>     > create a SocketAcceptor using it but I don't know how to make it wait
>     > for connections. All the examples use the ServiceRegistry interface
>     > for this. am I missing something? Thanks in advance.
>     You don't have to do anything! SocketAcceptor.bind() will be called for
>     each of the Bindings you set on your SocketAcceptor in your Spring
>     file.
>     Just make sure you have configured some bindings.
>     If you are using Spring's FileSystemApplicationContext to load you
>     Spring XML file all the beans you define will be automatically created
>     at load time. For other ApplicationContext implementations you may have
>     to call refresh() on it for the beans to be instantiated.
>     If you are using a BeanFactory such as XmlBeanFactory Spring will
>     instantiate your beans lazily when retrieved from the BeanFactory. In
>     that case you will have to call getBean() on the BeanFactory and supply
>     the id of the SocketAcceptorFactoryBean before Spring will create it.
>     HTH
>     /Niklas

Med vänlig hälsning

Niklas Therning
Software Architect
Mobil: +46 739 75 05 73

Trillian - Software Design at its best

View raw message