Search in sources :

Example 1 with ExplodedBizArchive

use of com.alipay.sofa.ark.loader.ExplodedBizArchive in project sofa-ark by alipay.

the class BizFactoryServiceImpl method createBiz.

@Override
public Biz createBiz(BizArchive bizArchive) throws IOException {
    AssertUtils.isTrue(isArkBiz(bizArchive), "Archive must be a ark biz!");
    BizModel bizModel = new BizModel();
    Attributes manifestMainAttributes = bizArchive.getManifest().getMainAttributes();
    bizModel.setBizState(BizState.RESOLVED).setBizName(manifestMainAttributes.getValue(ARK_BIZ_NAME)).setBizVersion(manifestMainAttributes.getValue(ARK_BIZ_VERSION)).setMainClass(manifestMainAttributes.getValue(MAIN_CLASS_ATTRIBUTE)).setPriority(manifestMainAttributes.getValue(PRIORITY_ATTRIBUTE)).setWebContextPath(manifestMainAttributes.getValue(WEB_CONTEXT_PATH)).setDenyImportPackages(manifestMainAttributes.getValue(DENY_IMPORT_PACKAGES)).setDenyImportClasses(manifestMainAttributes.getValue(DENY_IMPORT_CLASSES)).setDenyImportResources(manifestMainAttributes.getValue(DENY_IMPORT_RESOURCES)).setInjectPluginDependencies(getInjectDependencies(manifestMainAttributes.getValue(INJECT_PLUGIN_DEPENDENCIES))).setInjectExportPackages(manifestMainAttributes.getValue(INJECT_EXPORT_PACKAGES)).setClassPath(bizArchive.getUrls()).setClassLoader(new BizClassLoader(bizModel.getIdentity(), getBizUcp(bizModel.getClassPath()), bizArchive instanceof ExplodedBizArchive));
    return bizModel;
}
Also used : Attributes(java.util.jar.Attributes) ExplodedBizArchive(com.alipay.sofa.ark.loader.ExplodedBizArchive) BizModel(com.alipay.sofa.ark.container.model.BizModel) BizClassLoader(com.alipay.sofa.ark.container.service.classloader.BizClassLoader)

Example 2 with ExplodedBizArchive

use of com.alipay.sofa.ark.loader.ExplodedBizArchive in project sofa-ark by alipay.

the class BizFactoryServiceImpl method createBiz.

@Override
public Biz createBiz(File file) throws IOException {
    BizArchive bizArchive;
    if (ArkConfigs.isEmbedEnable()) {
        File unpackFile = new File(file.getAbsolutePath() + "-unpack");
        if (!unpackFile.exists()) {
            unpackFile = FileUtils.unzip(file, file.getAbsolutePath() + "-unpack");
        }
        if (file.exists()) {
            file.delete();
        }
        file = unpackFile;
        bizArchive = new ExplodedBizArchive(unpackFile);
    } else {
        JarFile bizFile = new JarFile(file);
        JarFileArchive jarFileArchive = new JarFileArchive(bizFile);
        bizArchive = new JarBizArchive(jarFileArchive);
    }
    BizModel biz = (BizModel) createBiz(bizArchive);
    biz.setBizTempWorkDir(file);
    return biz;
}
Also used : JarBizArchive(com.alipay.sofa.ark.loader.JarBizArchive) JarFileArchive(com.alipay.sofa.ark.loader.archive.JarFileArchive) ExplodedBizArchive(com.alipay.sofa.ark.loader.ExplodedBizArchive) BizModel(com.alipay.sofa.ark.container.model.BizModel) JarFile(com.alipay.sofa.ark.loader.jar.JarFile) JarFile(com.alipay.sofa.ark.loader.jar.JarFile) File(java.io.File) BizArchive(com.alipay.sofa.ark.spi.archive.BizArchive) JarBizArchive(com.alipay.sofa.ark.loader.JarBizArchive) ExplodedBizArchive(com.alipay.sofa.ark.loader.ExplodedBizArchive)

Aggregations

BizModel (com.alipay.sofa.ark.container.model.BizModel)2 ExplodedBizArchive (com.alipay.sofa.ark.loader.ExplodedBizArchive)2 BizClassLoader (com.alipay.sofa.ark.container.service.classloader.BizClassLoader)1 JarBizArchive (com.alipay.sofa.ark.loader.JarBizArchive)1 JarFileArchive (com.alipay.sofa.ark.loader.archive.JarFileArchive)1 JarFile (com.alipay.sofa.ark.loader.jar.JarFile)1 BizArchive (com.alipay.sofa.ark.spi.archive.BizArchive)1 File (java.io.File)1 Attributes (java.util.jar.Attributes)1