Class XmlDocConfigurationProvider
java.lang.Object
org.apache.struts2.config.providers.XmlDocConfigurationProvider
- All Implemented Interfaces:
- ConfigurationProvider,- ContainerProvider,- PackageProvider
- Direct Known Subclasses:
- XmlConfigurationProvider
This is a base Struts 
ConfigurationProvider for loading configuration from a parsed
 XML document. By extending this class, configuration can be loaded from any source that an XML
 document can be parsed from. Note that this class does not validate the document against any provided DTDs. For
 loading configuration from an XML file with DTD validation, please see
 StrutsXmlConfigurationProvider.- Since:
- 6.2.0
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Configurationprotected ObjectFactoryprotected ProviderAllowlistprotected booleanprotected ValueSubstitutor
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddAction(Element actionElement, PackageConfig.Builder packageContext) protected static voidaddAllowedMethodsToSet(Node allowedMethodsNode, Set<String> allowedMethodsSet) protected PackageConfigaddPackage(Element packageElement) Create a PackageConfig from an XML element representing it.protected voidaddResultTypes(PackageConfig.Builder packageContext, Element element) protected Class<?>allowAndLoadClass(String className) protected ActionConfigbuildActionConfig(Element actionElement, Location location, PackageConfig.Builder packageContext, Map<String, ResultConfig> results) buildAllowedMethods(Element element, PackageConfig.Builder packageContext) protected List<ExceptionMappingConfig>buildExceptionMappings(Element element) Build a list of exception mapping objects from below a given XML element.protected InterceptorConfigbuildInterceptorConfig(Element interceptorElement) protected List<InterceptorMapping>buildInterceptorList(Element element, PackageConfig.Builder context) protected PackageConfig.BuilderbuildPackageContext(Element packageElement) This method builds a package context by looking for the parents of this new package.protected ResultConfigbuildResultConfig(String name, ResultTypeConfig config, Location location, Map<String, String> params) buildResultParams(Element resultElement, ResultTypeConfig config) protected Map<String,ResultConfig> buildResults(Element element, PackageConfig.Builder packageContext) Build a map of ResultConfig objects from below a given XML element.protected ResultTypeConfigbuildResultTypeConfig(Element resultTypeElement, Location location, String paramName) voiddestroy()Called before removed from the configuration managerReturns an unmodifiable map of DTD mappingsprotected static StringguessResultType(String type) voidinit(Configuration configuration) Initializes with the configurationstatic voiditerateChildren(Node node, Consumer<Node> function) static voiditerateChildrenByTagName(Element el, String tagName, Consumer<Element> function) static voiditerateElementChildren(Document doc, Consumer<Element> function) static voiditerateElementChildren(Node node, Consumer<Element> function) protected Class<?>protected voidloadDefaultActionRef(PackageConfig.Builder packageContext, Element element) protected voidloadDefaultClassRef(PackageConfig.Builder packageContext, Element element) protected voidloadDefaultInterceptorRef(PackageConfig.Builder packageContext, Element element) protected voidAllows subclasses to load extra information from the documentprotected voidloadGlobalAllowedMethods(PackageConfig.Builder packageContext, Element packageElement) protected voidloadGlobalExceptionMappings(PackageConfig.Builder packageContext, Element packageElement) Load all the global results for this package from the XML element.protected voidloadGlobalResults(PackageConfig.Builder packageContext, Element packageElement) Load all the global results for this package from the XML element.protected voidloadInterceptors(PackageConfig.Builder context, Element element) protected InterceptorStackConfigloadInterceptorStack(Element element, PackageConfig.Builder context) protected voidloadInterceptorStacks(Element element, PackageConfig.Builder context) voidLoads the packages for the configuration.protected List<InterceptorMapping>lookupInterceptorReference(PackageConfig.Builder context, Element interceptorRefElement) Looks up the Interceptor Class from the interceptor-ref name and creates an instance, which is added to the provided List, or, if this is a ref to a stack, it adds the Interceptor instances from the List to this stack.booleanTells whether the ContainerProvider should reload its configurationvoidregister(ContainerBuilder containerBuilder, LocatableProperties props) Registers beans and properties for the Containerprotected voidregisterBean(Element child, Map<String, Node> loadedBeans, ContainerBuilder containerBuilder) protected voidregisterBeanSelection(Element child, ContainerBuilder containerBuilder, LocatableProperties props) protected voidregisterConstant(Element child, LocatableProperties props) protected voidvoidsetDtdMappings(Map<String, String> mappings) voidsetObjectFactory(ObjectFactory objectFactory) voidsetProviderAllowlist(ProviderAllowlist providerAllowlist) voidsetThrowExceptionOnDuplicateBeans(boolean val) voidsetValueSubstitutor(ValueSubstitutor valueSubstitutor) protected voidverifyAction(String className, Location loc) protected voidverifyInterceptor(String className, Location loc) protected Class<?>verifyResultType(String className, Location loc) 
- 
Field Details- 
declaredPackages
- 
documents
- 
objectFactory
- 
dtdMappings
- 
configuration
- 
providerAllowlist
- 
throwExceptionOnDuplicateBeansprotected boolean throwExceptionOnDuplicateBeans
- 
valueSubstitutor
- 
allowlistClasses
 
- 
- 
Constructor Details- 
XmlDocConfigurationProvider
 
- 
- 
Method Details- 
setObjectFactory
- 
setValueSubstitutor
- 
setProviderAllowlist
- 
setThrowExceptionOnDuplicateBeanspublic void setThrowExceptionOnDuplicateBeans(boolean val) 
- 
setDtdMappings
- 
getDtdMappingsReturns an unmodifiable map of DTD mappings- Returns:
- map of DTD mappings
 
