Refine search
private ManagedList<String> getIncludePatterns(Element interceptor, String elementName) { List<Element> paths = DomUtils.getChildElementsByTagName(interceptor, elementName); ManagedList<String> patterns = new ManagedList<>(paths.size()); for (Element path : paths) { patterns.add(path.getAttribute("path")); } return patterns; }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { List<Element> childElements = DomUtils.getChildElementsByTagName(element, "template-loader-path"); if (!childElements.isEmpty()) { List<String> locations = new ArrayList<>(childElements.size()); for (Element childElement : childElements) { locations.add(childElement.getAttribute("location")); } if (locations.isEmpty()) { locations.add("/WEB-INF/"); } builder.addPropertyValue("templateLoaderPaths", StringUtils.toStringArray(locations)); } }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) { String contextPath = element.getAttribute("context-path"); if (StringUtils.hasText(contextPath)) { beanDefinitionBuilder.addPropertyValue("contextPath", contextPath); } List<Element> classes = DomUtils.getChildElementsByTagName(element, "class-to-be-bound"); if (!classes.isEmpty()) { ManagedList<String> classesToBeBound = new ManagedList<>(classes.size()); for (Element classToBeBound : classes) { String className = classToBeBound.getAttribute("name"); classesToBeBound.add(className); } beanDefinitionBuilder.addPropertyValue("classesToBeBound", classesToBeBound); } }
/** * Parse the validated document and add entries to the given unit info list. */ protected List<SpringPersistenceUnitInfo> parseDocument( Resource resource, Document document, List<SpringPersistenceUnitInfo> infos) throws IOException { Element persistence = document.getDocumentElement(); String version = persistence.getAttribute(PERSISTENCE_VERSION); URL rootUrl = determinePersistenceUnitRootUrl(resource); List<Element> units = DomUtils.getChildElementsByTagName(persistence, PERSISTENCE_UNIT); for (Element unit : units) { infos.add(parsePersistenceUnitInfo(unit, version, rootUrl)); } return infos; }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { List<Element> childElements = DomUtils.getChildElementsByTagName(element, "definitions"); if (!childElements.isEmpty()) { List<String> locations = new ArrayList<>(childElements.size()); for (Element childElement : childElements) { locations.add(childElement.getAttribute("location")); } builder.addPropertyValue("definitions", StringUtils.toStringArray(locations)); } if (element.hasAttribute("check-refresh")) { builder.addPropertyValue("checkRefresh", element.getAttribute("check-refresh")); } if (element.hasAttribute("validate-definitions")) { builder.addPropertyValue("validateDefinitions", element.getAttribute("validate-definitions")); } if (element.hasAttribute("definitions-factory")) { builder.addPropertyValue("definitionsFactoryClass", element.getAttribute("definitions-factory")); } if (element.hasAttribute("preparer-factory")) { builder.addPropertyValue("preparerFactoryClass", element.getAttribute("preparer-factory")); } }
/** * Parse the {@code property} XML elements. */ protected void parseProperties(Element persistenceUnit, SpringPersistenceUnitInfo unitInfo) { Element propRoot = DomUtils.getChildElementByTagName(persistenceUnit, PROPERTIES); if (propRoot == null) { return; } List<Element> properties = DomUtils.getChildElementsByTagName(propRoot, "property"); for (Element property : properties) { String name = property.getAttribute("name"); String value = property.getAttribute("value"); unitInfo.addProperty(name, value); } }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { List<Element> childElements = DomUtils.getChildElementsByTagName(element, "script"); if (!childElements.isEmpty()) { List<String> locations = new ArrayList<>(childElements.size()); for (Element childElement : childElements) { locations.add(childElement.getAttribute("location")); } builder.addPropertyValue("scripts", StringUtils.toStringArray(locations)); } builder.addPropertyValue("engineName", element.getAttribute("engine-name")); if (element.hasAttribute("render-object")) { builder.addPropertyValue("renderObject", element.getAttribute("render-object")); } if (element.hasAttribute("render-function")) { builder.addPropertyValue("renderFunction", element.getAttribute("render-function")); } if (element.hasAttribute("content-type")) { builder.addPropertyValue("contentType", element.getAttribute("content-type")); } if (element.hasAttribute("charset")) { builder.addPropertyValue("charset", Charset.forName(element.getAttribute("charset"))); } if (element.hasAttribute("resource-loader-path")) { builder.addPropertyValue("resourceLoaderPath", element.getAttribute("resource-loader-path")); } if (element.hasAttribute("shared-engine")) { builder.addPropertyValue("sharedEngine", element.getAttribute("shared-engine")); } }
private ManagedList<String> getIncludePatterns(Element interceptor, String elementName) { List<Element> paths = DomUtils.getChildElementsByTagName(interceptor, elementName); ManagedList<String> patterns = new ManagedList<>(paths.size()); for (Element path : paths) { patterns.add(path.getAttribute("path")); } return patterns; }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { List<Element> childElements = DomUtils.getChildElementsByTagName(element, "template-loader-path"); if (!childElements.isEmpty()) { List<String> locations = new ArrayList<>(childElements.size()); for (Element childElement : childElements) { locations.add(childElement.getAttribute("location")); } if (locations.isEmpty()) { locations.add("/WEB-INF/"); } builder.addPropertyValue("templateLoaderPaths", StringUtils.toStringArray(locations)); } }
/** * 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. */ @Nullable 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; } }
private void parseHeaderElements(Element element) { List<Element> headerElts = element == null ? Collections.<Element> emptyList() : DomUtils.getChildElementsByTagName(element, GENERIC_HEADER_ELEMENT); for (Element headerElt : headerElts) { String headerFactoryRef = headerElt.getAttribute(ATT_REF); if (StringUtils.hasText(headerFactoryRef)) { headerWriters.add(new RuntimeBeanReference(headerFactoryRef)); } else { BeanDefinitionBuilder builder = BeanDefinitionBuilder .genericBeanDefinition(StaticHeadersWriter.class); builder.addConstructorArgValue(headerElt.getAttribute(ATT_NAME)); builder.addConstructorArgValue(headerElt.getAttribute(ATT_VALUE)); headerWriters.add(builder.getBeanDefinition()); } } }
private ManagedList<BeanDefinition> parseOpenIDAttributes(Element attrExElt) { ManagedList<BeanDefinition> attributes = new ManagedList<>(); for (Element attElt : DomUtils.getChildElementsByTagName(attrExElt, Elements.OPENID_ATTRIBUTE)) { String name = attElt.getAttribute("name"); String type = attElt.getAttribute("type"); String required = attElt.getAttribute("required"); String count = attElt.getAttribute("count"); BeanDefinitionBuilder attrBldr = BeanDefinitionBuilder .rootBeanDefinition(OPEN_ID_ATTRIBUTE_CLASS); attrBldr.addConstructorArgValue(name); attrBldr.addConstructorArgValue(type); if (StringUtils.hasLength(required)) { attrBldr.addPropertyValue("required", Boolean.valueOf(required)); } if (StringUtils.hasLength(count)) { attrBldr.addPropertyValue("count", Integer.parseInt(count)); } attributes.add(attrBldr.getBeanDefinition()); } return attributes; }
private void parsePropertyElement(Element propertyElement) { Properties properties = new Properties(); for (Element element : DomUtils.getChildElementsByTagName(propertyElement, PROPERTY_ELEMENT)) { properties.put(element.getAttribute(PROPERTY_NAME_ATTRIBUTE), element.getAttribute(PROPERTY_VALUE_ATTRIBUTE)); } setProperties(properties); setJobPropertiesBean(properties); }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { List<Element> childElements = DomUtils.getChildElementsByTagName(element, "definitions"); if (!childElements.isEmpty()) { List<String> locations = new ArrayList<>(childElements.size()); for (Element childElement : childElements) { locations.add(childElement.getAttribute("location")); } builder.addPropertyValue("definitions", StringUtils.toStringArray(locations)); } if (element.hasAttribute("check-refresh")) { builder.addPropertyValue("checkRefresh", element.getAttribute("check-refresh")); } if (element.hasAttribute("validate-definitions")) { builder.addPropertyValue("validateDefinitions", element.getAttribute("validate-definitions")); } if (element.hasAttribute("definitions-factory")) { builder.addPropertyValue("definitionsFactoryClass", element.getAttribute("definitions-factory")); } if (element.hasAttribute("preparer-factory")) { builder.addPropertyValue("preparerFactoryClass", element.getAttribute("preparer-factory")); } }
/** * Parse the validated document and add entries to the given unit info list. */ protected List<SpringPersistenceUnitInfo> parseDocument( Resource resource, Document document, List<SpringPersistenceUnitInfo> infos) throws IOException { Element persistence = document.getDocumentElement(); String version = persistence.getAttribute(PERSISTENCE_VERSION); URL rootUrl = determinePersistenceUnitRootUrl(resource); List<Element> units = DomUtils.getChildElementsByTagName(persistence, PERSISTENCE_UNIT); for (Element unit : units) { infos.add(parsePersistenceUnitInfo(unit, version, rootUrl)); } return infos; }
List<Element> mappings = DomUtils.getChildElementsByTagName(element, "mapping"); CorsConfiguration config = new CorsConfiguration(); if (mapping.hasAttribute("allowed-origins")) { String[] allowedOrigins = StringUtils.tokenizeToStringArray(mapping.getAttribute("allowed-origins"), ","); config.setAllowedOrigins(Arrays.asList(allowedOrigins)); String[] allowedMethods = StringUtils.tokenizeToStringArray(mapping.getAttribute("allowed-methods"), ","); config.setAllowedMethods(Arrays.asList(allowedMethods)); String[] allowedHeaders = StringUtils.tokenizeToStringArray(mapping.getAttribute("allowed-headers"), ","); config.setAllowedHeaders(Arrays.asList(allowedHeaders));
public AbstractBeanDefinition parseInternal(Element elt, ParserContext pc) { // Parse the included methods List<Element> methods = DomUtils.getChildElementsByTagName(elt, Elements.PROTECT); Map<String, List<ConfigAttribute>> mappings = new LinkedHashMap<String, List<ConfigAttribute>>(); for (Element protectmethodElt : methods) { String[] tokens = StringUtils .commaDelimitedListToStringArray(protectmethodElt .getAttribute(ATT_ACCESS)); String methodName = protectmethodElt.getAttribute(ATT_METHOD); mappings.put(methodName, SecurityConfig.createList(tokens)); } RootBeanDefinition metadataSource = new RootBeanDefinition( MapBasedMethodSecurityMetadataSource.class); metadataSource.getConstructorArgumentValues().addGenericArgumentValue(mappings); return metadataSource; }
/** * 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. */ @Nullable 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; } }
/** * Parse the {@code property} XML elements. */ protected void parseProperties(Element persistenceUnit, SpringPersistenceUnitInfo unitInfo) { Element propRoot = DomUtils.getChildElementByTagName(persistenceUnit, PROPERTIES); if (propRoot == null) { return; } List<Element> properties = DomUtils.getChildElementsByTagName(propRoot, "property"); for (Element property : properties) { String name = property.getAttribute("name"); String value = property.getAttribute("value"); unitInfo.addProperty(name, value); } }
private void addExceptionClasses(String elementName, Element exceptionClassesElement, ManagedList<TypedStringValue> list, ParserContext parserContext) { for (Element child : DomUtils.getChildElementsByTagName(exceptionClassesElement, elementName)) { String className = child.getAttribute("class"); list.add(new TypedStringValue(className, Class.class)); } }