下面列出了怎么用org.springframework.boot.loader.archive.ExplodedArchive的API类实例代码及写法,或者点击链接到github查看源代码。
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));
}
protected static Archive createArchive(Class clazz) throws Exception {
ProtectionDomain protectionDomain = clazz.getProtectionDomain();
CodeSource codeSource = protectionDomain.getCodeSource();
URI location = codeSource != null ? codeSource.getLocation().toURI() : null;
String path = location != null ? location.getSchemeSpecificPart() : null;
if (path == null) {
throw new IllegalStateException("Unable to determine code source archive");
} else {
File root = new File(path);
if (!root.exists()) {
throw new IllegalStateException("Unable to determine code source archive from " + root);
} else {
return (Archive)(root.isDirectory() ? new ExplodedArchive(root) : new JarFileArchive(root));
}
}
}
@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);
}
}
private Archive resolveAsArchive(Resource app) throws IOException {
File moduleFile = app.getFile();
return moduleFile.isDirectory() ? new ExplodedArchive(moduleFile) : new JarFileArchive(moduleFile);
}
private Archive resolveAsArchive(Resource app) throws IOException {
File moduleFile = app.getFile();
return moduleFile.isDirectory() ? new ExplodedArchive(moduleFile) : new JarFileArchive(moduleFile);
}
private static Archive resolveAsArchive(Resource app) throws IOException {
Assert.notNull(app, "The resource specified for the app must not be null");
File moduleFile = app.getFile();
return moduleFile.isDirectory() ? new ExplodedArchive(moduleFile) : new JarFileArchive(moduleFile);
}