本文整理汇总了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;
}