mina 使用手记 4

将Apollo高精地图中的车道线叠加在多种导航地图上 本文介绍了将Apollo高精地图车道线叠加到普通导航地图的技术方案。高精地图具备厘米级车道精度和丰富的语义信息,叠加可实现可视化验证、调试分析和数据对比等功能。核心技术包括坐标系统转换(UTM/WGS84/BD09/GCJ02)和数据处理流程,通过Python脚本完成Apollo地图解析、坐标批量转换和多格式输出。文章详细提供了环境准备、工作目录创建和坐标转换脚本等操作步骤,实现了高精地图数据在OpenStreetMap、百度地图和高德地图上的可视化展示。 阅读详情

原创   Apache Mina使用手记(四) 收藏

上一篇中,我们介绍了如何在mina中编写自己的日志过滤器,这一篇我们自己实现一个编解器。

实际应用当,很多应用系统应用的都不是标准的web service或XML等,比如象中国移动/联通/电信的短信网关程序,都有自己不同的协议实现,并且都是基于TCP/IP的字节流。Mina自带的编解 码器实现了TextLineEncoder和TextLineDecoder,可以进行按行的字符串处理,对于象短信网关程序,就要自己实现编解码过滤器 了。

我们定义一个简单的基于TCP/IP字节流的协议,实现在客户端和服务端之间的数据包传输。数据包MyProtocalPack有消息头和消息体组 成,消息头包括:length(消息包的总长度,数据类型int),flag(消息包标志位,数据类型byte),消息体content是一个字符串,实 际实现的时候按byte流处理。源代码如下:

  1. package  com.gftech.mytool.mina;  
  2. import  com.gftech.util.GFCommon;  
  3. public   class  MyProtocalPack {  
  4.     private   int  length;  
  5.     private   byte  flag;  
  6.     private  String content;  
  7.       
  8.     public  MyProtocalPack(){  
  9.           
  10.     }  
  11.       
  12.     public  MyProtocalPack( byte  flag,String content){  
  13.         this .flag=flag;  
  14.         this .content=content;  
  15.         int  len1=content== null ? 0 :content.getBytes().length;  
  16.         this .length= 5 +len1;  
  17.     }  
  18.       
  19.     public  MyProtocalPack( byte [] bs){  
  20.         if (bs!= null  && bs.length>= 5 ){  
  21.             length=GFCommon.bytes2int(GFCommon.bytesCopy(bs, 0 ,  4 ));  
  22.             flag=bs[4 ];  
  23.             content=new  String(GFCommon.bytesCopy(bs,  5 , length- 5 ));  
  24.         }  
  25.     }  
  26.       
  27.     public   int  getLength() {  
  28.         return  length;  
  29.     }  
  30.     public   void  setLength( int  length) {  
  31.         this .length = length;  
  32.     }  
  33.     public   byte  getFlag() {  
  34.         return  flag;  
  35.     }  
  36.     public   void  setFlag( byte  flag) {  
  37.         this .flag = flag;  
  38.     }  
  39.     public  String getContent() {  
  40.         return  content;  
  41.     }  
  42.     public   void  setContent(String content) {  
  43.         this .content = content;  
  44.     }  
  45.       
  46.     public  String toString(){  
  47.         StringBuffer sb=new  StringBuffer();  
  48.         sb.append(" Len:" ).append(length);  
  49.         sb.append(" flag:" ).append(flag);  
  50.         sb.append(" content:" ).append(content);  
  51.         return  sb.toString();  
  52.     }  
  53. }  