- 
initDescription copied from interface:ContainerProviderInitializes with the configuration- Specified by:
- initin interface- ContainerProvider
- Specified by:
- initin interface- PackageProvider
- Parameters:
- configuration- The configuration
 
- 
destroypublic void destroy()Description copied from interface:ContainerProviderCalled before removed from the configuration manager- Specified by:
- destroyin interface- ContainerProvider
 
- 
allowAndLoadClass- Throws:
- ClassNotFoundException
 
- 
loadClass- Throws:
- ClassNotFoundException
 
- 
iterateElementChildren
- 
iterateElementChildren
- 
iterateChildren
- 
iterateChildrenByTagName
- 
registerpublic void register(ContainerBuilder containerBuilder, LocatableProperties props) throws ConfigurationException Description copied from interface:ContainerProviderRegisters beans and properties for the Container- Specified by:
- registerin interface- ContainerProvider
- Parameters:
- containerBuilder- The builder to register beans with
- props- The properties to register constants with
- Throws:
- ConfigurationException- If anything goes wrong
 
- 
registerBeanSelectionprotected void registerBeanSelection(Element child, ContainerBuilder containerBuilder, LocatableProperties props) 
- 
registerBeanprotected void registerBean(Element child, Map<String, Node> loadedBeans, ContainerBuilder containerBuilder) 
- 
registerConstant
- 
registerUnknownHandlerStack
- 
needsReloadpublic boolean needsReload()Description copied from interface:ContainerProviderTells whether the ContainerProvider should reload its configuration- Specified by:
- needsReloadin interface- ContainerProvider
- Specified by:
- needsReloadin interface- PackageProvider
- Returns:
- true, whether the ContainerProvider should reload its configuration, falseotherwise.
 
- 
loadPackagesDescription copied from interface:PackageProviderLoads the packages for the configuration.- Specified by:
- loadPackagesin interface- PackageProvider
- Throws:
- ConfigurationException- in case of configuration errors
 
- 
loadExtraConfigurationAllows subclasses to load extra information from the document- Parameters:
- doc- The configuration document
 
- 
addPackageCreate a PackageConfig from an XML element representing it.- Parameters:
- packageElement- the given XML element
- Returns:
- the package config
- Throws:
- ConfigurationException- in case of configuration errors
 
- 
addActionprotected void addAction(Element actionElement, PackageConfig.Builder packageContext) throws ConfigurationException - Throws:
- ConfigurationException
 
- 
buildActionConfigprotected ActionConfig buildActionConfig(Element actionElement, Location location, PackageConfig.Builder packageContext, Map<String, ResultConfig> results) 
- 
verifyAction
- 
addResultTypes
- 
buildResultTypeConfigprotected ResultTypeConfig buildResultTypeConfig(Element resultTypeElement, Location location, String paramName) 
- 
verifyResultType
- 
buildPackageContextThis method builds a package context by looking for the parents of this new package. If no parents are found, it will return a root package. - Parameters:
- packageElement- the package element
- Returns:
- the package config builder
 
- 
buildResultsprotected Map<String,ResultConfig> buildResults(Element element, PackageConfig.Builder packageContext) Build a map of ResultConfig objects from below a given XML element.- Parameters:
- element- the given XML element
- packageContext- the package context
- Returns:
- map of result config objects
 
- 
buildResultConfigprotected ResultConfig buildResultConfig(String name, ResultTypeConfig config, Location location, Map<String, String> params) 
- 
buildResultParams
- 
guessResultType
- 
buildExceptionMappingsBuild a list of exception mapping objects from below a given XML element.- Parameters:
- element- the given XML element
- Returns:
- list of exception mapping config objects
 
- 
buildAllowedMethods
- 
loadDefaultActionRef
- 
loadGlobalResultsLoad all the global results for this package from the XML element.- Parameters:
- packageContext- the package context
- packageElement- the given XML element
 
- 
loadGlobalAllowedMethodsprotected void loadGlobalAllowedMethods(PackageConfig.Builder packageContext, Element packageElement) 
- 
addAllowedMethodsToSet
- 
loadDefaultClassRef
- 
loadGlobalExceptionMappingsprotected void loadGlobalExceptionMappings(PackageConfig.Builder packageContext, Element packageElement) Load all the global results for this package from the XML element.- Parameters:
- packageContext- the package context
- packageElement- the given XML element
 
- 
buildInterceptorListprotected List<InterceptorMapping> buildInterceptorList(Element element, PackageConfig.Builder context) throws ConfigurationException - Throws:
- ConfigurationException
 
- 
loadInterceptorsprotected void loadInterceptors(PackageConfig.Builder context, Element element) throws ConfigurationException - Throws:
- ConfigurationException
 
- 
verifyInterceptor
- 
buildInterceptorConfig
- 
loadInterceptorStacksprotected void loadInterceptorStacks(Element element, PackageConfig.Builder context) throws ConfigurationException - Throws:
- ConfigurationException
 
- 
loadInterceptorStackprotected InterceptorStackConfig loadInterceptorStack(Element element, PackageConfig.Builder context) throws ConfigurationException - Throws:
- ConfigurationException
 
- 
lookupInterceptorReferenceprotected List<InterceptorMapping> lookupInterceptorReference(PackageConfig.Builder context, Element interceptorRefElement) throws ConfigurationException Looks up the Interceptor Class from the interceptor-ref name and creates an instance, which is added to the provided List, or, if this is a ref to a stack, it adds the Interceptor instances from the List to this stack.- Parameters:
- context- The PackageConfig to look up the interceptor from
- interceptorRefElement- Element to pull interceptor ref data from
- Returns:
- A list of Interceptor objects
- Throws:
- ConfigurationException- in case of configuration errors
 
- 
loadDefaultInterceptorRef
 
-