本文整理汇总了Java中org.springframework.core.io.Resource.getDescription方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.getDescription方法的具体用法?Java Resource.getDescription怎么用?Java Resource.getDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.core.io.Resource
的用法示例。
在下文中一共展示了Resource.getDescription方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installBundle
import org.springframework.core.io.Resource; //导入方法依赖的package包/类
/**
* Installs an OSGi bundle from the given location.
*
* @param location - location bundle to install
* @return bundle instance
* @throws Exception
*/
private Bundle installBundle(Resource location) throws Exception {
Assert.notNull(platformContext, "the OSGi platform is not set");
Assert.notNull(location, "cannot install from a null location");
if (logger.isDebugEnabled())
logger.debug("Installing bundle from location " + location.getDescription());
String bundleLocation;
try {
bundleLocation = URLDecoder.decode(location.getURL().toExternalForm(), UTF_8_CHARSET);
} catch (Exception ex) {
// the URL cannot be created, fall back to the description
bundleLocation = location.getDescription();
}
return platformContext.installBundle(bundleLocation, location.getInputStream());
}
示例2: getGroupIdFromPom
import org.springframework.core.io.Resource; //导入方法依赖的package包/类
/**
* Returns the <tt>groupId</tt> setting in a <tt>pom.xml</tt> file.
*
* @return a <tt>pom.xml</tt> <tt>groupId</tt>.
*/
String getGroupIdFromPom(Resource pomXml) {
try {
DocumentLoader docLoader = new DefaultDocumentLoader();
Document document = docLoader.loadDocument(new InputSource(pomXml.getInputStream()), null, null,
XmlValidationModeDetector.VALIDATION_NONE, false);
String groupId = DomUtils.getChildElementValueByTagName(document.getDocumentElement(), GROUP_ID_ELEM);
// no groupId specified, try the parent definition
if (groupId == null) {
if (log.isTraceEnabled())
log.trace("No groupId defined; checking for the parent definition");
Element parent = DomUtils.getChildElementByTagName(document.getDocumentElement(), "parent");
if (parent != null)
return DomUtils.getChildElementValueByTagName(parent, GROUP_ID_ELEM);
}
else {
return groupId;
}
}
catch (Exception ex) {
throw (RuntimeException) new RuntimeException(new ParserConfigurationException("error parsing resource="
+ pomXml).initCause(ex));
}
throw new IllegalArgumentException("no groupId or parent/groupId defined by resource ["
+ pomXml.getDescription() + "]");
}