本文整理汇总了Java中org.springframework.core.io.Resource.createRelative方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.createRelative方法的具体用法?Java Resource.createRelative怎么用?Java Resource.createRelative使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.core.io.Resource
的用法示例。
在下文中一共展示了Resource.createRelative方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResource
import org.springframework.core.io.Resource; //导入方法依赖的package包/类
@Override
protected Resource getResource(String resourcePath, Resource location) throws IOException {
Resource resource = location.createRelative(resourcePath);
if (resource.exists() && resource.isReadable()) {
return resource;
}
if (getApiPath() != null && ("/" + resourcePath).startsWith(getApiPath())) {
return null;
}
if(getApiPublicPath() != null && ("/" + resourcePath).startsWith(getApiPublicPath())) {
return null;
}
LoggerFactory.getLogger(getClass()).info("Routing /" + resourcePath + " to /index.html");
resource = location.createRelative("/WEB-INF/app/" + resourcePath);
LoggerFactory.getLogger(getClass()).info("Routing to " + resource);
if (resource.exists() && resource.isReadable()) {
return resource;
}
return null;
}
示例2: parse
import org.springframework.core.io.Resource; //导入方法依赖的package包/类
private Resource parse(String id, Resource resource) {
if (id.indexOf(SPRING_DM_PREFIX) > -1) {
try {
String relativePath = "";
// check if it's a relative file
if (StringUtils.cleanPath(resource.getURI().toString()).indexOf("/target/") > -1) {
relativePath = "clover" + File.separator;
}
relativePath = relativePath + id + "-clover.jar";
Resource res = resource.createRelative(relativePath);
BaseIntegrationTest.this.logger.info("Using clover instrumented jar " + res.getDescription());
return res;
}
catch (Exception ex) {
throw (RuntimeException) new IllegalStateException(
"Trying to find Clover instrumented class but none is available; disable clover or build the instrumented artifacts").initCause(ex);
}
}
return resource;
}
示例3: useOrmXmlForDefaultPersistenceUnit
import org.springframework.core.io.Resource; //导入方法依赖的package包/类
/**
* Determine whether to register JPA's default "META-INF/orm.xml" with
* Spring's default persistence unit, if any.
* <p>Checks whether a "META-INF/orm.xml" file exists in the classpath and
* uses it if it is not co-located with a "META-INF/persistence.xml" file.
*/
private boolean useOrmXmlForDefaultPersistenceUnit() {
Resource ormXml = this.resourcePatternResolver.getResource(
this.defaultPersistenceUnitRootLocation + DEFAULT_ORM_XML_RESOURCE);
if (ormXml.exists()) {
try {
Resource persistenceXml = ormXml.createRelative(PERSISTENCE_XML_FILENAME);
if (!persistenceXml.exists()) {
return true;
}
}
catch (IOException ex) {
// Cannot resolve relative persistence.xml file - let's assume it's not there.
return true;
}
}
return false;
}
示例4: createRelative
import org.springframework.core.io.Resource; //导入方法依赖的package包/类
private Resource createRelative(Resource resource, String relativePath) {
try {
return resource.createRelative(relativePath);
} catch (IOException e) {
return null;
}
}