当前位置: 首页>>代码示例>>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;未经允许,请勿转载。