回过头来,我们先看一下在MinaTimeServer中,如何使用一个文本的编解码过滤器,它是在过滤器链中添加了一个叫ProtocalCodecFilter的类,其中它调用 了一个工厂方法TextLineCodecFactory的工厂类,创建具休的TextLineEncoder和TextLineDecoder编码和解 码器。我们看一下具体的源代码:

  1. acceptor.getFilterChain().addLast( "codec" ,  new  ProtocolCodecFilter( new  TextLineCodecFactory(Charset.forName( "GBK" ))));  

  1. package  org.apache.mina.filter.codec.textline;  
  2. import  java.nio.charset.Charset;  
  3. import  org.apache.mina.core.buffer.BufferDataException;  
  4. import  org.apache.mina.core.session.IoSession;  
  5. import  org.apache.mina.filter.codec.ProtocolCodecFactory;  
  6. import  org.apache.mina.filter.codec.ProtocolDecoder;  
  7. import  org.apache.mina.filter.codec.ProtocolEncoder;  
  8. /**  
  9.  * A {@link ProtocolCodecFactory} that performs encoding and decoding between  
  10.  * a text line data and a Java string object.  This codec is useful especially  
  11.  * when you work with a text-based protocols such as SMTP and IMAP.  
  12.  *  
  13.  * @author The Apache MINA Project (dev@mina.apache.org)  
  14.  * @version $Rev$, $Date$  
  15.  */   
  16. public   class  TextLineCodecFactory  implements  ProtocolCodecFactory {  
  17.     private   final  TextLineEncoder encoder;  
  18.     private   final  TextLineDecoder decoder;  
  19.     /**  
  20.      * Creates a new instance with the current default {@link Charset}.  
  21.      */   
  22.     public  TextLineCodecFactory() {  
  23.         this (Charset.defaultCharset());  
  24.     }  
  25.     /**  
  26.      * Creates a new instance with the specified {@link Charset}.  The  
  27.      * encoder uses a UNIX {@link LineDelimiter} and the decoder uses  
  28.      * the AUTO {@link LineDelimiter}.  
  29.      *  
  30.      * @param charset  
  31.      *  The charset to use in the encoding and decoding  
  32.      */   
  33.     public  TextLineCodecFactory(Charset charset) {  
  34.         encoder = new  TextLineEncoder(charset, LineDelimiter.UNIX);  
  35.         decoder = new  TextLineDecoder(charset, LineDelimiter.AUTO);  
  36.     }  
  37.     /**  
  38.      * Creates a new instance of TextLineCodecFactory.  This constructor  
  39.      * provides more flexibility for the developer.  
  40.      *  
  41.      * @param charset  
  42.      *  The charset to use in the encoding and decoding  
  43.      * @param encodingDelimiter  
  44.      *  The line delimeter for the encoder  
  45.      * @param decodingDelimiter  
  46.      *  The line delimeter for the decoder  
  47.      */   
  48.     public  TextLineCodecFactory(Charset charset,  
  49.             String encodingDelimiter, String decodingDelimiter) {  
  50.         encoder = new  TextLineEncoder(charset, encodingDelimiter);  
  51.         decoder = new  TextLineDecoder(charset, decodingDelimiter);  
  52.     }  
  53.     /**  
  54.      * Creates a new instance of TextLineCodecFactory.  This constructor  
  55.      * provides more flexibility for the developer.  
  56.      *  
  57.      * @param charset  
  58.      *  The charset to use in the encoding and decoding  
  59.      * @param encodingDelimiter  
  60.      *  The line delimeter for the encoder  
  61.      * @param decodingDelimiter  
  62.      *  The line delimeter for the decoder  
  63.      */   
  64.     public  TextLineCodecFactory(Charset charset,  
  65.             LineDelimiter encodingDelimiter, LineDelimiter decodingDelimiter) {  
  66.         encoder = new  TextLineEncoder(charset, encodingDelimiter);  
  67.         decoder = new  TextLineDecoder(charset, decodingDelimiter);  
  68.     }  
  69.     public  ProtocolEncoder getEncoder(IoSession session) {  
  70.         return  encoder;  
  71.     }  
  72.     public  ProtocolDecoder getDecoder(IoSession session) {  
  73.         return  decoder;  
  74.     }  
  75.        /**  
  76.      * Returns the allowed maximum size of the encoded line.  
  77.      * If the size of the encoded line exceeds this value, the encoder  
  78.      * will throw a {@link IllegalArgumentException}.  The default value  
  79.      * is {@link Integer#MAX_VALUE}.  
  80.      * <p>  
  81.      * This method does the same job with {@link TextLineEncoder#getMaxLineLength()}.  
  82.      */   
  83.     public   int  getEncoderMaxLineLength() {  
  84.         return  encoder.getMaxLineLength();  
  85.     }  
  86.     /**  
  87.      * Sets the allowed maximum size of the encoded line.  
  88.      * If the size of the encoded line exceeds this value, the encoder  
  89.      * will throw a {@link IllegalArgumentException}.  The default value  
  90.      * is {@link Integer#MAX_VALUE}.  
  91.      * <p>  
  92.      * This method does the same job with {@link TextLineEncoder#setMaxLineLength(int)}.  
  93.      */   
  94.     public   void  setEncoderMaxLineLength( int  maxLineLength) {  
  95.         encoder.setMaxLineLength(maxLineLength);  
  96.     }  
  97.     /**  
  98.      * Returns the allowed maximum size of the line to be decoded.  
  99.      * If the size of the line to be decoded exceeds this value, the  
  100.      * decoder will throw a {@link BufferDataException}.  The default  
  101.      * value is <tt>1024</tt> (1KB).  
  102.      * <p>  
  103.      * This method does the same job with {@link TextLineDecoder#getMaxLineLength()}.  
  104.      */   
  105.     public   int  getDecoderMaxLineLength() {  
  106.         return  decoder.getMaxLineLength();  
  107.     }  
  108.     /**  
  109.      * Sets the allowed maximum size of the line to be decoded.  
  110.      * If the size of the line to be decoded exceeds this value, the  
  111.      * decoder will throw a {@link BufferDataException}.  The default  
  112.      * value is <tt>1024</tt> (1KB).  
  113.      * <p>  
  114.      * This method does the same job with {@link TextLineDecoder#setMaxLineLength(int)}.  
  115.      */   
  116.     public   void  setDecoderMaxLineLength( int  maxLineLength) {  
  117.         decoder.setMaxLineLength(maxLineLength);  
  118.     }  
  119. }  

