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


Java Resource.getDescription方法代碼示例

本文整理匯總了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());
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:25,代碼來源:AbstractOsgiTests.java

示例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() + "]");

}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:34,代碼來源:MavenPackagedArtifactFinder.java


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