use of com.alipay.sofa.ark.container.service.classloader.AbstractClasspathClassLoader in project sofa-ark by alipay.
the class BizModel method stop.
@Override
public void stop() {
AssertUtils.isTrue(bizState == BizState.ACTIVATED || bizState == BizState.DEACTIVATED || bizState == BizState.BROKEN, "BizState must be ACTIVATED, DEACTIVATED or BROKEN.");
if (isMasterBizAndEmbedEnable()) {
// skip stop when embed mode
return;
}
ClassLoader oldClassLoader = ClassLoaderUtils.pushContextClassLoader(this.classLoader);
bizState = BizState.DEACTIVATED;
EventAdminService eventAdminService = ArkServiceContainerHolder.getContainer().getService(EventAdminService.class);
try {
// this can trigger uninstall handler
eventAdminService.sendEvent(new BeforeBizStopEvent(this));
} finally {
BizManagerService bizManagerService = ArkServiceContainerHolder.getContainer().getService(BizManagerService.class);
bizManagerService.unRegisterBiz(bizName, bizVersion);
bizState = BizState.UNRESOLVED;
eventAdminService.sendEvent(new BeforeBizRecycleEvent(this));
urls = null;
denyImportPackages = null;
denyImportClasses = null;
denyImportResources = null;
if (bizTempWorkDir != null && bizTempWorkDir.exists()) {
bizTempWorkDir.delete();
}
bizTempWorkDir = null;
if (classLoader instanceof AbstractClasspathClassLoader) {
((AbstractClasspathClassLoader) classLoader).clearCache();
}
classLoader = null;
ClassLoaderUtils.popContextClassLoader(oldClassLoader);
eventAdminService.sendEvent(new AfterBizStopEvent(this));
}
}
Aggregations