TextLineFactory实现了ProtocalCodecFactory接口,该接口主要有一个编码的方法getEncoder()和一个解码的方法getDecoder():

  1. package  org.apache.mina.filter.codec;  
  2. import  org.apache.mina.core.session.IoSession;  
  3. /**  
  4.  * Provides {@link ProtocolEncoder} and {@link ProtocolDecoder} which translates  
  5.  * binary or protocol specific data into message object and vice versa.  
  6.  * <p>  
  7.  * Please refer to  
  8.  * <a href="../../../../../xref-examples/org/apache/mina/examples/reverser/ReverseProtocolProvider.html" mce_href="xref-examples/org/apache/mina/examples/reverser/ReverseProtocolProvider.html"><code>ReverserProtocolProvider</code></a>  
  9.  * example.  
  10.  *  
  11.  * @author The Apache MINA Project (dev@mina.apache.org)  
  12.  * @version $Rev$, $Date$  
  13.  */   
  14. public   interface  ProtocolCodecFactory {  
  15.     /**  
  16.      * Returns a new (or reusable) instance of {@link ProtocolEncoder} which  
  17.      * encodes message objects into binary or protocol-specific data.  
  18.      */   
  19.     ProtocolEncoder getEncoder(IoSession session) throws  Exception;  
  20.     /**  
  21.      * Returns a new (or reusable) instance of {@link ProtocolDecoder} which  
  22.      * decodes binary or protocol-specific data into message objects.  
  23.      */   
  24.     ProtocolDecoder getDecoder(IoSession session) throws  Exception;  
  25. }  

