spirng4.1.2 + mina

集成配置文件如下:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xmlns:aop="http://www.springframework.org/schema/aop" 
       xmlns:tx="http://www.springframework.org/schema/tx" 
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
       http://www.springframework.org/schema/aop 
       http://www.springframework.org/schema/aop/spring-aop-2.5.xsd 
       http://www.springframework.org/schema/tx 
       http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

	<!-- mina server -->
	<bean id="trapHandler" class="com.mina.mydemo.handlers.ServerHandler" />
	 
	<bean id="snmpCodecFilter" class="org.apache.mina.filter.codec.ProtocolCodecFilter">
		  <constructor-arg>
		  	<!-- <bean class="org.apache.mina.filter.codec.textline.TextLineCodecFactory" />-->  
        	<!-- 处理对象流时候用ObjectSerializationCodecFactory -->  
        	 <bean class="org.apache.mina.filter.codec.serialization.ObjectSerializationCodecFactory" />  
		   <!--  <bean class="com.mina.mydemo.factorys.ServerCodeFactory" />-->  
		  </constructor-arg>
	</bean>
		
	<bean id="loggingFilter" class="org.apache.mina.filter.logging.LoggingFilter" />
	
	<!-- The filter chain. -->
	<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="snmpCodecFilter"/>
	    </map>
	  </property>
	</bean>
	 
	 
	
	 <bean 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>
	<!-- The IoAcceptor which binds to port 161 -->
	<bean id="ioAcceptor" class="org.apache.mina.transport.socket.nio.NioDatagramAcceptor" init-method="bind" destroy-method="unbind">
	  <property name="defaultLocalAddress" value=":161" />
	  <property name="handler" ref="trapHandler" />
	  <property name="filterChainBuilder" ref="filterChainBuilder" />
	</bean>
	
		
</beans>

 解决了 按照官网配置报错的问题。

你可能感兴趣的:(Mina)