use of com.alipay.sofa.ark.spi.service.classloader.ClassLoaderHook in project sofa-ark by alipay.
the class BizClassLoader method loadBizClassLoaderHook.
private void loadBizClassLoaderHook() {
if (!skipLoadHook.get()) {
synchronized (lock) {
if (isHookLoaded.compareAndSet(false, true)) {
bizClassLoaderHook = ArkServiceLoader.loadExtensionFromArkBiz(ClassLoaderHook.class, BIZ_CLASS_LOADER_HOOK, bizIdentity);
Biz masterBiz = ArkClient.getMasterBiz();
if (bizClassLoaderHook == null && masterBiz != null && !masterBiz.getIdentity().equals(bizIdentity)) {
ClassLoader masterClassLoader = masterBiz.getBizClassLoader();
String defaultBizClassloaderHook = System.getProperty(BIZ_CLASS_LOADER_HOOK_DIR);
if (!StringUtils.isEmpty(defaultBizClassloaderHook)) {
try {
bizClassLoaderHook = (ClassLoaderHook<Biz>) masterClassLoader.loadClass(defaultBizClassloaderHook).newInstance();
} catch (Exception e) {
throw new RuntimeException(String.format("can not find master classloader hook: %s", defaultBizClassloaderHook), e);
}
}
}
skipLoadHook.set(true);
}
}
}
}
Aggregations