<!-- Mina 整合 -->
<!-- slf4j-api-1.7.7.jar -->
<!-- slf4j-log4j12-1.7.7.jar -->
<!-- 配置 textCodecFilter <bean id="textCodecFilter" class="org.apache.mina.filter.codec.ProtocolCodecFilter">
<constructor-arg> <bean class="com.founder.bank.util.TextLineChineseCodecFactory"></bean>
</constructor-arg> </bean> -->
<!-- 字符编 码过滤器,改为判断报文头固定长度 -->
<bean id="codecFilter" class="org.apache.mina.filter.codec.ProtocolCodecFilter">
<constructor-arg>
<bean class="com.founder.bank.util.PrefixedStringCodecFactory"></bean>
</constructor-arg>
</bean>
<!-- 多线程处理过滤器,的操作开启多线程,一般放在编解码过滤器之后, IO 线程与业务处理线程分开 -->
<bean id="executors" class="org.apache.mina.filter.executor.ExecutorFilter">
<constructor-arg index="0">
<value>1000</value>
</constructor-arg>
<constructor-arg index="1">
<value>1800</value>
</constructor-arg>
</bean>
<!-- 将IoSession的主键属性注入线程映射表MDC中 -->
<bean id="mdcInjectionFilter" class="org.apache.mina.filter.logging.MdcInjectionFilter">
<!-- <constructor-arg value="remoteAddress" /> -->
</bean>
<!-- 日志过滤器 -->
<bean id="loggingFilter" class="org.apache.mina.filter.logging.LoggingFilter">
<!-- <property name="messageReceivedLogLevel" ref="info"></property> <property
name="exceptionCaughtLogLevel" ref="info"></property> -->
</bean>
<!-- <bean id="info" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<property name="staticField" value="org.apache.mina.filter.logging.LogLevel.INFO"
/> </bean> -->
<!-- 过滤器链 -->
<bean id="filterChainBuilder"
class="org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder">
<property name="filters">
<map>
<entry key="loggingFilter" value-ref="loggingFilter" />
<entry key="codecFilter" value-ref="codecFilter" />
<entry key="executors" value-ref="executors" />
</map>
</property>
</bean>
<!-- 过滤器链2 <bean id="filterChainBuilderText" class="org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder">
<property name="filters"> <map> <entry key="loggingFilter" value-ref="loggingFilter"
/> <entry key="codecFilter" value-ref="textCodecFilter" /> <entry key="mdcInjectionFilter"
value-ref="mdcInjectionFilter" /> <entry key="executors" value-ref="executors"
/> </map> </property> </bean> -->
<!-- 设置 I/O 接受器,并指定接收到请求后交给 serverHandler 进行处理 -->
<bean id="customEditorConfigurer"
class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="java.net.SocketAddress"
value="org.apache.mina.integration.beans.InetSocketAddressEditor" />
</map>
</property>
</bean>
<!-- session config 通过工厂方法注入 -->
<bean id="sessionConfig" factory-bean="ioAcceptor" factory-method="getSessionConfig">
<property name="writeTimeout" value="30" />
<property name="bothIdleTime" value="30" />
<property name="minReadBufferSize" value="512" />
<property name="maxReadBufferSize" value="10240" />
</bean>
<!-- 定义数据处理Bean,接收到请求后交给 serverHandle -->
<bean id="serverHandler" class="com.founder.bank.filter.ServerHandler" />
<!-- IoAccepter,绑定到8888端口 -->
<bean id="ioAcceptor" class="org.apache.mina.transport.socket.nio.NioSocketAcceptor"
init-method="bind" destroy-method="unbind">
<!-- 默认启用的线程个数是CPU 的核数+1, -->
<!--<constructor-arg index="0" value="10"></constructor-arg> -->
<property name="defaultLocalAddress" value=":8888" />
<property name="handler" ref="serverHandler" />
<property name="reuseAddress" value="true" />
<property name="filterChainBuilder" ref="filterChainBuilder" />
</bean>
<!-- IoAccepter,绑定到8889端口 <bean id="ioAcceptorText" class="org.apache.mina.transport.socket.nio.NioSocketAcceptor"
init-method="bind" destroy-method="unbind"> <property name="defaultLocalAddress"
value=":8889" /> <property name="handler" ref="serverHandler" /> <property
name="reuseAddress" value="true" /> <property name="filterChainBuilder" ref="filterChainBuilderText"
/> </bean> -->
<!-- slf4j-api-1.7.7.jar -->
<!-- slf4j-log4j12-1.7.7.jar -->
<!-- 配置 textCodecFilter <bean id="textCodecFilter" class="org.apache.mina.filter.codec.ProtocolCodecFilter">
<constructor-arg> <bean class="com.founder.bank.util.TextLineChineseCodecFactory"></bean>
</constructor-arg> </bean> -->
<!-- 字符编 码过滤器,改为判断报文头固定长度 -->
<bean id="codecFilter" class="org.apache.mina.filter.codec.ProtocolCodecFilter">
<constructor-arg>
<bean class="com.founder.bank.util.PrefixedStringCodecFactory"></bean>
</constructor-arg>
</bean>
<!-- 多线程处理过滤器,的操作开启多线程,一般放在编解码过滤器之后, IO 线程与业务处理线程分开 -->
<bean id="executors" class="org.apache.mina.filter.executor.ExecutorFilter">
<constructor-arg index="0">
<value>1000</value>
</constructor-arg>
<constructor-arg index="1">
<value>1800</value>
</constructor-arg>
</bean>
<!-- 将IoSession的主键属性注入线程映射表MDC中 -->
<bean id="mdcInjectionFilter" class="org.apache.mina.filter.logging.MdcInjectionFilter">
<!-- <constructor-arg value="remoteAddress" /> -->
</bean>
<!-- 日志过滤器 -->
<bean id="loggingFilter" class="org.apache.mina.filter.logging.LoggingFilter">
<!-- <property name="messageReceivedLogLevel" ref="info"></property> <property
name="exceptionCaughtLogLevel" ref="info"></property> -->
</bean>
<!-- <bean id="info" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<property name="staticField" value="org.apache.mina.filter.logging.LogLevel.INFO"
/> </bean> -->
<!-- 过滤器链 -->
<bean id="filterChainBuilder"
class="org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder">
<property name="filters">
<map>
<entry key="loggingFilter" value-ref="loggingFilter" />
<entry key="codecFilter" value-ref="codecFilter" />
<entry key="executors" value-ref="executors" />
</map>
</property>
</bean>
<!-- 过滤器链2 <bean id="filterChainBuilderText" class="org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder">
<property name="filters"> <map> <entry key="loggingFilter" value-ref="loggingFilter"
/> <entry key="codecFilter" value-ref="textCodecFilter" /> <entry key="mdcInjectionFilter"
value-ref="mdcInjectionFilter" /> <entry key="executors" value-ref="executors"
/> </map> </property> </bean> -->
<!-- 设置 I/O 接受器,并指定接收到请求后交给 serverHandler 进行处理 -->
<bean id="customEditorConfigurer"
class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="java.net.SocketAddress"
value="org.apache.mina.integration.beans.InetSocketAddressEditor" />
</map>
</property>
</bean>
<!-- session config 通过工厂方法注入 -->
<bean id="sessionConfig" factory-bean="ioAcceptor" factory-method="getSessionConfig">
<property name="writeTimeout" value="30" />
<property name="bothIdleTime" value="30" />
<property name="minReadBufferSize" value="512" />
<property name="maxReadBufferSize" value="10240" />
</bean>
<!-- 定义数据处理Bean,接收到请求后交给 serverHandle -->
<bean id="serverHandler" class="com.founder.bank.filter.ServerHandler" />
<!-- IoAccepter,绑定到8888端口 -->
<bean id="ioAcceptor" class="org.apache.mina.transport.socket.nio.NioSocketAcceptor"
init-method="bind" destroy-method="unbind">
<!-- 默认启用的线程个数是CPU 的核数+1, -->
<!--<constructor-arg index="0" value="10"></constructor-arg> -->
<property name="defaultLocalAddress" value=":8888" />
<property name="handler" ref="serverHandler" />
<property name="reuseAddress" value="true" />
<property name="filterChainBuilder" ref="filterChainBuilder" />
</bean>
<!-- IoAccepter,绑定到8889端口 <bean id="ioAcceptorText" class="org.apache.mina.transport.socket.nio.NioSocketAcceptor"
init-method="bind" destroy-method="unbind"> <property name="defaultLocalAddress"
value=":8889" /> <property name="handler" ref="serverHandler" /> <property
name="reuseAddress" value="true" /> <property name="filterChainBuilder" ref="filterChainBuilderText"
/> </bean> -->