本文整理匯總了Java中org.springframework.util.xml.DomUtils.getChildElementValueByTagName方法的典型用法代碼示例。如果您正苦於以下問題:Java DomUtils.getChildElementValueByTagName方法的具體用法?Java DomUtils.getChildElementValueByTagName怎麽用?Java DomUtils.getChildElementValueByTagName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.util.xml.DomUtils
的用法示例。
在下文中一共展示了DomUtils.getChildElementValueByTagName方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getMavenSettingsLocalRepository
import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
/**
* Returns the <code>localRepository</code> settings as indicated by the
* <code>settings.xml</code> file.
*
* @return local repository as indicated by a Maven settings.xml file
*/
String getMavenSettingsLocalRepository(Resource m2Settings) {
// no file found, return null to continue the discovery process
if (!m2Settings.exists()) {
return null;
}
try {
DocumentLoader docLoader = new DefaultDocumentLoader();
Document document = docLoader.loadDocument(new InputSource(m2Settings.getInputStream()), null, null,
XmlValidationModeDetector.VALIDATION_NONE, false);
return (DomUtils.getChildElementValueByTagName(document.getDocumentElement(), LOCAL_REPOSITORY_ELEM));
} catch (Exception ex) {
throw new RuntimeException(new ParserConfigurationException("error parsing resource=" + m2Settings).initCause(ex));
}
}
示例2: postProcess
import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
@Override
protected void postProcess(BeanDefinitionBuilder definitionBuilder, Element element) {
Object envValue = DomUtils.getChildElementValueByTagName(element, ENVIRONMENT);
if (envValue != null) {
// Specific environment settings defined, overriding any shared properties.
definitionBuilder.addPropertyValue(JNDI_ENVIRONMENT, envValue);
}
else {
// Check whether there is a reference to shared environment properties...
String envRef = element.getAttribute(ENVIRONMENT_REF);
if (StringUtils.hasLength(envRef)) {
definitionBuilder.addPropertyValue(JNDI_ENVIRONMENT, new RuntimeBeanReference(envRef));
}
}
String lazyInit = element.getAttribute(LAZY_INIT_ATTRIBUTE);
if (StringUtils.hasText(lazyInit) && !DEFAULT_VALUE.equals(lazyInit)) {
definitionBuilder.setLazyInit(TRUE_VALUE.equals(lazyInit));
}
}
示例3: getMavenSettingsLocalRepository
import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
/**
* Returns the <code>localRepository</code> settings as indicated by the
* <code>settings.xml</code> file.
*
* @return local repository as indicated by a Maven settings.xml file
*/
String getMavenSettingsLocalRepository(Resource m2Settings) {
// no file found, return null to continue the discovery process
if (!m2Settings.exists())
return null;
try {
DocumentLoader docLoader = new DefaultDocumentLoader();
Document document = docLoader.loadDocument(new InputSource(m2Settings.getInputStream()), null, null,
XmlValidationModeDetector.VALIDATION_NONE, false);
return (DomUtils.getChildElementValueByTagName(document.getDocumentElement(), LOCAL_REPOSITORY_ELEM));
}
catch (Exception ex) {
throw (RuntimeException) new RuntimeException(new ParserConfigurationException("error parsing resource="
+ m2Settings).initCause(ex));
}
}
示例4: getGroupIdFromPom
import org.springframework.util.xml.DomUtils; //導入方法依賴的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() + "]");
}
示例5: parsePersistenceUnitInfo
import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
/**
* Parse the unit info DOM element.
*/
protected SpringPersistenceUnitInfo parsePersistenceUnitInfo(Element persistenceUnit, String version, URL rootUrl)
throws IOException {
SpringPersistenceUnitInfo unitInfo = new SpringPersistenceUnitInfo();
// set JPA version (1.0 or 2.0)
unitInfo.setPersistenceXMLSchemaVersion(version);
// set persistence unit root URL
unitInfo.setPersistenceUnitRootUrl(rootUrl);
// set unit name
unitInfo.setPersistenceUnitName(persistenceUnit.getAttribute(UNIT_NAME).trim());
// set transaction type
String txType = persistenceUnit.getAttribute(TRANSACTION_TYPE).trim();
if (StringUtils.hasText(txType)) {
unitInfo.setTransactionType(PersistenceUnitTransactionType.valueOf(txType));
}
// evaluate data sources
String jtaDataSource = DomUtils.getChildElementValueByTagName(persistenceUnit, JTA_DATA_SOURCE);
if (StringUtils.hasText(jtaDataSource)) {
unitInfo.setJtaDataSource(this.dataSourceLookup.getDataSource(jtaDataSource.trim()));
}
String nonJtaDataSource = DomUtils.getChildElementValueByTagName(persistenceUnit, NON_JTA_DATA_SOURCE);
if (StringUtils.hasText(nonJtaDataSource)) {
unitInfo.setNonJtaDataSource(this.dataSourceLookup.getDataSource(nonJtaDataSource.trim()));
}
// provider
String provider = DomUtils.getChildElementValueByTagName(persistenceUnit, PROVIDER);
if (StringUtils.hasText(provider)) {
unitInfo.setPersistenceProviderClassName(provider.trim());
}
// exclude unlisted classes
Element excludeUnlistedClasses = DomUtils.getChildElementByTagName(persistenceUnit, EXCLUDE_UNLISTED_CLASSES);
if (excludeUnlistedClasses != null) {
String excludeText = DomUtils.getTextValue(excludeUnlistedClasses);
unitInfo.setExcludeUnlistedClasses(!StringUtils.hasText(excludeText) || Boolean.valueOf(excludeText));
}
// set JPA 2.0 shared cache mode
String cacheMode = DomUtils.getChildElementValueByTagName(persistenceUnit, SHARED_CACHE_MODE);
if (StringUtils.hasText(cacheMode)) {
unitInfo.setSharedCacheMode(SharedCacheMode.valueOf(cacheMode));
}
// set JPA 2.0 validation mode
String validationMode = DomUtils.getChildElementValueByTagName(persistenceUnit, VALIDATION_MODE);
if (StringUtils.hasText(validationMode)) {
unitInfo.setValidationMode(ValidationMode.valueOf(validationMode));
}
parseProperties(persistenceUnit, unitInfo);
parseManagedClasses(persistenceUnit, unitInfo);
parseMappingFiles(persistenceUnit, unitInfo);
parseJarFiles(persistenceUnit, unitInfo);
return unitInfo;
}
示例6: parsePersistenceUnitInfo
import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
/**
* Parse the unit info DOM element.
*/
protected SpringPersistenceUnitInfo parsePersistenceUnitInfo(Element persistenceUnit, String version, URL rootUrl)
throws IOException {
SpringPersistenceUnitInfo unitInfo = new SpringPersistenceUnitInfo();
// set JPA version (1.0 or 2.0)
unitInfo.setPersistenceXMLSchemaVersion(version);
// set persistence unit root URL
unitInfo.setPersistenceUnitRootUrl(rootUrl);
// set unit name
unitInfo.setPersistenceUnitName(persistenceUnit.getAttribute(UNIT_NAME).trim());
// set transaction type
String txType = persistenceUnit.getAttribute(TRANSACTION_TYPE).trim();
if (StringUtils.hasText(txType)) {
unitInfo.setTransactionType(PersistenceUnitTransactionType.valueOf(txType));
}
// evaluate data sources
String jtaDataSource = DomUtils.getChildElementValueByTagName(persistenceUnit, JTA_DATA_SOURCE);
if (StringUtils.hasText(jtaDataSource)) {
unitInfo.setJtaDataSource(this.dataSourceLookup.getDataSource(jtaDataSource.trim()));
}
String nonJtaDataSource = DomUtils.getChildElementValueByTagName(persistenceUnit, NON_JTA_DATA_SOURCE);
if (StringUtils.hasText(nonJtaDataSource)) {
unitInfo.setNonJtaDataSource(this.dataSourceLookup.getDataSource(nonJtaDataSource.trim()));
}
// provider
String provider = DomUtils.getChildElementValueByTagName(persistenceUnit, PROVIDER);
if (StringUtils.hasText(provider)) {
unitInfo.setPersistenceProviderClassName(provider.trim());
}
// exclude unlisted classes
Element excludeUnlistedClasses = DomUtils.getChildElementByTagName(persistenceUnit, EXCLUDE_UNLISTED_CLASSES);
if (excludeUnlistedClasses != null) {
String excludeText = DomUtils.getTextValue(excludeUnlistedClasses);
unitInfo.setExcludeUnlistedClasses(!StringUtils.hasText(excludeText) || Boolean.valueOf(excludeText));
}
// set JPA 2.0 shared cache mode
String cacheMode = DomUtils.getChildElementValueByTagName(persistenceUnit, SHARED_CACHE_MODE);
if (StringUtils.hasText(cacheMode)) {
unitInfo.setSharedCacheModeName(cacheMode);
}
// set JPA 2.0 validation mode
String validationMode = DomUtils.getChildElementValueByTagName(persistenceUnit, VALIDATION_MODE);
if (StringUtils.hasText(validationMode)) {
unitInfo.setValidationModeName(validationMode);
}
parseProperties(persistenceUnit, unitInfo);
parseManagedClasses(persistenceUnit, unitInfo);
parseMappingFiles(persistenceUnit, unitInfo);
parseJarFiles(persistenceUnit, unitInfo);
return unitInfo;
}