我们主要是仿照TextLineEncoder实现其中的encode()方法,仿照TextLineDecoder实现其中的decode()即 可,它们分别实现了ProtocalEncoder和ProtocalDecoder接口。我们要编写三个类分别 是:MyProtocalCodecFactory,MyProtocalEncoder,MyProtocalDecoder对应 TextLineCodecFactory,TextLineEncoder,TextLineDecoder。

  1. package  com.gftech.mytool.mina;  
  2. import  java.nio.charset.Charset;  
  3. import  org.apache.mina.core.session.IoSession;  
  4. import  org.apache.mina.filter.codec.ProtocolCodecFactory;  
  5. import  org.apache.mina.filter.codec.ProtocolDecoder;  
  6. import  org.apache.mina.filter.codec.ProtocolEncoder;  
  7. public   class  MyProtocalCodecFactory    implements  ProtocolCodecFactory {  
  8.         private   final  MyProtocalEncoder encoder;  
  9.         private   final  MyProtocalDecoder decoder;  
  10.           
  11.         public  MyProtocalCodecFactory(Charset charset) {  
  12.             encoder=new  MyProtocalEncoder(charset);  
  13.             decoder=new  MyProtocalDecoder(charset);  
  14.         }  
  15.            
  16.         public  ProtocolEncoder getEncoder(IoSession session) {  
  17.             return  encoder;  
  18.         }  
  19.         public  ProtocolDecoder getDecoder(IoSession session) {  
  20.             return  decoder;  
  21.         }  
  22.           
  23. }  

  1. package  com.gftech.mytool.mina;  
  2. import  java.nio.charset.Charset;  
  3. import  org.apache.mina.core.buffer.IoBuffer;  
  4. import  org.apache.mina.core.session.IoSession;  
  5. import  org.apache.mina.filter.codec.ProtocolEncoderAdapter;  
  6. import  org.apache.mina.filter.codec.ProtocolEncoderOutput;  
  7. public   class  MyProtocalEncoder  extends  ProtocolEncoderAdapter {  
  8.     private   final  Charset charset;  
  9.     public  MyProtocalEncoder(Charset charset) {  
  10.         this .charset = charset;  
  11.     }  
  12.     //在此处实现对MyProtocalPack包的编码工作,并把它写入输出流中   
  13.     public   void  encode(IoSession session, Object message, ProtocolEncoderOutput out)  throws  Exception {  
  14.         MyProtocalPack value = (MyProtocalPack) message;  
  15.         IoBuffer buf = IoBuffer.allocate(value.getLength());  
  16.         buf.setAutoExpand(true );  
  17.         buf.putInt(value.getLength());  
  18.         buf.put(value.getFlag());  
  19.         if  (value.getContent() !=  null )  
  20.             buf.put(value.getContent().getBytes());  
  21.         buf.flip();  
  22.         out.write(buf);  
  23.     }  
  24.     public   void  dispose()  throws  Exception {  
  25.     }  
  26. }  

  1. package  com.gftech.mytool.mina;  
  2. import  java.nio.charset.Charset;  
  3. import  java.nio.charset.CharsetDecoder;  
  4. import  org.apache.mina.core.buffer.IoBuffer;  
  5. import  org.apache.mina.core.session.AttributeKey;  
  6. import  org.apache.mina.core.session.IoSession;  
  7. import  org.apache.mina.filter.codec.ProtocolDecoder;  
  8. import  org.apache.mina.filter.codec.ProtocolDecoderOutput;  
  9. public   class  MyProtocalDecoder  implements  ProtocolDecoder {  
  10.     private   final  AttributeKey CONTEXT =  new  AttributeKey(getClass(),  "context" );  
  11.     private   final  Charset charset;  
  12.     private   int  maxPackLength =  100 ;  
  13.     public  MyProtocalDecoder() {  
  14.         this (Charset.defaultCharset());  
  15.     }  
  16.     public  MyProtocalDecoder(Charset charset) {  
  17.         this .charset = charset;  
  18.     }  
  19.     public   int  getMaxLineLength() {  
  20.         return  maxPackLength;  
  21.     }  
  22.     public   void  setMaxLineLength( int  maxLineLength) {  
  23.         if  (maxLineLength <=  0 ) {  
  24.             throw   new  IllegalArgumentException( "maxLineLength: "  + maxLineLength);  
  25.         }  
  26.         this .maxPackLength = maxLineLength;  
  27.     }  
  28.     private  Context getContext(IoSession session) {  
  29.         Context ctx;  
  30.         ctx = (Context) session.getAttribute(CONTEXT);  
  31.         if  (ctx ==  null ) {  
  32.             ctx = new  Context();  
  33.             session.setAttribute(CONTEXT, ctx);   
  34.         }   
  35.         return  ctx;  
  36.     }  
  37.     public   void  decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out)  throws  Exception {  
  38.         final   int  packHeadLength =  5 ;  
  39.         //先获取上次的处理上下文,其中可能有未处理完的数据   
  40.         Context ctx = getContext(session);  
  41.         // 先把当前buffer中的数据追加到Context的buffer当中    
  42.         ctx.append(in);   
  43.         //把position指向0位置,把limit指向原来的position位置   
  44.         IoBuffer buf = ctx.getBuffer();  
  45.         buf.flip();   
  46.         // 然后按数据包的协议进行读取   
  47.         while  (buf.remaining() >= packHeadLength) {  
  48.             buf.mark();  
  49.             // 读取消息头部分   
  50.             int  length = buf.getInt();  
  51.             byte  flag = buf.get();  
  52.             //检查读取的包头是否正常,不正常的话清空buffer   
  53.             if  (length< 0  ||length > maxPackLength) {  
  54.                 buf.clear();   
  55.                 break ;  
  56.             }   
  57.             //读取正常的消息包,并写入输出流中,以便IoHandler进行处理   
  58.             else   if  (length >= packHeadLength && length - packHeadLength <= buf.remaining()) {  
  59.                 int  oldLimit2 = buf.limit();  
  60.                 buf.limit(buf.position() + length - packHeadLength);  
  61.                 String content = buf.getString(ctx.getDecoder());  
  62.                 buf.limit(oldLimit2);  
  63.                 MyProtocalPack pack = new  MyProtocalPack(flag, content);  
  64.                 out.write(pack);  
  65.             } else  {  
  66.                 // 如果消息包不完整   
  67.                 // 将指针重新移动消息头的起始位置    
  68.                 buf.reset();   
  69.                 break ;  
  70.             }  
  71.         }  
  72.         if  (buf.hasRemaining()) {  
  73.             // 将数据移到buffer的最前面    
  74.                 IoBuffer temp = IoBuffer.allocate(maxPackLength).setAutoExpand(true );  
  75.                 temp.put(buf);  
  76.                 temp.flip();  
  77.                 buf.clear();  
  78.                 buf.put(temp);  
  79.                    
  80.         } else  { // 如果数据已经处理完毕,进行清空   
  81.             buf.clear();   
  82.         }  
  83.           
  84.           
  85.     }  
  86.     public   void  finishDecode(IoSession session, ProtocolDecoderOutput out)  throws  Exception {  
  87.     }  
  88.     public   void  dispose(IoSession session)  throws  Exception {   
  89.         Context ctx = (Context) session.getAttribute(CONTEXT);  
  90.         if  (ctx !=  null ) {  
  91.             session.removeAttribute(CONTEXT);  
  92.         }  
  93.     }  
  94.     //记录上下文,因为数据触发没有规模,很可能只收到数据包的一半   
  95.     //所以,需要上下文拼起来才能完整的处理   
  96.     private   class  Context {  
  97.         private   final  CharsetDecoder decoder;  
  98.         private  IoBuffer buf;  
  99.         private   int  matchCount =  0 ;  
  100.         private   int  overflowPosition =  0 ;  
  101.         private  Context() {  
  102.             decoder = charset.newDecoder();  
  103.             buf = IoBuffer.allocate(80 ).setAutoExpand( true );  
  104.         }  
  105.         public  CharsetDecoder getDecoder() {  
  106.             return  decoder;  
  107.         }  
  108.         public  IoBuffer getBuffer() {  
  109.             return  buf;  
  110.         }  
  111.         public   int  getOverflowPosition() {  
  112.             return  overflowPosition;  
  113.         }  
  114.         public   int  getMatchCount() {  
  115.             return  matchCount;  
  116.         }  
  117.         public   void  setMatchCount( int  matchCount) {  
  118.             this .matchCount = matchCount;  
  119.         }  
  120.         public   void  reset() {  
  121.             overflowPosition = 0 ;  
  122.             matchCount = 0 ;  
  123.             decoder.reset();  
  124.         }  
  125.         public   void  append(IoBuffer in) {   
  126.             getBuffer().put(in);  
  127.             
  128.         }  
  129.    
  130.     }  
  131. }  

