Search in sources :

Example 1 with AbstractClasspathClassLoader

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));
    }
}
Also used : BeforeBizRecycleEvent(com.alipay.sofa.ark.spi.event.biz.BeforeBizRecycleEvent) EventAdminService(com.alipay.sofa.ark.spi.service.event.EventAdminService) AbstractClasspathClassLoader(com.alipay.sofa.ark.container.service.classloader.AbstractClasspathClassLoader) BeforeBizStopEvent(com.alipay.sofa.ark.spi.event.biz.BeforeBizStopEvent) AfterBizStopEvent(com.alipay.sofa.ark.spi.event.biz.AfterBizStopEvent) BizManagerService(com.alipay.sofa.ark.spi.service.biz.BizManagerService) AbstractClasspathClassLoader(com.alipay.sofa.ark.container.service.classloader.AbstractClasspathClassLoader)

Aggregations

AbstractClasspathClassLoader (com.alipay.sofa.ark.container.service.classloader.AbstractClasspathClassLoader)1 AfterBizStopEvent (com.alipay.sofa.ark.spi.event.biz.AfterBizStopEvent)1 BeforeBizRecycleEvent (com.alipay.sofa.ark.spi.event.biz.BeforeBizRecycleEvent)1 BeforeBizStopEvent (com.alipay.sofa.ark.spi.event.biz.BeforeBizStopEvent)1 BizManagerService (com.alipay.sofa.ark.spi.service.biz.BizManagerService)1 EventAdminService (com.alipay.sofa.ark.spi.service.event.EventAdminService)1