Class IoAcceptorFactoryBean
- java.lang.Object
-
- org.apache.mina.integration.spring.IoAcceptorFactoryBean
-
- All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.FactoryBean,org.springframework.beans.factory.InitializingBean
public class IoAcceptorFactoryBean extends java.lang.Object implements org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBeanSpringFactoryBeanwhich enables the bindings of anIoAcceptorto be configured using Spring. Example of usage:<!-- This makes it possible to specify java.net.SocketAddress values (e.g. :80 below) as Strings. They will be converted into java.net.InetSocketAddress objects by Spring. --> <bean class="org.springframework.beans.factory.config.CustomEditorConfigurer"> <property name="customEditors"> <map> <entry key="java.net.SocketAddress"> <bean class="org.apache.mina.integration.spring.InetSocketAddressEditor"/> </entry> </map> </property> </bean> <!-- The IoHandler implementation --> <bean id="httpHandler" class="com.example.MyHttpHandler"> ... </bean> <bean id="filterChainBuilder" class="org.apache.mina.integration.spring.DefaultIoFilterChainBuilderFactoryBean"> <property name="filters"> <list> <bean class="org.apache.mina.filter.LoggingFilter"/> </list> </property> </bean> <!-- By default MINA uses an ExecutorThreadModel. This demonstrates how to use your own with some non default settings. The threadModel will be set on the SocketAcceptorConfig defined below. To configure a ExecutorFilter directly you will have to use the ThreadModel.MANUAL ThreadModel instead. --> <bean id="threadModel" class="org.apache.mina.integration.spring.ExecutorThreadModelFactoryBean"> <property name="serviceName" value="HttpService"/> <property name="executor"> <bean class="org.apache.mina.integration.spring.ThreadPoolExecutorFactoryBean"> <property name="corePoolSize" value="2"/> <property name="maxPoolSize" value="10"/> <property name="keepAliveSeconds" value="30"/> </bean> </property> </bean> <bean id="ioAcceptor" class="org.apache.mina.integration.spring.IoAcceptorFactoryBean"> <property name="target"> <bean class="org.apache.mina.transport.socket.nio.SocketAcceptor"/> </property> <property name="bindings"> <list> <bean class="org.apache.mina.integration.spring.Binding"> <property name="address" value=":80"/> <property name="handler" ref="httpHandler"/> <property name="serviceConfig"> <bean class="org.apache.mina.transport.socket.nio.SocketAcceptorConfig"> <property name="filterChainBuilder" ref="filterChainBuilder"/> <property name="reuseAddress" value="true"/> <property name="threadModel" ref="threadModel"/> </bean> </property> </bean> </list> </property> </bean>
-
-
Constructor Summary
Constructors Constructor Description IoAcceptorFactoryBean()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()voiddestroy()java.lang.ObjectgetObject()java.lang.ClassgetObjectType()booleanisSingleton()voidsetBindings(Binding[] bindings)Sets the bindings to be used by theIoAcceptorconfigured by this factory bean.voidsetTarget(org.apache.mina.common.IoAcceptor target)Sets theIoAcceptorto be configured using this factory bean.
-
-
-
Method Detail
-
setTarget
public void setTarget(org.apache.mina.common.IoAcceptor target)
Sets theIoAcceptorto be configured using this factory bean.- Parameters:
target- the targetIoAcceptor.
-
setBindings
public void setBindings(Binding[] bindings)
Sets the bindings to be used by theIoAcceptorconfigured by this factory bean.- Parameters:
bindings- the bindings.- Throws:
java.lang.IllegalArgumentException- if the specified value isnull.- See Also:
IoAcceptor.bind(SocketAddress, IoHandler),IoAcceptor.bind(SocketAddress, IoHandler, IoServiceConfig),Binding
-
getObject
public java.lang.Object getObject() throws java.lang.Exception- Specified by:
getObjectin interfaceorg.springframework.beans.factory.FactoryBean- Throws:
java.lang.Exception
-
getObjectType
public java.lang.Class getObjectType()
- Specified by:
getObjectTypein interfaceorg.springframework.beans.factory.FactoryBean
-
isSingleton
public boolean isSingleton()
- Specified by:
isSingletonin interfaceorg.springframework.beans.factory.FactoryBean
-
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
java.lang.Exception
-
destroy
public void destroy() throws java.lang.Exception- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Throws:
java.lang.Exception
-
-