本文整理了Java中org.springframework.util.ResourceUtils.extractJarFileURL
方法的一些代码示例,展示了ResourceUtils.extractJarFileURL
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceUtils.extractJarFileURL
方法的具体详情如下:
包路径:org.springframework.util.ResourceUtils
类名称:ResourceUtils
方法名:extractJarFileURL
[英]Extract the URL for the actual jar file from the given URL (which may point to a resource in a jar file or to a jar file itself).
[中]从给定的URL(可能指向jar文件中的资源或jar文件本身)中提取实际jar文件的URL。
代码示例来源:origin: spring-projects/spring-framework
/**
* Extract the URL for the outermost archive from the given jar/war URL
* (which may point to a resource in a jar file or to a jar file itself).
* <p>In the case of a jar file nested within a war file, this will return
* a URL to the war file since that is the one resolvable in the file system.
* @param jarUrl the original URL
* @return the URL for the actual jar file
* @throws MalformedURLException if no valid jar file URL could be extracted
* @since 4.1.8
* @see #extractJarFileURL(URL)
*/
public static URL extractArchiveURL(URL jarUrl) throws MalformedURLException {
String urlFile = jarUrl.getFile();
int endIndex = urlFile.indexOf(WAR_URL_SEPARATOR);
if (endIndex != -1) {
// Tomcat's "war:file:...mywar.war*/WEB-INF/lib/myjar.jar!/myentry.txt"
String warFile = urlFile.substring(0, endIndex);
if (URL_PROTOCOL_WAR.equals(jarUrl.getProtocol())) {
return new URL(warFile);
}
int startIndex = warFile.indexOf(WAR_URL_PREFIX);
if (startIndex != -1) {
return new URL(warFile.substring(startIndex + WAR_URL_PREFIX.length()));
}
}
// Regular "jar:file:...myjar.jar!/myentry.txt"
return extractJarFileURL(jarUrl);
}
代码示例来源:origin: spring-projects/spring-framework
return ResourceUtils.extractJarFileURL(originalURL);
代码示例来源:origin: spring-projects/spring-framework
/**
* Try to determine the persistence unit root URL based on the given
* "defaultPersistenceUnitRootLocation".
* @return the persistence unit root URL to pass to the JPA PersistenceProvider
* @see #setDefaultPersistenceUnitRootLocation
*/
@Nullable
private URL determineDefaultPersistenceUnitRootUrl() {
if (this.defaultPersistenceUnitRootLocation == null) {
return null;
}
try {
URL url = this.resourcePatternResolver.getResource(this.defaultPersistenceUnitRootLocation).getURL();
return (ResourceUtils.isJarURL(url) ? ResourceUtils.extractJarFileURL(url) : url);
}
catch (IOException ex) {
throw new PersistenceException("Unable to resolve persistence unit root URL", ex);
}
}
代码示例来源:origin: org.springframework/spring-core
/**
* Extract the URL for the outermost archive from the given jar/war URL
* (which may point to a resource in a jar file or to a jar file itself).
* <p>In the case of a jar file nested within a war file, this will return
* a URL to the war file since that is the one resolvable in the file system.
* @param jarUrl the original URL
* @return the URL for the actual jar file
* @throws MalformedURLException if no valid jar file URL could be extracted
* @since 4.1.8
* @see #extractJarFileURL(URL)
*/
public static URL extractArchiveURL(URL jarUrl) throws MalformedURLException {
String urlFile = jarUrl.getFile();
int endIndex = urlFile.indexOf(WAR_URL_SEPARATOR);
if (endIndex != -1) {
// Tomcat's "war:file:...mywar.war*/WEB-INF/lib/myjar.jar!/myentry.txt"
String warFile = urlFile.substring(0, endIndex);
if (URL_PROTOCOL_WAR.equals(jarUrl.getProtocol())) {
return new URL(warFile);
}
int startIndex = warFile.indexOf(WAR_URL_PREFIX);
if (startIndex != -1) {
return new URL(warFile.substring(startIndex + WAR_URL_PREFIX.length()));
}
}
// Regular "jar:file:...myjar.jar!/myentry.txt"
return extractJarFileURL(jarUrl);
}
代码示例来源:origin: org.springframework/spring-orm
return ResourceUtils.extractJarFileURL(originalURL);
代码示例来源:origin: org.springframework/spring-orm
/**
* Try to determine the persistence unit root URL based on the given
* "defaultPersistenceUnitRootLocation".
* @return the persistence unit root URL to pass to the JPA PersistenceProvider
* @see #setDefaultPersistenceUnitRootLocation
*/
@Nullable
private URL determineDefaultPersistenceUnitRootUrl() {
if (this.defaultPersistenceUnitRootLocation == null) {
return null;
}
try {
URL url = this.resourcePatternResolver.getResource(this.defaultPersistenceUnitRootLocation).getURL();
return (ResourceUtils.isJarURL(url) ? ResourceUtils.extractJarFileURL(url) : url);
}
catch (IOException ex) {
throw new PersistenceException("Unable to resolve persistence unit root URL", ex);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void extractJarFileURL() throws Exception {
assertEquals(new URL("file:myjar.jar"),
ResourceUtils.extractJarFileURL(new URL("jar:file:myjar.jar!/mypath")));
assertEquals(new URL("file:/myjar.jar"),
ResourceUtils.extractJarFileURL(new URL(null, "jar:myjar.jar!/mypath", new DummyURLStreamHandler())));
assertEquals(new URL("file:myjar.jar"),
ResourceUtils.extractJarFileURL(new URL(null, "zip:file:myjar.jar!/mypath", new DummyURLStreamHandler())));
assertEquals(new URL("file:myjar.jar"),
ResourceUtils.extractJarFileURL(new URL(null, "wsjar:file:myjar.jar!/mypath", new DummyURLStreamHandler())));
assertEquals(new URL("file:myjar.jar"),
ResourceUtils.extractJarFileURL(new URL("file:myjar.jar")));
assertEquals(new URL("file:myjar.jar"),
ResourceUtils.extractJarFileURL(new URL("jar:file:myjar.jar!/")));
assertEquals(new URL("file:myjar.jar"),
ResourceUtils.extractJarFileURL(new URL(null, "zip:file:myjar.jar!/", new DummyURLStreamHandler())));
assertEquals(new URL("file:myjar.jar"),
ResourceUtils.extractJarFileURL(new URL(null, "wsjar:file:myjar.jar!/", new DummyURLStreamHandler())));
}
代码示例来源:origin: spring-projects/spring-framework
URL url = resource.getURL();
if (ResourceUtils.isJarURL(url)) {
scannedUnit.setPersistenceUnitRootUrl(ResourceUtils.extractJarFileURL(url));
代码示例来源:origin: baomidou/mybatis-plus
try {
if (ResourceUtils.isJarURL(mapperLocation.getURL())) {
String key = new UrlResource(ResourceUtils.extractJarFileURL(mapperLocation.getURL()))
.getFile().getPath();
fileSet.add(key);
代码示例来源:origin: org.springframework/spring-orm
URL url = resource.getURL();
if (ResourceUtils.isJarURL(url)) {
scannedUnit.setPersistenceUnitRootUrl(ResourceUtils.extractJarFileURL(url));
代码示例来源:origin: org.springframework.boot/spring-boot-devtools
private void updateTimeStamp(URL url) {
try {
URL actualUrl = ResourceUtils.extractJarFileURL(url);
File file = ResourceUtils.getFile(actualUrl, "Jar URL");
file.setLastModified(System.currentTimeMillis());
}
catch (Exception ex) {
// Ignore
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* This implementation determines the underlying File
* (or jar file, in case of a resource in a jar/zip).
*/
@Override
protected File getFileForLastModifiedCheck() throws IOException {
URL url = getURL();
if (ResourceUtils.isJarURL(url)) {
URL actualUrl = ResourceUtils.extractJarFileURL(url);
if (actualUrl.getProtocol().startsWith(ResourceUtils.URL_PROTOCOL_VFS)) {
return VfsResourceDelegate.getResource(actualUrl).getFile();
}
return ResourceUtils.getFile(actualUrl, "Jar URL");
}
else {
return getFile();
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core
/**
* Extract the URL for the outermost archive from the given jar/war URL
* (which may point to a resource in a jar file or to a jar file itself).
* <p>In the case of a jar file nested within a war file, this will return
* a URL to the war file since that is the one resolvable in the file system.
* @param jarUrl the original URL
* @return the URL for the actual jar file
* @throws MalformedURLException if no valid jar file URL could be extracted
* @since 4.1.8
* @see #extractJarFileURL(URL)
*/
public static URL extractArchiveURL(URL jarUrl) throws MalformedURLException {
String urlFile = jarUrl.getFile();
int endIndex = urlFile.indexOf(WAR_URL_SEPARATOR);
if (endIndex != -1) {
// Tomcat's "war:file:...mywar.war*/WEB-INF/lib/myjar.jar!/myentry.txt"
String warFile = urlFile.substring(0, endIndex);
if (URL_PROTOCOL_WAR.equals(jarUrl.getProtocol())) {
return new URL(warFile);
}
int startIndex = warFile.indexOf(WAR_URL_PREFIX);
if (startIndex != -1) {
return new URL(warFile.substring(startIndex + WAR_URL_PREFIX.length()));
}
}
// Regular "jar:file:...myjar.jar!/myentry.txt"
return extractJarFileURL(jarUrl);
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Extract the URL for the outermost archive from the given jar/war URL
* (which may point to a resource in a jar file or to a jar file itself).
* <p>In the case of a jar file nested within a war file, this will return
* a URL to the war file since that is the one resolvable in the file system.
* @param jarUrl the original URL
* @return the URL for the actual jar file
* @throws MalformedURLException if no valid jar file URL could be extracted
* @since 4.1.8
* @see #extractJarFileURL(URL)
*/
public static URL extractArchiveURL(URL jarUrl) throws MalformedURLException {
String urlFile = jarUrl.getFile();
int endIndex = urlFile.indexOf(WAR_URL_SEPARATOR);
if (endIndex != -1) {
// Tomcat's "war:file:...mywar.war*/WEB-INF/lib/myjar.jar!/myentry.txt"
String warFile = urlFile.substring(0, endIndex);
if (URL_PROTOCOL_WAR.equals(jarUrl.getProtocol())) {
return new URL(warFile);
}
int startIndex = warFile.indexOf(WAR_URL_PREFIX);
if (startIndex != -1) {
return new URL(warFile.substring(startIndex + WAR_URL_PREFIX.length()));
}
}
// Regular "jar:file:...myjar.jar!/myentry.txt"
return extractJarFileURL(jarUrl);
}
代码示例来源:origin: apache/servicemix-bundles
return ResourceUtils.extractJarFileURL(originalURL);
代码示例来源:origin: org.openl.rules/org.openl.rules.ruleservice
final URL resourceURL = rulesXmlResource.getURL();
if ("jar".equals(resourceURL.getProtocol()) || "wsjar".equals(resourceURL.getProtocol())) {
URL jarUrl = org.springframework.util.ResourceUtils.extractJarFileURL(resourceURL);
file = org.springframework.util.ResourceUtils.getFile(jarUrl);
} else if ("vfs".equals(rulesXmlResource.getURL().getProtocol())) {
代码示例来源:origin: openl-tablets/openl-tablets
final URL resourceURL = rulesXmlResource.getURL();
if ("jar".equals(resourceURL.getProtocol()) || "wsjar".equals(resourceURL.getProtocol())) {
URL jarUrl = org.springframework.util.ResourceUtils.extractJarFileURL(resourceURL);
file = org.springframework.util.ResourceUtils.getFile(jarUrl);
} else if ("vfs".equals(rulesXmlResource.getURL().getProtocol())) {
代码示例来源:origin: org.zeroturnaround/spring-jr-plugin
private static File getFileForLastModifiedCheck(UrlResource resource) throws IOException {
URL url = resource.getURL();
if (ResourceUtils.isJarURL(url)) {
URL actualUrl = ResourceUtils.extractJarFileURL(url);
return ResourceUtils.getFile(actualUrl);
}
else {
return resource.getFile();
}
}
代码示例来源:origin: org.springframework.android/spring-android-core
/**
* This implementation determines the underlying File (or jar file, in case of a resource in a jar/zip).
*/
@Override
protected File getFileForLastModifiedCheck() throws IOException {
URL url = getURL();
if (ResourceUtils.isJarURL(url)) {
URL actualUrl = ResourceUtils.extractJarFileURL(url);
return ResourceUtils.getFile(actualUrl, "Jar URL");
} else {
return getFile();
}
}
代码示例来源:origin: org.zeroturnaround/spring-jr-plugin
private static File getFileForLastModifiedCheck(ClassPathResource resource) throws IOException {
URL url = resource.getURL();
if (ResourceUtils.isJarURL(url)) {
URL actualUrl = ResourceUtils.extractJarFileURL(url);
return ResourceUtils.getFile(actualUrl);
}
else {
return ResourceUtils.getFile(url, resource.getDescription());
}
}
内容来源于网络,如有侵权,请联系作者删除!