MCPcopy Create free account
hub / github.com/e2wugui/zeze / retreat

Method retreat

ZezeJava/ZezeJava/src/main/java/Zeze/Hot/HotManager.java:194–220  ·  view source on GitHub ↗
(ArrayList<HotModule> removes, ArrayList<HotModule> currents, Bean bean)

Source from the content-addressed store, hash-verified

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

Callers 1

installMethod · 0.95

Calls 10

isHotModuleMethod · 0.95
AllocateMethod · 0.95
getClassLoaderMethod · 0.80
sizeMethod · 0.65
getMethod · 0.65
getNameMethod · 0.65
encodeMethod · 0.65
decodeMethod · 0.65
indexOfMethod · 0.45
loadClassMethod · 0.45

Tested by

no test coverage detected