Java 类org.springframework.boot.loader.jar.JarFile 实例源码

项目:springboot-analysis    文件:LaunchedURLClassLoaderTest.java   
@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();
        }
    }
项目:spring-cloud-dashboard    文件:BootApplicationConfigurationMetadataResolver.java   
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);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JarFileArchive.java   
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);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:LaunchedURLClassLoaderTests.java   
@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);
}
项目:spring-boot-concourse    文件:JarFileArchive.java   
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);
}
项目:spring-boot-concourse    文件:LaunchedURLClassLoaderTests.java   
@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);
}
项目:spring-cloud-dataflow    文件:BootApplicationConfigurationMetadataResolver.java   
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);
    }
}
项目:contestparser    文件:JarFileArchive.java   
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);
}
项目:contestparser    文件:JarFileArchive.java   
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);
}
项目:contestparser    文件:JarFileArchive.java   
@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);
}
项目:contestparser    文件:Launcher.java   
/**
 * 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);
    }
}
项目:contestparser    文件:LaunchedURLClassLoaderTests.java   
@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));
}
项目:test-procrun    文件:Bootstrap.java   
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);
    }
}
项目:midpoint    文件:MidPointWarLauncher.java   
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);
    }
}
项目:midpoint    文件:MidPointWarLauncher.java   
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);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JarFileArchive.java   
public JarFileArchive(File file, URL url) throws IOException {
    this(new JarFile(file));
    this.url = url;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JarFileArchive.java   
public JarFileArchive(JarFile jarFile) {
    this.jarFile = jarFile;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:LaunchedURLClassLoader.java   
private void clearCache(URLConnection connection) throws IOException {
    Object jarFile = ((JarURLConnection) connection).getJarFile();
    if (jarFile instanceof JarFile) {
        ((JarFile) jarFile).clearCache();
    }
}
项目:spring-boot-concourse    文件:JarFileArchive.java   
public JarFileArchive(File file, URL url) throws IOException {
    this(new JarFile(file));
    this.url = url;
}
项目:spring-boot-concourse    文件:JarFileArchive.java   
public JarFileArchive(JarFile jarFile) {
    this.jarFile = jarFile;
}
项目:spring-boot-concourse    文件:LaunchedURLClassLoader.java   
private void clearCache(URLConnection connection) throws IOException {
    Object jarFile = ((JarURLConnection) connection).getJarFile();
    if (jarFile instanceof JarFile) {
        ((JarFile) jarFile).clearCache();
    }
}
项目:contestparser    文件:JarFileArchive.java   
public JarFileArchive(File file, URL url) throws IOException {
    this(new JarFile(file));
    this.url = url;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:Launcher.java   
/**
 * 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);
}
项目:spring-boot-concourse    文件:Launcher.java   
/**
 * 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);
}