use of com.alipay.sofa.ark.spi.service.biz.BizManagerService in project sofa-ark by alipay.
the class BaseTest method registerMockBiz.
protected void registerMockBiz() {
if (arkContainer == null) {
String[] args = new String[] { "-Ajar=" + jarURL.toExternalForm() };
arkContainer = (ArkContainer) ArkContainer.main(args);
}
BizManagerService bizManagerService = ArkServiceContainerHolder.getContainer().getService(BizManagerService.class);
Biz biz = new BizModel().setBizName("mock").setBizVersion("1.0").setClassLoader(this.getClass().getClassLoader()).setDenyImportPackages("").setDenyImportClasses("").setDenyImportResources("").setBizState(BizState.RESOLVED);
bizManagerService.registerBiz(biz);
((BizModel) biz).setBizState(BizState.ACTIVATED);
}
use of com.alipay.sofa.ark.spi.service.biz.BizManagerService in project sofa-ark by alipay.
the class TestClassLoader method createTestBiz.
private Biz createTestBiz(String bizIdentity) {
String[] bizNameAndVersion = bizIdentity.split(":");
if (bizNameAndVersion.length != 2) {
throw new ArkRuntimeException("error bizIdentity format.");
}
BizManagerService bizManagerService = ArkServiceContainerHolder.getContainer().getService(BizManagerService.class);
Biz testBiz = new BizModel().setBizName(bizNameAndVersion[0]).setBizVersion(bizNameAndVersion[1]).setClassLoader(this).setDenyImportPackages("").setDenyImportClasses("").setDenyImportResources("").setBizState(BizState.RESOLVED);
bizManagerService.registerBiz(testBiz);
return testBiz;
}
use of com.alipay.sofa.ark.spi.service.biz.BizManagerService 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