当前位置: 首页>>代码示例>>Java>>正文


Java Archive类代码示例

本文整理汇总了Java中org.springframework.boot.loader.archive.Archive的典型用法代码示例。如果您正苦于以下问题:Java Archive类的具体用法?Java Archive怎么用?Java Archive使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Archive类属于org.springframework.boot.loader.archive包,在下文中一共展示了Archive类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SpringBootPluginsClassLoader

import org.springframework.boot.loader.archive.Archive; //导入依赖的package包/类
public SpringBootPluginsClassLoader(final ClassLoader parent) throws IOException {
    super(new URL[]{}, parent);

    // find all jar plugins
    final Collection<File> jarFiles = FileUtils.listFiles(new File("plugins/"), new String[]{"jar"}, false);

    for(final File jarFile : jarFiles) {
        // add the jar's own classes to classpath
        final URL jarURL = new URL("jar:file:" + jarFile.getPath() + "!/BOOT-INF/classes/");
        addURL(jarURL);

        final JarFileArchive jarFileArchive = new JarFileArchive(jarFile);
        final List<Archive> nestedArchives = jarFileArchive
                .getNestedArchives(entry -> entry.getName().endsWith(".jar"));

        for(final Archive archive : nestedArchives) {
            // add all bundled dependencies to classpath
            addURL(archive.getUrl());
        }
    }
}
 
开发者ID:jonfryd,项目名称:tifoon,代码行数:22,代码来源:SpringBootPluginsClassLoader.java

示例2: createArchive

import org.springframework.boot.loader.archive.Archive; //导入依赖的package包/类
protected final Archive 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 ExplodedArchive(root)
			: new JarFileArchive(root));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:Launcher.java

示例3: getClassPathArchives

