本文整理匯總了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() + "]");
}