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


Java JarFile类代码示例

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


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

示例1: test

import org.springframework.boot.loader.jar.JarFile; //导入依赖的package包/类
@Test
    public void test() {
        try {
            JarFile.registerUrlProtocolHandler();
            LaunchedURLClassLoader classLoader = new LaunchedURLClassLoader(
                    new URL[] {
                            new URL("jar:file:/Users/fangjian/Develop/gitrepository/springboot-analysis/springboot-executable-jar/target/executable-jar-1.0-SNAPSHOT.jar!/lib/spring-boot-loader-1.3.5.RELEASE.jar!/")
                            , new URL("jar:file:/Users/fangjian/Develop/gitrepository/springboot-analysis/springboot-executable-jar/target/executable-jar-1.0-SNAPSHOT.jar!/lib/spring-boot-1.3.5.RELEASE.jar!/")
                    },
                    LaunchedURLClassLoaderTest.class.getClassLoader());

//            classLoader.loadClass("org.springframework.boot.loader.JarLauncher");
//            classLoader.loadClass("org.springframework.boot.SpringApplication");
            classLoader.loadClass("org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
开发者ID:fangjian0423,项目名称:springboot-analysis,代码行数:19,代码来源:LaunchedURLClassLoaderTest.java

示例2: BootApplicationConfigurationMetadataResolver

import org.springframework.boot.loader.jar.JarFile; //导入依赖的package包/类
public BootApplicationConfigurationMetadataResolver(ClassLoader parent) {
	this.parent = parent;
	JarFile.registerUrlProtocolHandler();
	try {
		Resource[] globalResources = new PathMatchingResourcePatternResolver(ApplicationConfigurationMetadataResolver.class.getClassLoader()).getResources(WHITELIST_PROPERTIES);
		loadWhiteLists(globalResources, globalWhiteListedClasses, globalWhiteListedProperties);
	}
	catch (IOException e) {
		throw new RuntimeException("Error reading global white list of configuration properties", e);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:12,代码来源:BootApplicationConfigurationMetadataResolver.java

示例3: getNestedArchive

import org.springframework.boot.loader.jar.JarFile; //导入依赖的package包/类
protected Archive getNestedArchive(Entry entry) throws IOException {
	JarEntry jarEntry = ((JarFileEntry) entry).getJarEntry();
	if (jarEntry.getComment().startsWith(UNPACK_MARKER)) {
		return getUnpackedNestedArchive(jarEntry);
	}
	JarFile jarFile = this.jarFile.getNestedJarFile(jarEntry);
	return new JarFileArchive(jarFile);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:JarFileArchive.java

示例4: resolveFromNested

import org.springframework.boot.loader.jar.JarFile; //导入依赖的package包/类
@Test
public void resolveFromNested() throws Exception {
	File file = this.temporaryFolder.newFile();
	TestJarCreator.createTestJar(file);
	JarFile jarFile = new JarFile(file);
	URL url = jarFile.getUrl();
	LaunchedURLClassLoader loader = new LaunchedURLClassLoader(new URL[] { url },
			null);
	URL resource = loader.getResource("nested.jar!/3.dat");
	assertThat(resource.toString()).isEqualTo(url + "nested.jar!/3.dat");
	assertThat(resource.openConnection().getInputStream().read()).isEqualTo(3);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:LaunchedURLClassLoaderTests.java

示例5: BootApplicationConfigurationMetadataResolver

import org.springframework.boot.loader.jar.JarFile; //导入依赖的package包/类
public BootApplicationConfigurationMetadataResolver(ClassLoader parent) {
	this.parent = parent;
	JarFile.registerUrlProtocolHandler();
	try {
		Resource[] globalResources = new PathMatchingResourcePatternResolver(
				ApplicationConfigurationMetadataResolver.class.getClassLoader()).getResources(WHITELIST_PROPERTIES);
		loadWhiteLists(globalResources, globalWhiteListedClasses, globalWhiteListedProperties);
	}
	catch (IOException e) {
		throw new RuntimeException("Error reading global white list of configuration properties", e);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:13,代码来源:BootApplicationConfigurationMetadataResolver.java

示例6: JarFileArchive

import org.springframework.boot.loader.jar.JarFile; //导入依赖的package包/类
public JarFileArchive(JarFile jarFile) {
	this.jarFile = jarFile;
	ArrayList<Entry> jarFileEntries = new ArrayList<Entry>();
	for (JarEntryData data : jarFile) {
		jarFileEntries.add(new JarFileEntry(data));
	}
	this.entries = Collections.unmodifiableList(jarFileEntries);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:9,代码来源:JarFileArchive.java

示例7: getNestedArchive

import org.springframework.boot.loader.jar.JarFile; //导入依赖的package包/类
protected Archive getNestedArchive(Entry entry) throws IOException {
	JarEntryData data = ((JarFileEntry) entry).getJarEntryData();
	if (data.getComment().startsWith(UNPACK_MARKER)) {
		return getUnpackedNestedArchive(data);
	}
	JarFile jarFile = this.jarFile.getNestedJarFile(data);
	return new JarFileArchive(jarFile);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:9,代码来源:JarFileArchive.java

示例8: getFilteredArchive

import org.springframework.boot.loader.jar.JarFile; //导入依赖的package包/类
@Override
public Archive getFilteredArchive(final EntryRenameFilter filter) throws IOException {
	JarFile filteredJar = this.jarFile.getFilteredJarFile(new JarEntryFilter() {
		@Override
		public AsciiBytes apply(AsciiBytes name, JarEntryData entryData) {
			return filter.apply(name, new JarFileEntry(entryData));
		}
	});
	return new JarFileArchive(filteredJar);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:11,代码来源:JarFileArchive.java

示例9: launch

import org.springframework.boot.loader.jar.JarFile; //导入依赖的package包/类
/**
 * Launch the application. This method is the initial entry point that should be
 * called by a subclass {@code public static void main(String[] args)} method.
 * @param args the incoming arguments
 */
protected void launch(String[] args) {
	try {
		JarFile.registerUrlProtocolHandler();
		ClassLoader classLoader = createClassLoader(getClassPathArchives());
		launch(args, getMainClass(), classLoader);
	}
	catch (Exception ex) {
		ex.printStackTrace();
		System.exit(1);
	}
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:17,代码来源:Launcher.java

示例10: resolveFromNested

import org.springframework.boot.loader.jar.JarFile; //导入依赖的package包/类
@Test
public void resolveFromNested() throws Exception {
	File file = this.temporaryFolder.newFile();
	TestJarCreator.createTestJar(file);
	JarFile jarFile = new JarFile(file);
	URL url = jarFile.getUrl();
	LaunchedURLClassLoader loader = new LaunchedURLClassLoader(new URL[] { url },
			null);
	URL resource = loader.getResource("nested.jar!/3.dat");
	assertThat(resource.toString(), equalTo(url + "nested.jar!/3.dat"));
	assertThat(resource.openConnection().getInputStream().read(), equalTo(3));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:13,代码来源:LaunchedURLClassLoaderTests.java

示例11: start

import org.springframework.boot.loader.jar.JarFile; //导入依赖的package包/类
public static void start (String []args) {
    bootstrap = new Bootstrap ();
    try {
        JarFile.registerUrlProtocolHandler();
        classLoader = bootstrap.createClassLoader(bootstrap.getClassPathArchives());
        bootstrap.launch(args, bootstrap.getMainClass(), classLoader, true);
    }
    catch (Exception ex) {
        ex.printStackTrace();
        System.exit(1);
    }
}
 
开发者ID:francesc79,项目名称:test-procrun,代码行数:13,代码来源:Bootstrap.java

示例12: start

import org.springframework.boot.loader.jar.JarFile; //导入依赖的package包/类
public static synchronized void start(String[] args) throws Exception {
    warlauncher = new MidPointWarLauncher();

    try {
        JarFile.registerUrlProtocolHandler();
        classLoader = warlauncher.createClassLoader(warlauncher.getClassPathArchives());
        warlauncher.launch(args, warlauncher.getMainClass(), classLoader, true);
    } catch (Exception ex) {
        StringBuilder sb = new StringBuilder();
        sb.append("Could not start MidPoint application").append(";").append(ex.getLocalizedMessage());
        throw new Exception(sb.toString(), ex);
    }
}
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:14,代码来源:MidPointWarLauncher.java

示例13: JarFileArchive

import org.springframework.boot.loader.jar.JarFile; //导入依赖的package包/类
public JarFileArchive(File file, URL url) throws IOException {
	this(new JarFile(file));
	this.url = url;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:5,代码来源:JarFileArchive.java

示例14: clearCache

import org.springframework.boot.loader.jar.JarFile; //导入依赖的package包/类
private void clearCache(URLConnection connection) throws IOException {
	Object jarFile = ((JarURLConnection) connection).getJarFile();
	if (jarFile instanceof JarFile) {
		((JarFile) jarFile).clearCache();
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:LaunchedURLClassLoader.java

示例15: launch

import org.springframework.boot.loader.jar.JarFile; //导入依赖的package包/类
/**
 * Launch the application. This method is the initial entry point that should be
 * called by a subclass {@code public static void main(String[] args)} method.
 * @param args the incoming arguments
 * @throws Exception if the application fails to launch
 */
protected void launch(String[] args) throws Exception {
	JarFile.registerUrlProtocolHandler();
	ClassLoader classLoader = createClassLoader(getClassPathArchives());
	launch(args, getMainClass(), classLoader);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:Launcher.java


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