import org.springframework.boot.loader.archive.Archive; //导入依赖的package包/类
@Override
protected List<Archive> getClassPathArchives() throws Exception {
	List<Archive> lib = new ArrayList<Archive>();
	for (String path : this.paths) {
		for (Archive archive : getClassPathArchives(path)) {
			if (archive instanceof ExplodedArchive) {
				List<Archive> nested = new ArrayList<Archive>(
						archive.getNestedArchives(new ArchiveEntryFilter()));
				nested.add(0, archive);
				lib.addAll(nested);
			}
			else {
				lib.add(archive);
			}
		}
	}
	addNestedEntries(lib);
	return lib;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:PropertiesLauncher.java

示例4: addNestedEntries

import org.springframework.boot.loader.archive.Archive; //导入依赖的package包/类
private void addNestedEntries(List<Archive> lib) {
	// The parent archive might have "BOOT-INF/lib/" and "BOOT-INF/classes/"
	// directories, meaning we are running from an executable JAR. We add nested
	// entries from there with low priority (i.e. at end).
	try {
		lib.addAll(this.parent.getNestedArchives(new EntryFilter() {

			@Override
			public boolean matches(Entry entry) {
				if (entry.isDirectory()) {
					return entry.getName().startsWith(JarLauncher.BOOT_INF_CLASSES);
				}
				return entry.getName().startsWith(JarLauncher.BOOT_INF_LIB);
			}

		}));
	}
	catch (IOException ex) {
		// Ignore
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:22,代码来源:PropertiesLauncher.java

示例5: explodedWarHasOnlyWebInfClassesAndContentsOfWebInfLibOnClasspath

import org.springframework.boot.loader.archive.Archive; //导入依赖的package包/类
@Test
public void explodedWarHasOnlyWebInfClassesAndContentsOfWebInfLibOnClasspath()
		throws Exception {
	File warRoot = new File("target/exploded-war");
	FileSystemUtils.deleteRecursively(warRoot);
	warRoot.mkdirs();
	File webInfClasses = new File(warRoot, "WEB-INF/classes");
	webInfClasses.mkdirs();
	File webInfLib = new File(warRoot, "WEB-INF/lib");
	webInfLib.mkdirs();
	File webInfLibFoo = new File(webInfLib, "foo.jar");
	new JarOutputStream(new FileOutputStream(webInfLibFoo)).close();
	WarLauncher launcher = new WarLauncher(new ExplodedArchive(warRoot, true));
	List<Archive> archives = launcher.getClassPathArchives();
	assertThat(archives).hasSize(2);
	assertThat(getUrls(archives)).containsOnly(webInfClasses.toURI().toURL(),
			new URL("jar:" + webInfLibFoo.toURI().toURL() + "!/"));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:WarLauncherTests.java

示例6: addNestedArchivesFromParent

import org.springframework.boot.loader.archive.Archive; //导入依赖的package包/类
private void addNestedArchivesFromParent(List<Archive> urls) {
	int index = findArchive(urls, this.parent);
	if (index >= 0) {
		try {
			Archive nested = getNestedArchive("lib/");
			if (nested != null) {
				List<Archive> extra = new ArrayList<Archive>(
						nested.getNestedArchives(new ArchiveEntryFilter()));
				urls.addAll(index + 1, extra);
			}
		}
		catch (Exception ex) {
			// ignore
		}
	}
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:17,代码来源:PropertiesLauncher.java

示例7: explodedWarHasOnlyWebInfClassesAndContentsOfWebInfLibOnClasspath

import org.springframework.boot.loader.archive.Archive; //导入依赖的package包/类
@Test
public void explodedWarHasOnlyWebInfClassesAndContentsOfWebInfLibOnClasspath()
		throws Exception {
	File warRoot = new File("target/exploded-war");
	FileSystemUtils.deleteRecursively(warRoot);
	warRoot.mkdirs();
	File webInfClasses = new File(warRoot, "WEB-INF/classes");
	webInfClasses.mkdirs();
	File webInfLib = new File(warRoot, "WEB-INF/lib");
	webInfLib.mkdirs();
	File webInfLibFoo = new File(webInfLib, "foo.jar");
	new JarOutputStream(new FileOutputStream(webInfLibFoo)).close();

	WarLauncher launcher = new WarLauncher(new ExplodedArchive(warRoot, true));
	List<Archive> archives = launcher.getClassPathArchives();
	assertEquals(2, archives.size());

	assertThat(getUrls(archives), hasItems(webInfClasses.toURI().toURL(),
			new URL("jar:" + webInfLibFoo.toURI().toURL() + "!/")));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:21,代码来源:WarLauncherTests.java

示例8: listProperties

import org.springframework.boot.loader.archive.Archive; //导入依赖的package包/类
/**
 * Return metadata about configuration properties that are documented via
 * <a href="http://docs.spring.io/spring-boot/docs/current/reference/html/configuration-metadata.html">
 * Spring Boot configuration metadata</a> and visible in an app.
 * @param app a Spring Cloud Stream app; typically a Boot uberjar,
 *            but directories are supported as well
 */
public List<ConfigurationMetadataProperty> listProperties(Resource app, boolean exhaustive) {
	try {
		Archive archive = resolveAsArchive(app);
		return listProperties(archive, exhaustive);
	}
	catch (IOException e) {
		throw new RuntimeException("Failed to list properties for " + app, e);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:17,代码来源:BootApplicationConfigurationMetadataResolver.java

示例9: createClassLoader

import org.springframework.boot.loader.archive.Archive; //导入依赖的package包/类
public URLClassLoader createClassLoader() {
	boolean useBoot14Layout = false;
	for (Archive.Entry entry : archive) {
		if (entry.getName().startsWith(BOOT_14_LIBS_LOCATION)) {
			useBoot14Layout = true;
			break;
		}
	}

	ClassLoaderExposingLauncher launcher = useBoot14Layout
			? new Boot14ClassLoaderExposingLauncher()
			: new Boot13ClassLoaderExposingLauncher();

	return launcher.createClassLoader();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:16,代码来源:BootClassLoaderFactory.java

示例10: isNestedArchive

import org.springframework.boot.loader.archive.Archive; //导入依赖的package包/类
@Override
protected boolean isNestedArchive(Archive.Entry entry) {
	if (entry.isDirectory()) {
		return entry.getName().equals(BOOT_INF_CLASSES);
	}
	return entry.getName().startsWith(BOOT_INF_LIB);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:JarLauncher.java

示例11: createClassLoader

import org.springframework.boot.loader.archive.Archive; //导入依赖的package包/类
/**
 * Create a classloader for the specified archives.
 * @param archives the archives
 * @return the classloader
 * @throws Exception if the classloader cannot be created
 */
protected ClassLoader createClassLoader(List<Archive> archives) throws Exception {
	List<URL> urls = new ArrayList<URL>(archives.size());
	for (Archive archive : archives) {
		urls.add(archive.getUrl());
	}
	return createClassLoader(urls.toArray(new URL[urls.size()]));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:Launcher.java

示例12: isNestedArchive

import org.springframework.boot.loader.archive.Archive; //导入依赖的package包/类
@Override
public boolean isNestedArchive(Archive.Entry entry) {
	if (entry.isDirectory()) {
		return entry.getName().equals(WEB_INF_CLASSES);
	}
	else {
		return entry.getName().startsWith(WEB_INF_LIB)
				|| entry.getName().startsWith(WEB_INF_LIB_PROVIDED);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:WarLauncher.java

示例13: createClassLoader

import org.springframework.boot.loader.archive.Archive; //导入依赖的package包/类
@Override
protected ClassLoader createClassLoader(List<Archive> archives) throws Exception {
	ClassLoader loader = super.createClassLoader(archives);
	String customLoaderClassName = getProperty("loader.classLoader");
	if (customLoaderClassName != null) {
		loader = wrapWithCustomClassLoader(loader, customLoaderClassName);
		log("Using custom class loader: " + customLoaderClassName);
	}
	return loader;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:PropertiesLauncher.java

示例14: getArchive

import org.springframework.boot.loader.archive.Archive; //导入依赖的package包/类
private Archive getArchive(File file) throws IOException {
	String name = file.getName().toLowerCase();
	if (name.endsWith(".jar") || name.endsWith(".zip")) {
		return new JarFileArchive(file);
	}
	return null;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:PropertiesLauncher.java

示例15: getNestedArchive

import org.springframework.boot.loader.archive.Archive; //导入依赖的package包/类
private Archive getNestedArchive(String root) throws Exception {
	if (root.startsWith("/")
			|| this.parent.getUrl().equals(this.home.toURI().toURL())) {
		// If home dir is same as parent archive, no need to add it twice.
		return null;
	}
	EntryFilter filter = new PrefixMatchingArchiveFilter(root);
	if (this.parent.getNestedArchives(filter).isEmpty()) {
		return null;
	}
	// If there are more archives nested in this subdirectory (root) then create a new
	// virtual archive for them, and have it added to the classpath
	return new FilteredArchive(this.parent, filter);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:PropertiesLauncher.java


注:本文中的org.springframework.boot.loader.archive.Archive类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。