Java 类org.springframework.boot.loader.archive.ExplodedArchive 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:Launcher.java   
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));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertiesLauncher.java   
@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;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:WarLauncherTests.java   
@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() + "!/"));
}
项目:spring-boot-concourse    文件:Launcher.java   
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));
}
项目:spring-boot-concourse    文件:PropertiesLauncher.java   
@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;
}
项目:spring-boot-concourse    文件:WarLauncherTests.java   
@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() + "!/"));
}
项目:contestparser    文件:Launcher.java   
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));
}
项目:contestparser    文件:WarLauncherTests.java   
@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() + "!/")));
}
项目:spring-cloud-stream-app-starters    文件:ConfigurationMetadataDocumentationMojo.java   
@Override
public List<Archive> getNestedArchives(EntryFilter ignored) throws IOException {
    try {
        List<Archive> archives = new ArrayList<>(mavenProject.getRuntimeClasspathElements().size());
        for (String dep : mavenProject.getRuntimeClasspathElements()) {
            File file = new File(dep);
            archives.add(file.isDirectory() ? new ExplodedArchive(file) : new JarFileArchive(file));
        }
        return archives;
    }
    catch (DependencyResolutionRequiredException e) {
        throw new IOException("Could not create boot archive", e);
    }

}
项目:contestparser    文件:PropertiesLauncher.java   
private void addParentClassLoaderEntries(List<Archive> lib)
        throws IOException, URISyntaxException {
    ClassLoader parentClassLoader = getClass().getClassLoader();
    List<Archive> urls = new ArrayList<Archive>();
    for (URL url : getURLs(parentClassLoader)) {
        if (url.toString().endsWith(".jar") || url.toString().endsWith(".zip")) {
            urls.add(new JarFileArchive(new File(url.toURI())));
        }
        else if (url.toString().endsWith("/*")) {
            String name = url.getFile();
            File dir = new File(name.substring(0, name.length() - 1));
            if (dir.exists()) {
                urls.add(new ExplodedArchive(
                        new File(name.substring(0, name.length() - 1)), false));
            }
        }
        else {
            String filename = URLDecoder.decode(url.getFile(), "UTF-8");
            urls.add(new ExplodedArchive(new File(filename)));
        }
    }
    // The parent archive might have a "lib/" directory, meaning we are running from
    // an executable JAR. We add nested entries from there with low priority (i.e. at
    // end).
    addNestedArchivesFromParent(urls);
    for (Archive archive : urls) {
        // But only add them if they are not already included
        if (findArchive(lib, archive) < 0) {
            lib.add(archive);
        }
    }
}
项目:spring-cloud-dashboard    文件:BootApplicationConfigurationMetadataResolver.java   
private Archive resolveAsArchive(Resource app) throws IOException {
        File moduleFile = app.getFile();
        return moduleFile.isDirectory() ? new ExplodedArchive(moduleFile) : new JarFileArchive(moduleFile);
}
项目:spring-cloud-dataflow    文件:BootApplicationConfigurationMetadataResolver.java   
private Archive resolveAsArchive(Resource app) throws IOException {
    File moduleFile = app.getFile();
    return moduleFile.isDirectory() ? new ExplodedArchive(moduleFile) : new JarFileArchive(moduleFile);
}