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);
}
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);
}
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());
}
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());
}
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());
}
Aggregations