先来看spring中的配置:

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

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


 <bean
  class="org.springframework.beans.factory.config.CustomEditorConfigurer">
  <property name="customEditors">
   <map>
    <entry key="java.net.SocketAddress">
     <bean
      class="org.apache.mina.integration.beans.InetSocketAddressEditor" />
    </entry>
   </map>
  </property>
 </bean>

 <bean ));
     }
     public MyCodeFactory(Charset charset) {
       encoder = new TextLineEncoder(charset, LineDelimiter.UNIX);  
          decoder = new TextLineDecoder(charset, LineDelimiter.AUTO);  
          }

     @Override
  public ProtocolDecoder getDecoder(IoSession session) throws Exception {
   // TODO Auto-generated method stub
   return decoder;
  }
  @Override
  public ProtocolEncoder getEncoder(IoSession session) throws Exception {
   // TODO Auto-generated method stub
   return encoder;
  }
  public int getEncoderMaxLineLength() {
         return encoder.getMaxLineLength();
     }
     public void setEncoderMaxLineLength(int maxLineLength) {
         encoder.setMaxLineLength(maxLineLength);
     }
     public int getDecoderMaxLineLength() {
         return decoder.getMaxLineLength();
     }
     public void setDecoderMaxLineLength(int maxLineLength) {
         decoder.setMaxLineLength(maxLineLength);
     }

}

 

这样简单的例子就OK了

 /Files/coolattt/MinaSpring.rar

 

 

 

相关文章:

  • 2022-12-23
  • 2021-11-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2021-10-21
  • 2022-12-23
猜你喜欢
  • 2021-04-20
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-05
相关资源
相似解决方案