| | |
| | | |
| | | public class PrefixedDataAvailableHandleImp implements PrefixedDataAvailableHandle { |
| | | |
| | | private static Logger log = LogManager.getLogger(PrefixedDataAvailableHandleImp.class) ; |
| | | private static final Logger log = LogManager.getLogger(PrefixedDataAvailableHandleImp.class) ; |
| | | |
| | | |
| | | /** |
| | | * 在多线程环境中运行 |
| | | * 分析上线数据(网络连接后第一包数据)是否可获得 |
| | | * @param in |
| | | * @return |
| | | * @throws Exception |
| | | * @param in IoBuffer |
| | | * @return PrefixedDataAvailableStatus |
| | | */ |
| | | public PrefixedDataAvailableStatus forOnLine(IoBuffer in){ |
| | | int remain = in.remaining() ; |
| | |
| | | try{ |
| | | PrefixedDataAvailableStatus pds = null ; |
| | | |
| | | HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCach.getPrefixedDataAvailableMap() ; |
| | | HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCache.getPrefixedDataAvailableMap() ; |
| | | Collection<AnnotationPrefixedDataAvailableVo> set = prefixedDataAvailableMap.values() ; |
| | | if(set == null || set.size() == 0){ |
| | | if(set.size() == 0){ |
| | | throw new Exception("上线数据完整性检查时,得到的协议完整性检查类集合为空。") ; |
| | | } |
| | | int prority = ProtocolConstant.firstPriority ; |
| | | int priority = ProtocolConstant.firstPriority ; |
| | | |
| | | while(true){ |
| | | Object[] objs = this.getClassObjAndAnnotationVo(prority, set) ; |
| | | Object[] objs = this.getClassObjAndAnnotationVo(priority, set) ; |
| | | PrefixedDataAvailable pda = (PrefixedDataAvailable)objs[0] ; |
| | | if(pda == null && prority == ProtocolConstant.firstPriority){ |
| | | throw new Exception("上线数据完整性检查时,未得到优先级为" + prority + "上线数据完整性检查类!") ; |
| | | if(pda == null && priority == ProtocolConstant.firstPriority){ |
| | | throw new Exception("上线数据完整性检查时,未得到优先级为" + priority + "上线数据完整性检查类!") ; |
| | | }else if(pda == null){ |
| | | //说明上线数据完整性检查类集合已经遍历完了。 |
| | | break ; |
| | |
| | | if(pds == null){ |
| | | //说明不是对应的协议数据,需要另外的协议来处理上线 |
| | | //循环继续 |
| | | prority++ ; |
| | | priority++ ; |
| | | }else{ |
| | | //停止循环,返回结果 |
| | | break ; |
| | |
| | | /** |
| | | * 在多线程环境中运行 |
| | | * 分析上行数据(网络连接后第二(包含)包以后数据)是否可获得 |
| | | * @param in |
| | | * @param clientProtocol |
| | | * @param maxDataLength |
| | | * @return |
| | | * @throws Exception |
| | | * @param in IoBuffer |
| | | * @return PrefixedDataAvailableStatus |
| | | */ |
| | | public PrefixedDataAvailableStatus forUpData(IoBuffer in){ |
| | | int remain = in.remaining() ; |
| | |
| | | try{ |
| | | PrefixedDataAvailableStatus pds = null ; |
| | | |
| | | HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCach.getPrefixedDataAvailableMap() ; |
| | | HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCache.getPrefixedDataAvailableMap() ; |
| | | Collection<AnnotationPrefixedDataAvailableVo> set = prefixedDataAvailableMap.values() ; |
| | | if(set == null || set.size() == 0){ |
| | | if(set.size() == 0){ |
| | | throw new Exception("上线数据完整性检查时,得到的协议集合为空。") ; |
| | | } |
| | | int prority = ProtocolConstant.firstPriority ; |
| | |
| | | |
| | | /** |
| | | * 得到处理类对象 |
| | | * @param prority |
| | | * @param set |
| | | * @return |
| | | * @throws Exception |
| | | * @param prority 优先级 |
| | | * @param set 集合 |
| | | * @return Object[] |
| | | * @throws Exception 异常 |
| | | */ |
| | | private Object[] getClassObjAndAnnotationVo(int prority, Collection<AnnotationPrefixedDataAvailableVo> set) throws Exception{ |
| | | PrefixedDataAvailable obj = null ; |