Search in sources :

Example 1 with ExplodedArchive

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

the class ArkContainer method main.

public static Object main(String[] args) throws ArkRuntimeException {
    if (args.length < MINIMUM_ARGS_SIZE) {
        throw new ArkRuntimeException("Please provide suitable arguments to continue !");
    }
    try {
        LaunchCommand launchCommand = LaunchCommand.parse(args);
        if (launchCommand.isExecutedByCommandLine()) {
            ExecutableArkBizJar executableArchive;
            File rootFile = new File(URLDecoder.decode(launchCommand.getExecutableArkBizJar().getFile()));
            if (rootFile.isDirectory()) {
                executableArchive = new ExecutableArkBizJar(new ExplodedArchive(rootFile));
            } else {
                executableArchive = new ExecutableArkBizJar(new JarFileArchive(rootFile, launchCommand.getExecutableArkBizJar()));
            }
            return new ArkContainer(executableArchive, launchCommand).start();
        } else {
            ClassPathArchive classPathArchive;
            if (ArkConfigs.isEmbedEnable()) {
                classPathArchive = new EmbedClassPathArchive(launchCommand.getEntryClassName(), launchCommand.getEntryMethodName(), launchCommand.getClasspath());
            } else {
                classPathArchive = new ClassPathArchive(launchCommand.getEntryClassName(), launchCommand.getEntryMethodName(), launchCommand.getClasspath());
            }
            return new ArkContainer(classPathArchive, launchCommand).start();
        }
    } catch (IOException e) {
        throw new ArkRuntimeException(String.format("SOFAArk startup failed, commandline=%s", LaunchCommand.toString(args)), e);
    }
}
Also used : ExplodedArchive(com.alipay.sofa.ark.loader.archive.ExplodedArchive) LaunchCommand(com.alipay.sofa.ark.spi.argument.LaunchCommand) EmbedClassPathArchive(com.alipay.sofa.ark.loader.EmbedClassPathArchive) ExecutableArkBizJar(com.alipay.sofa.ark.loader.ExecutableArkBizJar) JarFileArchive(com.alipay.sofa.ark.loader.archive.JarFileArchive) IOException(java.io.IOException) File(java.io.File) ArkRuntimeException(com.alipay.sofa.ark.exception.ArkRuntimeException) ClassPathArchive(com.alipay.sofa.ark.bootstrap.ClasspathLauncher.ClassPathArchive) EmbedClassPathArchive(com.alipay.sofa.ark.loader.EmbedClassPathArchive)

Example 2 with ExplodedArchive

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

the class BaseExecutableArchiveLauncher method createArchive.

/**
 * Returns the executable file archive
 * @return executable file archive
 * @throws Exception
 */
protected ExecutableArchive createArchive() throws Exception {
    ProtectionDomain protectionDomain = getClass().getProtectionDomain();
    CodeSource codeSource = protectionDomain.getCodeSource();
    URI location = (codeSource == null ? null : codeSource.getLocation().toURI());
    String path = (location == null ? null : location.getSchemeSpecificPart());
    if (path == null) {
        throw new IllegalStateException("Unable to determine code source archive");
    }
    File root = new File(path);
    if (!root.exists()) {
        throw new IllegalStateException("Unable to determine code source archive from " + root);
    }
    return root.isDirectory() ? new ExecutableArkBizJar(new ExplodedArchive(root)) : new ExecutableArkBizJar(new JarFileArchive(root), root.toURI().toURL());
}
Also used : ExplodedArchive(com.alipay.sofa.ark.loader.archive.ExplodedArchive) ProtectionDomain(java.security.ProtectionDomain) ExecutableArkBizJar(com.alipay.sofa.ark.loader.ExecutableArkBizJar) JarFileArchive(com.alipay.sofa.ark.loader.archive.JarFileArchive) CodeSource(java.security.CodeSource) URI(java.net.URI) File(java.io.File)

Aggregations

ExecutableArkBizJar (com.alipay.sofa.ark.loader.ExecutableArkBizJar)2 ExplodedArchive (com.alipay.sofa.ark.loader.archive.ExplodedArchive)2 JarFileArchive (com.alipay.sofa.ark.loader.archive.JarFileArchive)2 File (java.io.File)2 ClassPathArchive (com.alipay.sofa.ark.bootstrap.ClasspathLauncher.ClassPathArchive)1 ArkRuntimeException (com.alipay.sofa.ark.exception.ArkRuntimeException)1 EmbedClassPathArchive (com.alipay.sofa.ark.loader.EmbedClassPathArchive)1 LaunchCommand (com.alipay.sofa.ark.spi.argument.LaunchCommand)1 IOException (java.io.IOException)1 URI (java.net.URI)1 CodeSource (java.security.CodeSource)1 ProtectionDomain (java.security.ProtectionDomain)1