在MyProtocalServer中,添加自己实现的Log4jFilter和编解码过滤器:

  1. package  com.gftech.mytool.mina;  
  2. import  java.io.IOException;  
  3. import  java.net.InetSocketAddress;  
  4. import  java.nio.charset.Charset;  
  5. import  org.apache.log4j.Logger;  
  6. import  org.apache.log4j.PropertyConfigurator;  
  7. import  org.apache.mina.core.service.IoAcceptor;  
  8. import  org.apache.mina.core.service.IoHandlerAdapter;  
  9. import  org.apache.mina.core.session.IdleStatus;  
  10. import  org.apache.mina.core.session.IoSession;  
  11. import  org.apache.mina.filter.codec.ProtocolCodecFilter;  
  12. import  org.apache.mina.transport.socket.nio.NioSocketAcceptor;  
  13. public   class  MyProtocalServer {  
  14.     private   static   final   int  PORT =  2500 ;  
  15.     static  Logger logger = Logger.getLogger(MyProtocalServer. class );  
  16.     public   static   void  main(String[] args)  throws  IOException {  
  17.         PropertyConfigurator.configure("conf//log4j.properties" );  
  18.         IoAcceptor acceptor = new  NioSocketAcceptor();  
  19.         Log4jFilter lf = new  Log4jFilter(logger);  
  20.         acceptor.getFilterChain().addLast("logger" , lf);  
  21.       
  22.         acceptor.getFilterChain().addLast("codec" ,  new  ProtocolCodecFilter( new  MyProtocalCodecFactory(Charset.forName( "GBK" ))));  
  23.         acceptor.getSessionConfig().setReadBufferSize(1024 );  
  24.         acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 10 );  
  25.         acceptor.setHandler(new  MyHandler());  
  26.         acceptor.bind(new  InetSocketAddress(PORT));  
  27.         System.out.println("start server ..." );  
  28.     }  
  29. }  
  30. class  MyHandler  extends  IoHandlerAdapter {  
  31.     static  Logger logger = Logger.getLogger(MyHandler. class );  
  32.     @Override   
  33.     public   void  exceptionCaught(IoSession session, Throwable cause)  throws  Exception {  
  34.         cause.printStackTrace();  
  35.     }  
  36.     @Override   
  37.     public   void  messageReceived(IoSession session, Object message)  throws  Exception {  
  38.         MyProtocalPack pack=(MyProtocalPack)message;  
  39.         logger.debug("Rec:"  + pack);  
  40.     }  
  41.     @Override   
  42.     public   void  sessionIdle(IoSession session, IdleStatus status)  throws  Exception {  
  43.         logger.debug("IDLE "  + session.getIdleCount(status));  
  44.     }  
  45. }  

