Search in sources :

Example 36 with Biz

use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.

the class ClassLoaderServiceImpl method isDeniedImportClass.

@Override
public boolean isDeniedImportClass(String bizIdentity, String className) {
    Biz biz = bizManagerService.getBizByIdentity(bizIdentity);
    if (biz == null) {
        return false;
    }
    for (String pattern : biz.getDenyImportClasses()) {
        if (pattern.equals(className)) {
            return true;
        }
    }
    String pkg = ClassUtils.getPackageName(className);
    for (String pattern : biz.getDenyImportPackageNodes()) {
        if (pkg.equals(pattern)) {
            return true;
        }
    }
    for (String pattern : biz.getDenyImportPackageStems()) {
        if (pkg.startsWith(pattern)) {
            return true;
        }
    }
    return false;
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz)

Example 37 with Biz

use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.

the class HandleArchiveStage method processEmbed.

protected void processEmbed(PipelineContext pipelineContext) throws Exception {
    ClassLoader masterBizClassLoader = pipelineContext.getClass().getClassLoader();
    Biz masterBiz = bizFactoryService.createEmbedMasterBiz(masterBizClassLoader);
    bizManagerService.registerBiz(masterBiz);
    ArkClient.setMasterBiz(masterBiz);
    ArkConfigs.putStringValue(Constants.MASTER_BIZ, masterBiz.getBizName());
    ExecutableArchive executableArchive = pipelineContext.getExecutableArchive();
    List<PluginArchive> pluginArchives = executableArchive.getPluginArchives();
    for (PluginArchive pluginArchive : pluginArchives) {
        Plugin plugin = pluginFactoryService.createEmbedPlugin(pluginArchive, masterBizClassLoader);
        if (!isPluginExcluded(plugin)) {
            pluginManagerService.registerPlugin(plugin);
        } else {
            LOGGER.warn(String.format("The plugin of %s is excluded.", plugin.getPluginName()));
        }
    }
    return;
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz) ExecutableArchive(com.alipay.sofa.ark.spi.archive.ExecutableArchive) PluginArchive(com.alipay.sofa.ark.spi.archive.PluginArchive) Plugin(com.alipay.sofa.ark.spi.model.Plugin)

Example 38 with Biz

use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.

the class ArkTomcatServletWebServerFactory method getContextPath.

@Override
public String getContextPath() {
    String contextPath = super.getContextPath();
    if (bizManagerService == null) {
        return contextPath;
    }
    Biz biz = bizManagerService.getBizByClassLoader(Thread.currentThread().getContextClassLoader());
    if (!StringUtils.isEmpty(contextPath)) {
        return contextPath;
    } else if (biz != null) {
        if (StringUtils.isEmpty(biz.getWebContextPath())) {
            return ROOT_WEB_CONTEXT_PATH;
        }
        return biz.getWebContextPath();
    } else {
        return ROOT_WEB_CONTEXT_PATH;
    }
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz)

Aggregations

Biz (com.alipay.sofa.ark.spi.model.Biz)38 Test (org.junit.Test)14 BaseTest (com.alipay.sofa.ark.container.BaseTest)13 BizModel (com.alipay.sofa.ark.container.model.BizModel)12 ArkRuntimeException (com.alipay.sofa.ark.exception.ArkRuntimeException)6 BizManagerService (com.alipay.sofa.ark.spi.service.biz.BizManagerService)6 Plugin (com.alipay.sofa.ark.spi.model.Plugin)5 AfterBizStartupEvent (com.alipay.sofa.ark.spi.event.biz.AfterBizStartupEvent)3 PluginModel (com.alipay.sofa.ark.container.model.PluginModel)2 ExecutableArchive (com.alipay.sofa.ark.spi.archive.ExecutableArchive)2 PluginArchive (com.alipay.sofa.ark.spi.archive.PluginArchive)2 AfterBizSwitchEvent (com.alipay.sofa.ark.spi.event.biz.AfterBizSwitchEvent)2 BeforeBizStartupEvent (com.alipay.sofa.ark.spi.event.biz.BeforeBizStartupEvent)2 BeforeBizSwitchEvent (com.alipay.sofa.ark.spi.event.biz.BeforeBizSwitchEvent)2 BeforePluginStartupEvent (com.alipay.sofa.ark.spi.event.plugin.BeforePluginStartupEvent)2 EventAdminService (com.alipay.sofa.ark.spi.service.event.EventAdminService)2 URL (java.net.URL)2 HashSet (java.util.HashSet)2 MainMethodRunner (com.alipay.sofa.ark.bootstrap.MainMethodRunner)1 OrderComparator (com.alipay.sofa.ark.common.util.OrderComparator)1