pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolCach.java
@@ -1,7 +1,6 @@
package com.dy.common.mw.protocol;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -9,26 +8,27 @@
public class ProtocolCach {
   
   //本系统中,Driver在单线程中运行,所以只用一个实例
   private static HashMap<String, Driver> drivers = new HashMap<String, Driver>() ;
   private static final HashMap<String, Driver> drivers = new HashMap<>() ;
    //注解与处理类的映射
   private static HashMap<String, AnnotationDriverVo> driverMap = new HashMap<String, AnnotationDriverVo>() ;
   private static HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = new HashMap<String, AnnotationPrefixedDataAvailableVo>() ;
   private static HashMap<String, AnnotationOnLineVo> onLineMap = new HashMap<String, AnnotationOnLineVo>() ;
   private static final HashMap<String, AnnotationDriverVo> driverMap = new HashMap<>() ;
   private static final HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = new HashMap<>() ;
   private static final HashMap<String, AnnotationOnLineVo> onLineMap = new HashMap<>() ;
   
   /**
    * 在单线程环境中运行
    * 通过协议驱动的类名,得到类单例
    * @param protocolName
    * @return
    * @throws Exception
    * @param protocolName 协议名称
    * @return 驱动
    * @throws Exception 异常
    */
   public static Driver getDriver(String protocolName) throws Exception{
      Driver dri = drivers.get(protocolName);
      if(dri == null){
         AnnotationDriverVo vo = driverMap.get(protocolName) ;
         if(vo != null && vo.clazz != null){
            dri = (Driver)vo.clazz.newInstance() ;
            dri = (Driver)vo.clazz.getDeclaredConstructor().newInstance();
            //dri = (Driver)vo.clazz.newInstance() ;
            drivers.put(protocolName, dri) ;
         }
      }
@@ -37,10 +37,10 @@
   
   /**
    * 得到驱动的数量,即中间件支持的协议数量
    * @return
    * @return 驱动总数
    */
   public static int driverCount(){
      if(drivers == null || drivers.size() == 0){
      if(drivers.size() == 0){
         return 0 ;
      }else{
         return drivers.size() ;
@@ -49,11 +49,11 @@
   
   /**
    * 得到第一个驱动
    * @return
    * @return 驱动
    */
   public static Driver getFirstDriver() throws Exception{
   public static Driver getFirstDriver(){
      Driver dri = null ;
      if(drivers != null && drivers.size() > 0){
      if(drivers.size() > 0){
         Map.Entry<String, Driver> ent = drivers.entrySet().iterator().next() ;
         dri = ent.getValue();
      }
@@ -62,15 +62,11 @@
   /**
    * 得到所有协议名称
    * @return
    * @return 协议名称集合
    */
   @SuppressWarnings("unused")
   public static List<String> getProtocolList() {
      List<String> list = new ArrayList<String>() ;
      Collection<String> col = driverMap.keySet() ;
      for(String pname : col){
         list.add(pname) ;
      }
      return list;
      return new ArrayList<>(driverMap.keySet()) ;
   }
   protected static HashMap<String, AnnotationDriverVo> getDriverMap() {
@@ -83,4 +79,11 @@
      return onLineMap;
   }
   public static void main(String[] args){
      HashMap<String, Integer> mp = new HashMap<>() ;
      mp.put("a1", 1) ;
      mp.put("a2", 2) ;
      List<String> list = new ArrayList<>(mp.keySet()) ;
      System.out.println(list);
   }
}