编写一个客户端程序进行测试:

  1. package  com.gftech.mytool.mina;  
  2. import  java.io.DataOutputStream;  
  3. import  java.net.Socket;  
  4. public   class  MyProtocalClient {  
  5.       
  6.     public   static   void  main(String[] args) {  
  7.         try  {  
  8.             Socket socket = new  Socket( "127.0.0.1" ,  2500 );  
  9.             DataOutputStream out =  new  DataOutputStream( socket.getOutputStream() ) ;  
  10.             for  ( int  i =  0 ; i <  1000 ; i++) {  
  11.                 MyProtocalPack pack=new  MyProtocalPack(( byte )i,i+ "测试MyProtocalaaaaaaaaaaaaaa" );  
  12.                 out.writeInt(pack.getLength());  
  13.                 out.write(pack.getFlag());  
  14.                 out.write(pack.getContent().getBytes());  
  15.                 out.flush();  
  16.                 System.out.println(i + " sended" );  
  17.             }  
  18.             Thread.sleep(1000  );  
  19.         } catch  (Exception e) {  
  20.             e.printStackTrace();  
  21.         }  
  22.     }  
  23. }  

也可以用IoConnector实现自己的客户端:

在最新版eclipse中配置使用AI AIcoder _AIcoder配置GPUSTACK使用_配置OLLAMA本地AI模型利用_集合---AI场景应用工作笔记 本文介绍了三款实用的编程辅助工具:一款便捷的反编译插件,可直接在插件市场安装使用;GitHub Copilot提供每月2000次代码补全和50条聊天记录的免费额度,支持智能代码提示功能;aicoder支持配置本地模型运行。这些工具都能有效提升开发效率,其中GitHub Copilot的智能补全功能尤为突出。 阅读详情

相关推荐

华为数通---配置风暴控制案例

风暴控制可以通过阻塞报文或关闭端口来阻断广播、未知组播和未知单播报文的流量。

2301_77081516的博客 1624

android平台上使用MINA进行数据传输之异常汇总

mina,android,对象传输

杨成勇 1709

Protege新手必看:从安装到建模的完整指南(附推理功能详解)

本文为Protege新手提供从安装、配置到核心建模的完整实战指南。详细讲解了Java环境准备、本体项目创建、类与属性定义、个体填充等关键步骤,并重点解析了推理功能的配置与使用,帮助读者快速构建可逻辑推理的知识图谱,避开常见陷阱。

numpy6sculptor的博客 795

mina并发

package dev.stars.server; import java.io.IOException; import java.net.InetSocketAddress; import java.util.concurrent.Executors; import org.apache.mina.core.service.IoHandlerAdapter; import org.apac...

haogexiaole的博客 398

卸载重装Ubuntu22.04双系统

先说一下写此篇文章的背景吧,我在Windows下配置了三个cornerNet深度学习环境分别是cuda10.3(显卡版本太高不支持),cuda11.3(配置后偶然看到一篇说这个版本win下只能用CPU跑),最后是cuda11.1终究还是没能跑通代码,因为它的代码是在Liunx系统写的,就想着装个Ubuntu试试看,在网上看说一般软件不要装太高版本,我就下载了470版的显卡驱动,跟着步骤升级了系统内核,结果第二天开机Ubuntu就崩了,开机黑屏左上角只有一道横杠显示,只能按ctrl+shift+f5进入命令窗

编程小白的博客 8106

PaddleOCR实战:从零开始打造专属OCR模型的完整指南

本文提供了一份从零开始使用PaddleOCR打造专属OCR模型的完整实战指南。内容涵盖环境搭建、数据标注与准备、模型训练与调优,以及最终的模型转换与部署。重点介绍了如何利用PaddleOCR进行模型训练,并整合PPOCRLabel等工具高效准备数据集,帮助开发者快速构建适用于特定场景的高精度OCR识别能力。

rl6adventurer的博客 733

Mina断线重连时出现DeadLock,死锁解决方案

