本文整理汇总了Java中org.springframework.util.xml.DomUtils.getChildElementsByTagName方法的典型用法代码示例。如果您正苦于以下问题:Java DomUtils.getChildElementsByTagName方法的具体用法?Java DomUtils.getChildElementsByTagName怎么用?Java DomUtils.getChildElementsByTagName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.util.xml.DomUtils
的用法示例。
在下文中一共展示了DomUtils.getChildElementsByTagName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parsePropsElement
import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
/**
* Parse a props element.
*/
public Properties parsePropsElement(Element propsEle) {
ManagedProperties props = new OrderedManagedProperties();
props.setSource(extractSource(propsEle));
props.setMergeEnabled(parseMergeAttribute(propsEle));
List propEles = DomUtils.getChildElementsByTagName(propsEle, BeanDefinitionParserDelegate.PROP_ELEMENT);
for (Iterator it = propEles.iterator(); it.hasNext();) {
Element propEle = (Element) it.next();
String key = propEle.getAttribute(BeanDefinitionParserDelegate.KEY_ATTRIBUTE);
// Trim the text value to avoid unwanted whitespace
// caused by typical XML formatting.
String value = DomUtils.getTextValue(propEle).trim();
TypedStringValue keyHolder = new TypedStringValue(key);
keyHolder.setSource(extractSource(propEle));
TypedStringValue valueHolder = new TypedStringValue(value);
valueHolder.setSource(extractSource(propEle));
props.put(keyHolder, valueHolder);
}
return props;
}
示例2: doParse
import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
builder.addPropertyReference("transactionManager", TxNamespaceHandler.getTransactionManagerName(element));
List<Element> txAttributes = DomUtils.getChildElementsByTagName(element, ATTRIBUTES_ELEMENT);
if (txAttributes.size() > 1) {
parserContext.getReaderContext().error(
"Element <attributes> is allowed at most once inside element <advice>", element);
}
else if (txAttributes.size() == 1) {
// Using attributes source.
Element attributeSourceElement = txAttributes.get(0);
RootBeanDefinition attributeSourceDefinition = parseAttributeSource(attributeSourceElement, parserContext);
builder.addPropertyValue("transactionAttributeSource", attributeSourceDefinition);
}
else {
// Assume annotations source.
builder.addPropertyValue("transactionAttributeSource",
new RootBeanDefinition("org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"));
}
}
示例3: resolveScriptSource
import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
/**
* Resolves the script source from either the '{@code script-source}' attribute or
* the '{@code inline-script}' element. Logs and {@link XmlReaderContext#error} and
* returns {@code null} if neither or both of these values are specified.
*/
private String resolveScriptSource(Element element, XmlReaderContext readerContext) {
boolean hasScriptSource = element.hasAttribute(SCRIPT_SOURCE_ATTRIBUTE);
List<Element> elements = DomUtils.getChildElementsByTagName(element, INLINE_SCRIPT_ELEMENT);
if (hasScriptSource && !elements.isEmpty()) {
readerContext.error("Only one of 'script-source' and 'inline-script' should be specified.", element);
return null;
}
else if (hasScriptSource) {
return element.getAttribute(SCRIPT_SOURCE_ATTRIBUTE);
}
else if (!elements.isEmpty()) {
Element inlineElement = elements.get(0);
return "inline:" + DomUtils.getTextValue(inlineElement);
}
else {
readerContext.error("Must specify either 'script-source' or 'inline-script'.", element);
return null;
}
}
示例4: parseReplacedMethodSubElements
import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
/**
* Parse replaced-method sub-elements of the given bean element.
*/
public void parseReplacedMethodSubElements(Element beanEle, MethodOverrides overrides) {
NodeList nl = beanEle.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
Node node = nl.item(i);
if (isCandidateElement(node) && nodeNameEquals(node, REPLACED_METHOD_ELEMENT)) {
Element replacedMethodEle = (Element) node;
String name = replacedMethodEle.getAttribute(NAME_ATTRIBUTE);
String callback = replacedMethodEle.getAttribute(REPLACER_ATTRIBUTE);
ReplaceOverride replaceOverride = new ReplaceOverride(name, callback);
// Look for arg-type match elements.
List<Element> argTypeEles = DomUtils.getChildElementsByTagName(replacedMethodEle, ARG_TYPE_ELEMENT);
for (Element argTypeEle : argTypeEles) {
String match = argTypeEle.getAttribute(ARG_TYPE_MATCH_ATTRIBUTE);
match = (StringUtils.hasText(match) ? match : DomUtils.getTextValue(argTypeEle));
if (StringUtils.hasText(match)) {
replaceOverride.addTypeIdentifier(match);
}
}
replaceOverride.setSource(extractSource(replacedMethodEle));
overrides.addOverride(replaceOverride);
}
}
}
示例5: parsePropsElement
import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
/**
* Parse a props element.
*/
public Properties parsePropsElement(Element propsEle) {
ManagedProperties props = new ManagedProperties();
props.setSource(extractSource(propsEle));
props.setMergeEnabled(parseMergeAttribute(propsEle));
List<Element> propEles = DomUtils.getChildElementsByTagName(propsEle, PROP_ELEMENT);
for (Element propEle : propEles) {
String key = propEle.getAttribute(KEY_ATTRIBUTE);
// Trim the text value to avoid unwanted whitespace
// caused by typical XML formatting.
String value = DomUtils.getTextValue(propEle).trim();
TypedStringValue keyHolder = new TypedStringValue(key);
keyHolder.setSource(extractSource(propEle));
TypedStringValue valueHolder = new TypedStringValue(value);
valueHolder.setSource(extractSource(propEle));
props.put(keyHolder, valueHolder);
}
return props;
}
示例6: doParse
import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
builder.addPropertyReference("cacheManager", CacheNamespaceHandler.extractCacheManager(element));
CacheNamespaceHandler.parseKeyGenerator(element, builder.getBeanDefinition());
List<Element> cacheDefs = DomUtils.getChildElementsByTagName(element, DEFS_ELEMENT);
if (cacheDefs.size() >= 1) {
// Using attributes source.
List<RootBeanDefinition> attributeSourceDefinitions = parseDefinitionsSources(cacheDefs, parserContext);
builder.addPropertyValue("cacheOperationSources", attributeSourceDefinitions);
} else {
// Assume annotations source.
builder.addPropertyValue("cacheOperationSources", new RootBeanDefinition(
AnnotationCacheOperationSource.class));
}
}
示例7: getCallableInterceptors
import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
private ManagedList<?> getCallableInterceptors(Element element, Object source, ParserContext parserContext) {
ManagedList<? super Object> interceptors = new ManagedList<Object>();
Element asyncElement = DomUtils.getChildElementByTagName(element, "async-support");
if (asyncElement != null) {
Element interceptorsElement = DomUtils.getChildElementByTagName(asyncElement, "callable-interceptors");
if (interceptorsElement != null) {
interceptors.setSource(source);
for (Element converter : DomUtils.getChildElementsByTagName(interceptorsElement, "bean")) {
BeanDefinitionHolder beanDef = parserContext.getDelegate().parseBeanDefinitionElement(converter);
beanDef = parserContext.getDelegate().decorateBeanDefinitionIfRequired(converter, beanDef);
interceptors.add(beanDef);
}
}
}
return interceptors;
}
示例8: getDeferredResultInterceptors
import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
private ManagedList<?> getDeferredResultInterceptors(Element element, Object source, ParserContext parserContext) {
ManagedList<? super Object> interceptors = new ManagedList<Object>();
Element asyncElement = DomUtils.getChildElementByTagName(element, "async-support");
if (asyncElement != null) {
Element interceptorsElement = DomUtils.getChildElementByTagName(asyncElement, "deferred-result-interceptors");
if (interceptorsElement != null) {
interceptors.setSource(source);
for (Element converter : DomUtils.getChildElementsByTagName(interceptorsElement, "bean")) {
BeanDefinitionHolder beanDef = parserContext.getDelegate().parseBeanDefinitionElement(converter);
beanDef = parserContext.getDelegate().decorateBeanDefinitionIfRequired(converter, beanDef);
interceptors.add(beanDef);
}
}
}
return interceptors;
}
示例9: createContentNegotiatingViewResolver
import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
private BeanDefinition createContentNegotiatingViewResolver(Element resolverElement, ParserContext context) {
RootBeanDefinition beanDef = new RootBeanDefinition(ContentNegotiatingViewResolver.class);
beanDef.setSource(context.extractSource(resolverElement));
beanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
MutablePropertyValues values = beanDef.getPropertyValues();
List<Element> elements = DomUtils.getChildElementsByTagName(resolverElement, new String[] {"default-views"});
if (!elements.isEmpty()) {
ManagedList<Object> list = new ManagedList<Object>();
for (Element element : DomUtils.getChildElementsByTagName(elements.get(0), "bean", "ref")) {
list.add(context.getDelegate().parsePropertySubElement(element, null));
}
values.add("defaultViews", list);
}
if (resolverElement.hasAttribute("use-not-acceptable")) {
values.add("useNotAcceptableStatusCode", resolverElement.getAttribute("use-not-acceptable"));
}
Object manager = getContentNegotiationManager(context);
if (manager != null) {
values.add("contentNegotiationManager", manager);
}
return beanDef;
}
示例10: doParse
import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
super.doParse(element, parserContext, builder);
List<Element> opeationCodesElements = DomUtils.getChildElementsByTagName(element, "operation");
ArrayList<Integer> operationCodes = new ArrayList<Integer>();
ArrayList<String> operationCodesNames = new ArrayList<String>();
for (int i = 0; i < opeationCodesElements.size(); i++) {
String operationCode = opeationCodesElements.get(i).getAttribute("code");
if (StringUtils.hasText(operationCode)) {
operationCodes.add(Integer.valueOf(operationCode));
}
operationCode = opeationCodesElements.get(i).getAttribute("code-name");
if (StringUtils.hasText(operationCode)) {
operationCodesNames.add(operationCode);
}
}
int[] numberOperationCodes = new int[operationCodes.size()];
for (int i = 0; i < numberOperationCodes.length; i++) {
numberOperationCodes[i] = operationCodes.get(i);
}
builder.addPropertyValue("operationCodes", numberOperationCodes);
builder.addPropertyValue("operationCodesNames", operationCodesNames.toArray(new String[operationCodesNames.size()]));
}
示例11: handleModifierElements
import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked","rawtypes"})
private void handleModifierElements(Element element, ParserContext parserContext,
BeanDefinitionBuilder builder, ModifierElement modifierElementEnum) {
List<Element> modifiers = DomUtils.getChildElementsByTagName(element,
modifierElementEnum.name().toLowerCase() + "-modifier");
if (modifiers.isEmpty()) {
return;
}
ManagedList managedModifiers = new ManagedList();
for (Element modifierElement : modifiers) {
managedModifiers.add(parserContext.getDelegate().parsePropertySubElement(
modifierElement,
builder.getRawBeanDefinition(),
null));
}
builder.addPropertyValue("default" + modifierElementEnum.name() + "Modifiers",
managedModifiers);
}
示例12: parseCachingModels
import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
/**
* Parses the given XML element which sub-elements containing the properties
* of the caching models to create.
*
* @param element
* the XML element to parse
* @return a map containing the parsed caching models.The key of each element
* is the value of the XML attribute <code>target</code> (a String)
* and the value is the caching model (an instance of
* <code>CachingModel</code>)
*/
private Map parseCachingModels(Element element) {
List modelElements = DomUtils.getChildElementsByTagName(element, "caching");
if (CollectionUtils.isEmpty(modelElements)) {
return null;
}
String cacheModelKey = getCacheModelKey();
Map models = new HashMap();
int modelElementCount = modelElements.size();
for (int i = 0; i < modelElementCount; i++) {
Element modelElement = (Element) modelElements.get(i);
String key = modelElement.getAttribute(cacheModelKey);
CachingModel model = cacheModelParser.parseCachingModel(modelElement);
models.put(key, model);
}
return models;
}
示例13: parseFlushingModels
import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
/**
* Parses the given XML element which sub-elements containing the properties
* of the flushing models to create.
*
* @param element
* the XML element to parse
* @return a map containing the parsed flushing models.The key of each element
* is the value of the XML attribute <code>target</code> (a String) *
* and the value is the flushing model (an instance of
* <code>FlushingModel</code>)
*/
private Map parseFlushingModels(Element element) {
List modelElements = DomUtils.getChildElementsByTagName(element,
"flushing");
if (CollectionUtils.isEmpty(modelElements)) {
return null;
}
String cacheModelKey = getCacheModelKey();
Map models = new HashMap();
int modelElementCount = modelElements.size();
for (int i = 0; i < modelElementCount; i++) {
Element modelElement = (Element) modelElements.get(i);
String key = modelElement.getAttribute(cacheModelKey);
FlushingModel model = cacheModelParser.parseFlushingModel(modelElement);
models.put(key, model);
}
return models;
}
示例14: doParseFlushingModel
import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
/**
* Creates a <code>{@link JcsFlushingModel}</code> from the given XML
* element.
*
* @param element
* the XML element to parse
* @param flushBeforeMethodExecution
* indicates if the cache should be flushed before or after the
* execution of the intercepted method
* @return the created flushing model
*
* @see AbstractCacheModelParser#doParseFlushingModel(Element, boolean)
*/
protected FlushingModel doParseFlushingModel(Element element,
boolean flushBeforeMethodExecution) {
JcsFlushingModel model = new JcsFlushingModel();
List cacheElements = DomUtils.getChildElementsByTagName(element, "cache");
if (!CollectionUtils.isEmpty(cacheElements)) {
int count = cacheElements.size();
CacheStruct[] cacheStructs = new CacheStruct[count];
for (int i = 0; i < count; i++) {
Element cacheElement = (Element) cacheElements.get(i);
String cacheName = cacheElement.getAttribute("name");
String groups = cacheElement.getAttribute("groups");
CacheStruct cache = new CacheStruct(cacheName, groups);
cacheStructs[i] = cache;
}
model.setCacheStructs(cacheStructs);
}
model.setFlushBeforeMethodExecution(flushBeforeMethodExecution);
return model;
}
示例15: doParse
import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
/**
* JAVADOC Method Level Comments
*
* @param element JAVADOC.
* @param builder JAVADOC.
*/
@Override
protected void doParse(Element element, BeanDefinitionBuilder builder) {
List<Element> resources = DomUtils.getChildElementsByTagName(element,
SingletonBeanFactory.INSTANCE_FACTORY_ID);
List<Object> resnames = new ManagedList<Object>();
for (Element relement : resources) {
String pack = relement.getAttribute(PACKAGE);
if (StringUtils.isNotEmpty(pack)) {
resnames.add(new PackageBasedInstanceFactory(pack));
} else {
resnames.add(new RuntimeBeanReference(relement.getAttribute(REF)));
}
}
builder.addPropertyValue(INSTANCE_FACTORIES, resnames);
}