| 192 | } |
| 193 | |
| 194 | private static Bean retreat(ArrayList<HotModule> removes, ArrayList<HotModule> currents, Bean bean) { |
| 195 | // 判断是否当前正在热更的模块创建的。 |
| 196 | try { |
| 197 | var cl = bean.getClass().getClassLoader(); |
| 198 | if (HotManager.isHotModule(cl)) { |
| 199 | var indexHot = removes.indexOf((HotModule)cl); |
| 200 | // removes 里面可能存在null。 |
| 201 | // indexOf找得到,currents里面就肯定有。但是安装可能部分失败。所以还是需要判断indexHot。 |
| 202 | if (indexHot >= 0 && indexHot < currents.size()) { |
| 203 | var current = currents.get(indexHot); |
| 204 | if (null != current) { |
| 205 | var curClass = current.loadClass(bean.getClass().getName()); |
| 206 | var curBean = (Bean)curClass.getConstructor((Class<?>[])null).newInstance((Object[])null); |
| 207 | var bb = ByteBuffer.Allocate(); |
| 208 | bean.encode(bb); |
| 209 | curBean.decode(bb); |
| 210 | // logger.info("<------ retreat ------> {} \r\n{} \r\n{}", |
| 211 | // bean.getClass().getName(), bean.variables(), curBean.variables()); |
| 212 | return curBean; |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } catch (Throwable ex) { |
| 217 | logger.error("retreat", ex); |
| 218 | } |
| 219 | return null; |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * Schemas Jar 命名规则:__hot_schemas__{SolutionName}.jar |