**Mina客户端断线重连,死锁异常DEAD LOCK: IoFuture.await() was invoked from an I/O processor thread. Please use IoFutureListener or configure a proper thread model alternatively. 解决!**

沐沐流年的博客 2897

微信小程序启用蓝牙设备特征值变化时的notify功能

注意:这里的serviceUUID、notifyCharacteristicUUID 我会在后面写入数据时做重点说明。isNotifyBLECharacteristic:false, //是否启用蓝牙设备服务特征 notify。二、启用蓝牙设备特征值变化时的notify功能。下一篇 将继续介绍 微信小程序蓝牙设备写入数据。

wsk198726的专栏 1172

MINA经典入门例子----Time Server

 貌似java的IO、NIO的入门例子都有相关的Time Server Demo。本例为MINA官方Demo翻译过来而已。  MINA百科:   Apache MINA(Multipurpose Infrastructure for Network Applications) 是 Apache 组织一个较新的项目,它为开发高性能和高可用性的网络应用程序提供了非常便     apache mina利的框架。当前发行的 MINA 版本支持基于 Java NIO 技术的 TCP/UDP 应用程序开发、串口通讯程序

kdiller的专栏 7123

第一节:从Chat_Bot 到 AI_Agent——一个范式转换

本文系统剖析了工业级AI代理系统ClaudeCode的设计原理与工程实践。通过对比ChatBot与Agent的三个本质差异:自主循环决策vs单轮应答、环境交互vs纯文本I/O、持久状态管理vs无状态对话,揭示了构建生产级Agent系统的关键挑战。文章详细解析了ClaudeCode的五层架构设计、1800+文件组成的运行时系统,包括工具调度、权限管理、状态持久化等核心机制,并阐述了从简单API调用到完整Agent系统的演进路径。

2201_75869398的博客 67

有之以为利,无之以为用,在 RAP 开发里的虚实取舍

摘要(149字) SAP RAP框架通过"有"与"无"的哲学平衡实现业务应用价值。其"有"体现在CDS视图、行为定义、服务绑定等具体对象,为系统提供形体;而"无"则表现为保留的扩展空间、未暴露的实现细节和框架托管的生命周期。在采购审批应用中,RAP既通过明确定义的行为模型建立业务语义,又通过验证、动作等机制保持灵活性。这种架构既确保核心功能稳固,又为未来演进留出余地,印证了"有之以为利,无之以为用"的技术智慧

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1302

TIMED_WAITING (on object monitor)分析

背景:采用mina和外部进行通信,在发送数据的方法上出现。 tracestack: "" prio=10 tid=0x00007f1c7c1e0000 nid=0x3e31 in Object.wait() [0x00007f1cb48bf000]    java.lang.Thread.State: TIMED_WAITING (on object monitor)     at jav

u013593306的专栏 1万+

NVIDIA Isaac GR00T N1.5 人形机器人强化学习入门教程(四)Lerobot、宇树 G1 等不同形态机器人微调教程

本笔记本是一份关于如何在新的数据集上对GR00T-N1预训练模型进行微调的教程。

2506_90492529的博客 1666

Apache Mina使用手记(四)

上一篇中,我们介绍了如何在mina中编写自己的日志过滤器,这一篇我们自己实现一个编解器。实际应用当,很多应用系统应用的都不是标准的web service或XML等,比如象中国移动/联通/电信的短信网关程序,都有自己不同的协议实现,并且都是基于TCP/IP的字节流。Mina自带的编解码器实现了TextLineEncoder和TextLineDecoder,可以进行按行的字符串处理,对于象短信网关

张新波的技术随笔 2万+

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

Apache Mina使用手记(三)

在上一篇中,通过一个简单的例子,得以管中窥豹,了解了Mina的基本编写方法。在MinaTimeServer演示程序中,我们添加了两个过滤器,一个是日志过滤器LoggingFilter,一个是文本编解码过滤器。前者实现日志信息的自动处理,后者实现对按行读写的文本数据的编码和解码。其中LoggingFilter默认的是slf4j,它是一个日志Facade,实际并不实现真正的日志处理功能,它在程序运

张新波的技术随笔 1万+

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Apache Mina使用手记(二)

 Mina主要是作为服务器端底层框架来实现数据处理,它的实现很简单,如下例所示:package com.gftech.mytool.mina;import java.io.IOException;import java.net.InetSocketAddress;import java.nio.charset.Charset;import java.util.Date;im

张新波的技术随笔 1万+

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Apache Mina使用手记(一)

