本文整理匯總了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;
}
}