| | |
| | | * 在单线程环境中运行 |
| | | * 通过协议驱动的类名,得到类单例 |
| | | * @param protocolName 协议名称 |
| | | * @param protocolVersion 协议版本号 |
| | | * @return 驱动 |
| | | * @throws Exception 异常 |
| | | */ |
| | | public static Driver getDriver(String protocolName) throws Exception{ |
| | | Driver dri = drivers.get(protocolName); |
| | | public static Driver getDriver(String protocolName, short protocolVersion) throws Exception{ |
| | | Driver dri = drivers.get(protocolName + protocolVersion) ; |
| | | if(dri == null){ |
| | | AnnotationDriverVo vo = driverMap.get(protocolName) ; |
| | | AnnotationDriverVo vo = driverMap.get(protocolName + protocolVersion) ; |
| | | if(vo != null && vo.clazz != null){ |
| | | dri = (Driver)vo.clazz.getDeclaredConstructor().newInstance(); |
| | | //dri = (Driver)vo.clazz.newInstance() ; |
| | | drivers.put(protocolName, dri) ; |
| | | drivers.put(protocolName + protocolVersion, dri) ; |
| | | } |
| | | } |
| | | return dri ; |
| | | } |
| | | /** |
| | | * 在单线程环境中运行 |
| | | * 通过协议驱动的类名,得到类单例 |
| | | * @param protocolNameVersion 协议名称和版本号 |
| | | * @return 驱动 |
| | | * @throws Exception 异常 |
| | | */ |
| | | public static Driver getDriver(String protocolNameVersion) throws Exception{ |
| | | Driver dri = drivers.get(protocolNameVersion) ; |
| | | if(dri == null){ |
| | | AnnotationDriverVo vo = driverMap.get(protocolNameVersion) ; |
| | | if(vo != null && vo.clazz != null){ |
| | | dri = (Driver)vo.clazz.getDeclaredConstructor().newInstance(); |
| | | drivers.put(protocolNameVersion, dri) ; |
| | | } |
| | | } |
| | | return dri ; |
| | |
| | | return onLineMap; |
| | | } |
| | | |
| | | protected AnnotationDriverVo getAnnotationDriver(String protocolName, Short protocolVersion){ |
| | | return driverMap.get(protocolName + "" + protocolVersion) ; |
| | | } |
| | | |
| | | protected static AnnotationPrefixedDataAvailableVo getAnnotationPrefixedDataAvailable(String protocolName, Short protocolVersion){ |
| | | return prefixedDataAvailableMap.get(protocolName + "" + protocolVersion) ; |
| | | } |
| | | |
| | | protected static AnnotationOnLineVo getAnnotationOnLine(String protocolName, Short protocolVersion){ |
| | | return onLineMap.get(protocolName + "" + protocolVersion) ; |
| | | } |
| | | |
| | | /* |
| | | public static void main(String[] args){ |
| | | HashMap<String, Integer> mp = new HashMap<>() ; |