1.Apache Mina是一个高性能的基础网络构架平台,构建在java NIO的基础上2.Mina使用了SLF4J做为日志记录器,全称Simple Logging Facade for Java,它是一个日志门面,只负责为客户端提供应用接口,实际的日志记录由Log4j/JUL等日志记录器实现。如下图所示: 3.Mina主要有IoConnector,IoAccepter,IoSes

张新波的技术随笔 1万+

Mina入门

自定义一个Mina的客户端,然后向上一节的Mina服务端发送数据。Mina客户端类:MinaClient.java/*** Mina客户端* * 用例:实现MinaServer的telnet程序**//*** IO会话连接器*//*** IO连接会话*//*** 与Mina服务端建立连接** @return 连接结果*/try {//1-NioSocketAcceptor( IO连接器)//2-设置超时时间。......

应无所住而生其心 1099

MINA框架概述

1.MINA框架简介MINA(Multipurpose Infrastructure for Network Applications)是用于开发高性能和高可用性的网络应用程序的基础框架。通过使用MINA框架可以可以省下处理底层I/O和线程并发等复杂工作,开发人员能够把更多的精力投入到业务设计和开发当中。MINA框架的应用比较广泛,应用的开源项目有Apache Directory、AsyncWeb

BraveHeart专栏 3999

MINA框架

基于MINA框架快速开发网络应用程序 1.MINA框架简介 MINA(Multipurpose Infrastructure for NetworkApplications)是用于开发高性能和高可用性的网络应用程序的基础框架。通过使用MINA框架可以可以省下处理底层I/O和线程并发等复杂工作,开发人员能够把更多的精力投入到业务设计和开发当中。MINA框架的应用比较广泛,应用

小毅的书屋 2757

Apache Mina

初步接触RPC通信框架,目前有很多优秀的RPC框架,今天我参考该博文:http://www.cnblogs.com/xuekyo/archive/2013/03/06/2945826.html 学习了Aapche Mina通信框架。博主介绍的非常详细,包括Mina的源码流程,这里通过阅读博主的文章进行了学习记录,方便以后需要时使用。 Apache Mina 是一个网络应用程序框架,用来帮助用户简

JY_He的博客 3437

Mina

1)MINA概念 一个简易用的基于TCP/IP通信的java框架 2)一个简单的网络程序需要的最少jar包 3)开发一个Mina应用过程 创建连接,设定过滤规则,编写自己的消息处理器 4)MINA实例 package com.vince...

zs1342084776的博客 658

MINA框架客户端的使用

在网络通信中,有时候需要保持长连接,一般的处理方式是使用socket,但是socket是阻塞式的,并且自己拼写socket的时候,步骤也挺繁杂,很容易出错。因此就想到了使用底层封装socket的框架---MINA框架。MINA框架的客户端是很好处理的,但是服务端网上大多是main函数来实现的。实际项目中,通常有很多需要tomcat来启动,因此就需要整合tomcat和MINA框架。本篇主要介绍MIN

小黄狗的博客 3380

java mina spring_Mina: SpringBoot 集成 MINA 项目

MINA一、概述​Apache MINA是一个网络通信应用框架,可帮助用户轻松开发高性能和高可扩展性的网络应用程序。 它通过Java NIO在各种传输(如TCP / IP和UDP / IP)上提供抽象的,事件驱动的异步API。MINA 不仅处理TCP和UDP,还通过VmpPipe或APR 在串行通信(RSC232)之上提供一层,现有支持的协议MINA附带了各种实现的协议:HTTP,XML,TCP,...

weixin_34315803的博客 605

java mina是干什么的_有关Mina基础技术知识介绍

一.MINA框架简介1.1Mina是什么东西?Apache MINA 是一个网络应用框架,有助于用户非常方便地开发高性能、高伸缩性的网络应用。它通过Java NIO提供了一个抽象的、事件驱动的、异步的位于各种传输协议(如TCP/IP和UDP/IP)之上的API,Apache MINA 通常可被称之为:l NIO 框架库;l 客户端/服务器框架库;l ...

weixin_33042659的博客 1001

MINA框架学习

转自:http://www.cnblogs.com/super-d2/archive/2013/02/18/2915495.html 一.MINA框架简介  MINA(Multipurpose Infrastructure for Network Applications)是用于开发高性能和高可用性的网络应用程序的基础框架。通过使用MINA框架可以可以省下处理底层I/O和线程并

yangyan19870319的专栏 1243
上一篇: mina 使用手记3
DocSun
博客等级 码龄18年 3粉丝 3原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值