Mina框架与Spring整合配置文件

  • 时间:
  • 浏览:0
  • 来源:uu直播快3平台_UU快3直播官方

米娜框架与春天的整合实在很简单,主就说 要弄清楚要注入的属性的名称,进而选泽 至少的注入土办法 。

<beans

xmlns =“http://www.springframework.org/schema/beans” xmlns:xsi =“http://www.w3.org/60 1/XMLSchema-instance” xmlns:context =“http:// www .springframework.org / schema / context“ xsi:schemaLocation =”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http:// www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd“> <! - 业务补救逻辑 - > <bean id =”handler“class =” com.mina.handler.StrategyFactoryHandler“/>

<! - 累加数据包解码器:解断丢包,粘包间题报告 - >

<bean id =“codec”class =“org.apache.mina.filter.codec.ProtocolCodecFilter”> <constructor-arg> < bean class =“com.mina.codec.MyCodecFcatory”> <constructor-arg index =“0”> <bean class =“com.mina.codec.MyEncoder”> </ bean> </ constructor-arg> <constructor- arg index =“1”> <bean class =“com.mina.codec.MyDecoder”> </ bean> </ constructor-arg>

<?xml version =“1.0”encoding =“UTF-8”?>

<! - 多多多线程 补救过滤器,为顶端的操作开启多多多线程 ,一般装入 编解码过滤器过后 ,开始了了业务逻辑补救 - >

<bean id =“executors”class =“org.apache.mina。 filter.executor.ExecutorFilter“/> <! - Mina自带日志过滤器默认级别为debug - > <bean id =”loggerFilter“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 =“codec”value-ref =“codec”/> <entry key =“logger”value-ref =“loggerFilter”/> <entry key =“executors” value-ref =“executors”/> </ map> </ property> </ bean> <! - 监听端口 - > <bean id =“defaultLocalAddress”class =“java.net.InetSocketAddress”> <constructor- arg index =“0”value =“$ {tcpPort}”> </ constructor-arg> </ bean> <! - session config通过工厂土办法 注入 - > <bean id =“sessionConfig”factory-bean =“ ioAcceptor“factory-method =”getSessionConfig“><property name =“readerIdleTime”value =“10”/> <property name =“minReadBufferSize”value =“512”/> <property name =“maxReadBufferSize”value =“10240”/> </ bean><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”ref =“defaultLocalAddress” /> <property name =“handler”ref =“handler”/> <property name =“filterChainBuilder”ref =“filterChainBuilder”/> </ bean> </ beans>

</ bean>

</ constructor-arg> </ bean>

地址原文http://www.bieryun.com/160 0.html