當前位置: 首頁>>代碼示例>>Java>>正文


Java Resource.createRelative方法代碼示例

本文整理匯總了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;
}
 
開發者ID:howma03,項目名稱:sporticus,代碼行數:23,代碼來源:ConfigurationWeb.java

示例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;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:22,代碼來源:BaseIntegrationTest.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:DefaultPersistenceUnitManager.java

示例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;
  }
}
 
開發者ID:2DV603NordVisaProject,項目名稱:nordvisa_calendar,代碼行數:8,代碼來源:AppConfig.java


注:本文中的org.springframework.core.io.Resource.createRelative方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。