Search in sources :

Example 1 with JarFileArchive

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

the class PluginFactoryServiceTest method testCreateEmbedPlugin.

@Test
public void testCreateEmbedPlugin() throws IOException {
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    URL samplePlugin = cl.getResource("sample-plugin.jar");
    PluginArchive archive = new JarPluginArchive(new JarFileArchive(new File(samplePlugin.getFile())));
    Plugin plugin = pluginFactoryService.createEmbedPlugin(archive, this.getClass().getClassLoader());
    Assert.assertNotNull(plugin);
}
Also used : JarPluginArchive(com.alipay.sofa.ark.loader.JarPluginArchive) PluginArchive(com.alipay.sofa.ark.spi.archive.PluginArchive) JarFileArchive(com.alipay.sofa.ark.loader.archive.JarFileArchive) JarFile(com.alipay.sofa.ark.loader.jar.JarFile) File(java.io.File) URL(java.net.URL) JarPluginArchive(com.alipay.sofa.ark.loader.JarPluginArchive) Plugin(com.alipay.sofa.ark.spi.model.Plugin) Test(org.junit.Test) BaseTest(com.alipay.sofa.ark.container.BaseTest)

Example 2 with JarFileArchive

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

the class PluginFactoryServiceImpl method createPlugin.

@Override
public Plugin createPlugin(File file) throws IOException {
    JarFile pluginFile = new JarFile(file);
    JarFileArchive jarFileArchive = new JarFileArchive(pluginFile);
    JarPluginArchive jarPluginArchive = new JarPluginArchive(jarFileArchive);
    return createPlugin(jarPluginArchive);
}
Also used : JarFileArchive(com.alipay.sofa.ark.loader.archive.JarFileArchive) JarFile(com.alipay.sofa.ark.loader.jar.JarFile) JarPluginArchive(com.alipay.sofa.ark.loader.JarPluginArchive)

Example 3 with JarFileArchive

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

the class ArkContainerTest method testStop.

@Test
public void testStop() throws Exception {
    ArkContainer arkContainer = new ArkContainer(new ExecutableArkBizJar(new JarFileArchive(new File((jarURL.getFile())))));
    arkContainer.start();
    arkContainer.stop();
    Assert.assertFalse(arkContainer.isRunning());
}
Also used : ExecutableArkBizJar(com.alipay.sofa.ark.loader.ExecutableArkBizJar) JarFileArchive(com.alipay.sofa.ark.loader.archive.JarFileArchive) File(java.io.File) Test(org.junit.Test)

Example 4 with JarFileArchive

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

the class ArkContainerTest method testStart.

@Test
public void testStart() throws Exception {
    ArkContainer arkContainer = new ArkContainer(new ExecutableArkBizJar(new JarFileArchive(new File((jarURL.getFile())))));
    arkContainer.start();
    Assert.assertTrue(arkContainer.isStarted());
}
Also used : ExecutableArkBizJar(com.alipay.sofa.ark.loader.ExecutableArkBizJar) JarFileArchive(com.alipay.sofa.ark.loader.archive.JarFileArchive) File(java.io.File) Test(org.junit.Test)

Example 5 with JarFileArchive

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

the class ExecutableArchiveLauncher 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() ? null : new ExecutableArkBizJar(new JarFileArchive(root), root.toURI().toURL());
}
Also used : 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

JarFileArchive (com.alipay.sofa.ark.loader.archive.JarFileArchive)11 File (java.io.File)10 ExecutableArkBizJar (com.alipay.sofa.ark.loader.ExecutableArkBizJar)5 Test (org.junit.Test)5 JarFile (com.alipay.sofa.ark.loader.jar.JarFile)4 JarPluginArchive (com.alipay.sofa.ark.loader.JarPluginArchive)3 BizArchive (com.alipay.sofa.ark.spi.archive.BizArchive)3 URL (java.net.URL)3 BaseTest (com.alipay.sofa.ark.container.BaseTest)2 EmbedClassPathArchive (com.alipay.sofa.ark.loader.EmbedClassPathArchive)2 ExplodedArchive (com.alipay.sofa.ark.loader.archive.ExplodedArchive)2 Archive (com.alipay.sofa.ark.spi.archive.Archive)2 PluginArchive (com.alipay.sofa.ark.spi.archive.PluginArchive)2 Plugin (com.alipay.sofa.ark.spi.model.Plugin)2 IOException (java.io.IOException)2 URI (java.net.URI)2 CodeSource (java.security.CodeSource)2 ProtectionDomain (java.security.ProtectionDomain)2 ClassPathArchive (com.alipay.sofa.ark.bootstrap.ClasspathLauncher.ClassPathArchive)1 BizModel (com.alipay.sofa.ark.container.model.BizModel)1